summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-07-05 10:58:10 +0200
committerfranck cuny <franck@lumberjaph.net>2010-07-05 10:58:10 +0200
commit15c4ef19f3b4821fa0c7beeef76ec3d399348de8 (patch)
treefe65bcb618523302a3b7f0c9e7a8e29a84168c4a
parentworker's id is in the headers (diff)
downloadpresque-15c4ef19f3b4821fa0c7beeef76ec3d399348de8.tar.gz
reflect change about worker id; update POD
-rw-r--r--lib/presque/ControlHandler.pm4
-rw-r--r--lib/presque/RestQueueBatchHandler.pm24
-rw-r--r--lib/presque/RestQueueHandler.pm37
-rw-r--r--lib/presque/StatusHandler.pm2
4 files changed, 38 insertions, 29 deletions
diff --git a/lib/presque/ControlHandler.pm b/lib/presque/ControlHandler.pm
index b2cc77c..40a0f62 100644
--- a/lib/presque/ControlHandler.pm
+++ b/lib/presque/ControlHandler.pm
@@ -126,10 +126,12 @@ status of the queue: 1 or 0
/control/:queue_name
-=item request
+=item headers
content-type : application/json
+=item request
+
content : {"status":"stop"}
=item response
diff --git a/lib/presque/RestQueueBatchHandler.pm b/lib/presque/RestQueueBatchHandler.pm
index 48029a2..abdbe5e 100644
--- a/lib/presque/RestQueueBatchHandler.pm
+++ b/lib/presque/RestQueueBatchHandler.pm
@@ -96,8 +96,8 @@ sub _update_queue_stats {
sub _update_worker_stats {
my ($self, $queue_name, $jobs) = @_;
- my $input = $self->request->parameters;
- my $worker_id = $input->{worker_id};
+ my $worker_id = $self->request->header('X-presque-workerid')
+ if $self->request->header('X-presque-workerid');
if ($worker_id) {
$self->application->redis->hincrby($self->_workers_processed,
@@ -155,10 +155,10 @@ presque::RestQueueBatchHandler - insert or fetch jobs in batch
=head1 SYNOPSIS
# insert a list of jobs
- curl -H 'Content-Type: application/json' -X POST "http://localhost:5000/qb/foo" -d '{jobs:[{"key":"value"}, {"key2":"value2"}]}'
+ curl -H 'Content-Type: application/json' -H 'X-presque-workerid: worker_1' -X POST "http://localhost:5000/qb/foo" -d '{jobs:[{"key":"value"}, {"key2":"value2"}]}'
# fetch some jobs
- curl http://localhost:5000/qb/foo
+ curl -H 'X-presque-workerid: worker_1' http://localhost:5000/qb/foo
=head1 DESCRIPTION
@@ -174,9 +174,13 @@ Insert of fetch jobs in batch.
/qb/:queue_name
+=item headers
+
+X-presque-workerid: worker's ID (optional)
+
=item request
-queue_name: [required] name of the queue to use
+queue_name: name of the queue to use (required)
=item response
@@ -192,11 +196,15 @@ If the queue is closed: 404
/qb/:queue_name
-=item request
+=item headers
-queue_name: [required] name of the queue to use
+content-type: application/json
+
+X-presque-workerid: worker's ID (optional)
+
+=item request
-Content-Type: application/json
+queue_name: name of the queue to use (required)
=item response
diff --git a/lib/presque/RestQueueHandler.pm b/lib/presque/RestQueueHandler.pm
index 75c821a..92542ba 100644
--- a/lib/presque/RestQueueHandler.pm
+++ b/lib/presque/RestQueueHandler.pm
@@ -133,8 +133,7 @@ sub _update_queue_stats {
sub _update_worker_stats {
my ($self, $queue_name) = @_;
- my $input = $self->request->parameters;
- my $worker_id = $input->{worker_id};
+ my $worker_id = $self->request->header('X-presque-workerid');
if ($worker_id) {
$self->application->redis->hincrby($self->_workers_processed,
@@ -201,8 +200,8 @@ sub _insert_to_queue {
sub _failed_job {
my ($self, $queue_name) = @_;
- my $input = $self->request->parameters;
- my $worker_id = $input->{worker_id} if $input && $input->{worker_id};
+ my $worker_id = $self->request->header('X-presque-workerid')
+ if $self->request->header('X-presque-workerid');
$self->application->redis->hincrby($self->_queue_failed, $queue_name, 1);
@@ -269,11 +268,13 @@ presque::RestQueueHandler
/q/:queue_name
-=item request
+=item headers
+
+X-presque-workerid: worker's ID (optional)
-queue_name: [required] name of the queue to use
+=item request
-worker_id: [optional] id of the worker, used for stats
+queue_name: name of the queue to use (required)
=item response
@@ -297,23 +298,25 @@ If the queue is open, a job will be fetched from the queue and send to the clien
/q/:queue_name
-=item request
+=item headers
+
+content-type: application/json
-content-type : application/json
+X-presque-workerid: worker's ID
-content : JSON object
+=item request
-query : delayed, worker_id
+content: JSON object
-delayed : after which date (in epoch) this job should be run
+query: delayed, after which date (in epoch) this job should be run
-uniq : this job is uniq. The value is the string that will be used to determined if the job is uniq
+uniq: this job is uniq. The value is the string that will be used to determined if the job is uniq
=item response
code: 201
-content : null
+content: null
=back
@@ -331,9 +334,9 @@ the B<delayed> value should be a date in epoch.
/q/:queue_name
-=item request
+=item headers
-worker_id: [optional] id of the worker, used for stats
+X-presque-workerid: worker's id (optional)
=item response
@@ -351,8 +354,6 @@ content: null
/q/:queue_name
-=item request
-
=item response
code: 204
diff --git a/lib/presque/StatusHandler.pm b/lib/presque/StatusHandler.pm
index 8fee47e..51499e6 100644
--- a/lib/presque/StatusHandler.pm
+++ b/lib/presque/StatusHandler.pm
@@ -53,8 +53,6 @@ Return the current size of a queue
/status/:queue_name
-=item request
-
=item response
content-type : application/json