diff options
Diffstat (limited to 'lib/presque/worker.pm')
| -rw-r--r-- | lib/presque/worker.pm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/presque/worker.pm b/lib/presque/worker.pm index 1e3fd90..c7b6f01 100644 --- a/lib/presque/worker.pm +++ b/lib/presque/worker.pm @@ -18,6 +18,7 @@ with qw/ presque::worker::Role::Context presque::worker::Role::Logger/; +has spore_description => ( is => 'ro', isa => 'Str', required => 1, ); has queue_name => ( is => 'rw', isa => 'Str', @@ -59,16 +60,19 @@ has worker_id => ( $name; } ); + has rest_client => ( is => 'rw', - isa => 'Net::Presque', + isa => 'Object', lazy => 1, default => sub { - my $self = shift; - my $client = Net::Presque->new( - api_base_url => $self->context->{presque}->{url}, - worker_id => $self->worker_id - ); + my $self = shift; + my $client = + Net::HTTP::Spore->new( $self->spore_description, + base_url => $self->context->{presque}->{url} ); + $client->enable('Format::JSON'); + $client->enable( '+presque::worker::middleware::clientid', + worker_id => $self->worker_id ); $client; }, handles => { @@ -151,6 +155,8 @@ If no job, the worker execute the method B<idle>. By default, this method will s =head1 ATTRIBUTES +=head2 spore_description + =head2 queue_name =head2 base_uri |
