mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 13:42:22 +00:00
2.0.0 Add namespacing + PHP8.0 support (#1)
2.0.0 (2021-02-19) Moved to PSR-4 Namespaced codebase Added more comments throughout Co-Authored-By: idanoo <daniel@m2.nz> Co-Committed-By: idanoo <daniel@m2.nz>
This commit is contained in:
parent
ebec2f7bf7
commit
80d64e79ff
56 changed files with 2215 additions and 1423 deletions
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
// Somewhere in our application, we need to register:
|
||||
Resque_Event::listen('afterEnqueue', ['My_Resque_Plugin', 'afterEnqueue']);
|
||||
Resque_Event::listen('beforeFirstFork', ['My_Resque_Plugin', 'beforeFirstFork']);
|
||||
Resque_Event::listen('beforeFork', ['My_Resque_Plugin', 'beforeFork']);
|
||||
Resque_Event::listen('afterFork', ['My_Resque_Plugin', 'afterFork']);
|
||||
Resque_Event::listen('beforePerform', ['My_Resque_Plugin', 'beforePerform']);
|
||||
Resque_Event::listen('afterPerform', ['My_Resque_Plugin', 'afterPerform']);
|
||||
Resque_Event::listen('onFailure', ['My_Resque_Plugin', 'onFailure']);
|
||||
|
||||
class Sample_Resque_Plugin
|
||||
{
|
||||
public static function afterEnqueue($class, $arguments)
|
||||
{
|
||||
echo "Job was queued for " . $class . ". Arguments:";
|
||||
print_r($arguments);
|
||||
}
|
||||
|
||||
public static function beforeFirstFork($worker)
|
||||
{
|
||||
echo "Worker started. Listening on queues: " . implode(', ', $worker->queues(false)) . "\n";
|
||||
}
|
||||
|
||||
public static function beforeFork($job)
|
||||
{
|
||||
echo "Just about to fork to run " . $job;
|
||||
}
|
||||
|
||||
public static function afterFork($job)
|
||||
{
|
||||
echo "Forked to run " . $job . ". This is the child process.\n";
|
||||
}
|
||||
|
||||
public static function beforePerform($job)
|
||||
{
|
||||
echo "Cancelling " . $job . "\n";
|
||||
// throw new Resque_Job_DontPerform;
|
||||
}
|
||||
|
||||
public static function afterPerform($job)
|
||||
{
|
||||
echo "Just performed " . $job . "\n";
|
||||
}
|
||||
|
||||
public static function onFailure($exception, $job)
|
||||
{
|
||||
echo $job . " threw an exception:\n" . $exception;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue