Last active
August 29, 2015 14:05
-
-
Save diegok/46b44a02a60aa4004636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Company::Task::Example; | |
# ABSTRACT: Example task class using moose | |
sub perform { | |
my $job = shift; | |
Company::Task::Example::Run->new( job => $job, %{$job->args->[0]} )->run; | |
} | |
package Company::Task::Example:Run; | |
use Moose; | |
with 'Company::Task::Role::ResqueJob'; # this provides job related attrs, like access to resque and redis :-) | |
with 'Company::Task::Role::Config'; | |
has url => ( is => 'ro', required => 1 ); | |
has first_seen => ( is => 'ro', lazy => 1, default => sub{time} ); | |
sub run { | |
my $self = shift; | |
if ( $self->first_seen < time-3600 ) { | |
$self->do_something_with_url; | |
} | |
else { | |
$self->requeue_job; | |
} | |
} | |
#... | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment