-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.pl
More file actions
28 lines (20 loc) · 701 Bytes
/
worker.pl
File metadata and controls
28 lines (20 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package Worker; # TheSchwartz::Worker subclass
use feature qw/say/;
use base qw/TheSchwartz::Worker/;
use TheSchwartz::Job;
sub work {
my $class = shift;
my TheSchwartz::Job $job = shift; # bless the $job to TheSchwartz::Job class
say $job->arg->{message}; # display args passed
$job->completed; # TODO: catch failure and do $job->failed($msg, $exit_status)
}
package main; # Main worker class
use TheSchwartz;
use Config::FromHash;
my $config = Config::FromHash->new(
filenames => ["config.pl"],
require_all_files => 1,
);
my $client = TheSchwartz->new( databases => $config->get("db_info") );
$client->can_do("Worker"); # define ability
$client->work; # do the queued job