@@ -97,12 +97,12 @@ Jobs are queued as follows:
97
97
98
98
``` php
99
99
// Required if redis is located elsewhere
100
- Resque::setBackend('localhost:6379');
100
+ Resque\Resque ::setBackend('localhost:6379');
101
101
102
102
$args = array(
103
103
'name' => 'Chris'
104
104
);
105
- Resque::enqueue('default', 'My_Job', $args);
105
+ Resque\Resque ::enqueue('default', 'My_Job', $args);
106
106
```
107
107
108
108
### Defining Jobs
@@ -157,24 +157,24 @@ This method can be used to conveniently remove a job from a queue.
157
157
158
158
``` php
159
159
// Removes job class 'My_Job' of queue 'default'
160
- Resque::dequeue('default', ['My_Job']);
160
+ Resque\Resque ::dequeue('default', ['My_Job']);
161
161
162
162
// Removes job class 'My_Job' with Job ID '087df5819a790ac666c9608e2234b21e' of queue 'default'
163
- Resque::dequeue('default', ['My_Job' => '087df5819a790ac666c9608e2234b21e']);
163
+ Resque\Resque ::dequeue('default', ['My_Job' => '087df5819a790ac666c9608e2234b21e']);
164
164
165
165
// Removes job class 'My_Job' with arguments of queue 'default'
166
- Resque::dequeue('default', ['My_Job' => array('foo' => 1, 'bar' => 2)]);
166
+ Resque\Resque ::dequeue('default', ['My_Job' => array('foo' => 1, 'bar' => 2)]);
167
167
168
168
// Removes multiple jobs
169
- Resque::dequeue('default', ['My_Job', 'My_Job2']);
169
+ Resque\Resque ::dequeue('default', ['My_Job', 'My_Job2']);
170
170
```
171
171
172
172
If no jobs are given, this method will dequeue all jobs matching the provided
173
173
queue.
174
174
175
175
``` php
176
176
// Removes all jobs of queue 'default'
177
- Resque::dequeue('default');
177
+ Resque\Resque ::dequeue('default');
178
178
```
179
179
180
180
### Tracking Job Statuses
@@ -184,27 +184,27 @@ status information will allow you to check if a job is in the queue, is
184
184
currently being run, has finished, or has failed.
185
185
186
186
To track the status of a job, pass ` true ` as the fourth argument to
187
- ` Resque::enqueue ` . A token used for tracking the job status will be returned:
187
+ ` Resque\Resque ::enqueue ` . A token used for tracking the job status will be returned:
188
188
189
189
``` php
190
- $token = Resque::enqueue('default', 'My_Job', $args, true);
190
+ $token = Resque\Resque ::enqueue('default', 'My_Job', $args, true);
191
191
echo $token;
192
192
```
193
193
194
194
To fetch the status of a job:
195
195
196
196
``` php
197
- $status = new Resque_Job_Status ($token);
197
+ $status = new Resque\Job\Status ($token);
198
198
echo $status->get(); // Outputs the status
199
199
```
200
200
201
- Job statuses are defined as constants in the ` Resque_Job_Status ` class. Valid
201
+ Job statuses are defined as constants in the ` Resque\Job\Status ` class. Valid
202
202
statuses include:
203
203
204
- - ` Resque_Job_Status ::STATUS_WAITING` - Job is still queued
205
- - ` Resque_Job_Status ::STATUS_RUNNING` - Job is currently running
206
- - ` Resque_Job_Status ::STATUS_FAILED` - Job has failed
207
- - ` Resque_Job_Status ::STATUS_COMPLETE` - Job is complete
204
+ - ` Resque\Job\Status ::STATUS_WAITING` - Job is still queued
205
+ - ` Resque\Job\Status ::STATUS_RUNNING` - Job is currently running
206
+ - ` Resque\Job\Status ::STATUS_FAILED` - Job has failed
207
+ - ` Resque\Job\Status ::STATUS_COMPLETE` - Job is complete
208
208
- ` false ` - Failed to fetch the status; is the token valid?
209
209
210
210
Statuses are available for up to 24 hours after a job has completed or failed,
@@ -213,13 +213,13 @@ calling the `stop()` method on a status class.
213
213
214
214
### Obtaining job PID ###
215
215
216
- You can obtain the PID of the actual process doing the work through ` Resque_Job_PID ` . On a forking OS this will be the
216
+ You can obtain the PID of the actual process doing the work through ` Resque\Job\PID ` . On a forking OS this will be the
217
217
PID of the forked process.
218
218
219
219
CAUTION: on a non-forking OS, the PID returned will be of the worker itself.
220
220
221
221
``` php
222
- echo Resque_Job_PID ::get($token);
222
+ echo Resque\Job\PID ::get($token);
223
223
```
224
224
225
225
Function returns ` 0 ` if the ` perform ` hasn't started yet, or if it has already ended.
@@ -231,12 +231,12 @@ To quote the documentation for the Ruby resque-scheduler:
231
231
> Delayed jobs are one-off jobs that you want to be put into a queue at some
232
232
point in the future. The classic example is sending an email:
233
233
234
- require 'Resque/Resque .php';
235
- require 'ResqueScheduler/ResqueScheduler .php';
234
+ require 'Resque.php';
235
+ require 'Scheduler .php';
236
236
237
237
$in = 3600;
238
238
$args = array('id' => $user->id);
239
- ResqueScheduler ::enqueueIn($in, 'email', 'SendFollowUpEmail', $args);
239
+ Resque\Scheduler ::enqueueIn($in, 'email', 'SendFollowUpEmail', $args);
240
240
241
241
The above will store the job for 1 hour in the delayed queue, and then pull the
242
242
job off and submit it to the ` email ` queue in Resque for processing as soon as
@@ -246,14 +246,14 @@ Instead of passing a relative time in seconds, you can also supply a timestamp
246
246
as either a DateTime object or integer containing a UNIX timestamp to the
247
247
` enqueueAt ` method:
248
248
249
- require 'Resque/Resque .php';
250
- require 'ResqueScheduler/ResqueScheduler .php';
249
+ require 'Resque.php';
250
+ require 'Scheduler .php';
251
251
252
252
$time = 1332067214;
253
- ResqueScheduler ::enqueueAt($time, 'email', 'SendFollowUpEmail', $args);
253
+ Resque\Scheduler ::enqueueAt($time, 'email', 'SendFollowUpEmail', $args);
254
254
255
255
$datetime = new DateTime('2012-03-18 13:21:49');
256
- ResqueScheduler ::enqueueAt($datetime, 'email', 'SendFollowUpEmail', $args);
256
+ Resque\Scheduler ::enqueueAt($datetime, 'email', 'SendFollowUpEmail', $args);
257
257
258
258
NOTE: resque-scheduler does not guarantee a job will fire at the time supplied.
259
259
At the time supplied, resque-scheduler will take the job out of the delayed
@@ -426,11 +426,11 @@ It's easy to start the resque-scheduler worker using `bin/resque-scheduler`:
426
426
php-resque has a basic event system that can be used by your application to
427
427
customize how some of the php-resque internals behave.
428
428
429
- You listen in on events (as listed below) by registering with ` Resque_Event ` and
429
+ You listen in on events (as listed below) by registering with ` Resque\Event ` and
430
430
supplying a callback that you would like triggered when the event is raised:
431
431
432
- ``` sh
433
- Resque_Event ::listen(' eventName' , [callback]);
432
+ ``` php
433
+ Resque\Event ::listen('eventName', [callback]);
434
434
```
435
435
436
436
` [callback] ` may be anything in PHP that is callable by ` call_user_func_array ` :
@@ -443,12 +443,12 @@ Resque_Event::listen('eventName', [callback]);
443
443
Events may pass arguments (documented below), so your callback should accept
444
444
these arguments.
445
445
446
- You can stop listening to an event by calling ` Resque_Event ::stopListening` with
447
- the same arguments supplied to ` Resque_Event ::listen` .
446
+ You can stop listening to an event by calling ` Resque\Event ::stopListening` with
447
+ the same arguments supplied to ` Resque\Event ::listen` .
448
448
449
449
It is up to your application to register event listeners. When enqueuing events
450
450
in your application, it should be as easy as making sure php-resque is loaded
451
- and calling ` Resque_Event ::listen` .
451
+ and calling ` Resque\Event ::listen` .
452
452
453
453
When running workers, if you run workers via the default ` bin/resque ` script,
454
454
your ` APP_INCLUDE ` script should initialize and register any listeners required
@@ -462,20 +462,20 @@ A sample plugin is included in the `extras` directory.
462
462
#### beforeFirstFork
463
463
464
464
Called once, as a worker initializes. Argument passed is the instance of
465
- ` Resque_Worker ` that was just initialized.
465
+ ` Resque\Worker\ResqueWorker ` that was just initialized.
466
466
467
467
#### beforeFork
468
468
469
469
Called before php-resque forks to run a job. Argument passed contains the
470
- instance of ` Resque_Job ` for the job about to be run.
470
+ instance of ` Resque\JobHandler ` for the job about to be run.
471
471
472
472
` beforeFork ` is triggered in the ** parent** process. Any changes made will be
473
473
permanent for as long as the ** worker** lives.
474
474
475
475
#### afterFork
476
476
477
477
Called after php-resque forks to run a job (but before the job is run). Argument
478
- passed contains the instance of ` Resque_Job ` for the job about to be run.
478
+ passed contains the instance of ` Resque\JobHandler ` for the job about to be run.
479
479
480
480
` afterFork ` is triggered in the ** child** process after forking out to complete
481
481
a job. Any changes made will only live as long as the ** job** is being
@@ -484,16 +484,16 @@ processed.
484
484
#### beforePerform
485
485
486
486
Called before the ` setUp ` and ` perform ` methods on a job are run. Argument
487
- passed contains the instance of ` Resque_Job ` for the job about to be run.
487
+ passed contains the instance of ` Resque\JobHandler ` for the job about to be run.
488
488
489
489
You can prevent execution of the job by throwing an exception of
490
- ` Resque_Job_DontPerform ` . Any other exceptions thrown will be treated as if they
490
+ ` Resque\Exceptions\DoNotPerformException ` . Any other exceptions thrown will be treated as if they
491
491
were thrown in a job, causing the job to fail.
492
492
493
493
#### afterPerform
494
494
495
495
Called after the ` perform ` and ` tearDown ` methods on a job are run. Argument
496
- passed contains the instance of ` Resque_Job ` that was just run.
496
+ passed contains the instance of ` Resque\JobHandler ` that was just run.
497
497
498
498
Any exceptions thrown will be treated as if they were thrown in a job, causing
499
499
the job to be marked as having failed.
@@ -503,11 +503,11 @@ the job to be marked as having failed.
503
503
Called whenever a job fails. Arguments passed (in this order) include:
504
504
505
505
- Exception - The exception that was thrown when the job failed
506
- - Resque_Job - The job that failed
506
+ - Resque\JobHandler - The job that failed
507
507
508
508
#### beforeEnqueue
509
509
510
- Called immediately before a job is enqueued using the ` Resque::enqueue ` method.
510
+ Called immediately before a job is enqueued using the ` Resque\Resque ::enqueue ` method.
511
511
Arguments passed (in this order) include:
512
512
513
513
- Class - string containing the name of the job to be enqueued
@@ -516,11 +516,11 @@ Arguments passed (in this order) include:
516
516
- ID - string containing the token of the job to be enqueued
517
517
518
518
You can prevent enqueing of the job by throwing an exception of
519
- ` Resque_Job_DontCreate ` .
519
+ ` Resque\Exceptions\DoNotCreateException ` .
520
520
521
521
#### afterEnqueue
522
522
523
- Called after a job has been queued using the ` Resque::enqueue ` method. Arguments
523
+ Called after a job has been queued using the ` Resque\Resque ::enqueue ` method. Arguments
524
524
passed (in this order) include:
525
525
526
526
- Class - string containing the name of scheduled job
0 commit comments