summaryrefslogtreecommitdiff
path: root/lib/presque/worker.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-11-26 14:26:14 +0100
committerfranck cuny <franck@lumberjaph.net>2010-11-26 14:26:14 +0100
commit2b9b256f473c3b4ab8316d290d49da76d9b2a191 (patch)
treecee0587d77d199ce3eb5e6b8a52dd901e1db7e97 /lib/presque/worker.pm
parentadd new middleware for clientid (diff)
downloadpresque-worker-2b9b256f473c3b4ab8316d290d49da76d9b2a191.tar.gz
add new middleware for clientid
Diffstat (limited to 'lib/presque/worker.pm')
-rw-r--r--lib/presque/worker.pm18
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