[Catalyst] [OT]? Extends TheSchwartz
Rodrigo
rodrigolive at gmail.com
Thu Feb 12 13:05:50 GMT 2009
On Wed, Feb 11, 2009 at 5:38 PM, Lindolfo Lorn Rodrigues
<lorn.br at gmail.com>wrote:
> Hi, sorry for the off-topic but i'm search at google and the uniq list th=
at
> i found ( http://groups.google.com/group/theschwartz ) dont have nothing.
> I need a something like TheSchwartz::Scheduler, i was thinking in change
> TheSchwartz->work method, they will look the time to run a job and execu=
te
> the job only when is the rigth time
> Does anyone have some tips? I looked at CPAN but dont find anything like
> this.
>
I've been using TheSchwartz::Moosified in my Catalyst app to schedule jobs.
Something along these lines:
package MyApp::Worker;
use base 'TheSchwartz::Moosified::Worker';
sub work {
my ($class, $job) =3D @_;
print "WORKING:". $job->dump();
$job->completed;
}
package main;
use strict;
require MyApp;
use TheSchwartz::Moosified;
my $client =3D TheSchwartz::Moosified->new( verbose =3D> 1);
MyApp->model('DBIC')->storage->dbh_do(
sub {
my ($storage, $dbh) =3D @_;
$client->databases([$dbh]) or die $!;
} );
use Date::Manip; Date_Init( "TZ=3DCET");
## schedule a job
my $job =3D TheSchwartz::Moosified::Job->new(
funcname =3D> 'MyApp::Worker',
run_after=3D> UnixDate(ParseDate('2009-02-12 13:00:00'), '%s' ), ##
run_after expects a secs since epoch value
## you may also wanna set grabbed_until
arg =3D> [ foo =3D> 'bar' ],
);
$client->insert($job) or die $!;
$client->can_do('MyApp::Worker');
$client->work();
-rodrigo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090212/d54b9=
0f8/attachment.htm
More information about the Catalyst
mailing list