Skip to content

Commit

Permalink
testing tweaks, fix for schema
Browse files Browse the repository at this point in the history
funcname, run_after is not the right index anymore :)
  • Loading branch information
dormando committed Aug 5, 2011
1 parent 8a84b69 commit 3e85bf1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/SchwartzMan.pm
Expand Up @@ -51,7 +51,7 @@ sub new {

$self->{batch_fetch_limit} = MIN_BATCH_SIZE;
$self->{batch_run_sleep} = 1;
$self->{queue_watermark_depth} = 5; # FIXME: Example :P
$self->{queue_watermark_depth} = 4000; # FIXME: Example :P

return $self;
}
Expand Down Expand Up @@ -199,6 +199,7 @@ sub work {
unless $self->{batch_fetch_limit} <= MIN_BATCH_SIZE;
}

DEBUG && print STDERR "Sent, sleeping\n";
# Sleep for configured amount of time.
# TODO: Use the select microsleep hack?
sleep $self->{batch_run_sleep};
Expand Down
2 changes: 1 addition & 1 deletion schema.sql
Expand Up @@ -6,6 +6,6 @@ CREATE TABLE `job` (
`run_after` INT UNSIGNED NOT NULL,
`coalesce` VARCHAR(255) NULL,
PRIMARY KEY (jobid),
INDEX (funcname, run_after),
INDEX (run_after),
UNIQUE (funcname, uniqkey)
) ENGINE=InnoDB;
7 changes: 5 additions & 2 deletions sm_inject
Expand Up @@ -8,14 +8,15 @@ use lib "$Bin/lib";
use Getopt::Long;
use SchwartzMan::Client;

my %o = ();
my %o = (loops => 1);

# TODO: Doesn't support specifying multiple DB's yet. YAML config or whatever?
# TODO: Uhh... require a control manager or do our own fork management?
GetOptions(\%o,
'dsn=s',
'username=s',
'password=s',
'loops=i',
);

die "Need dsn" unless $o{dsn};
Expand All @@ -28,5 +29,7 @@ sub run {
pass => $o{password}, }},
);

$client->insert_job(funcname => 'foo', arg => 'hello: ' . time());
for (my $i = 0; $i < $o{loops} $i++) {
$client->insert_job(funcname => 'foo', arg => 'hello: ' . time());
}
}

0 comments on commit 3e85bf1

Please sign in to comment.