josegonzalez / cakephp-queuesadilla

CakePHP3: easily run background jobs on various message backends
https://cakephp-queuesadilla.readthedocs.org/en/latest/
MIT License
34 stars 14 forks source link

Add support to listen to worker events #7

Open rodrigorm opened 7 years ago

rodrigorm commented 7 years ago

When using then QueuesadillaShell I need to listen to Worker so I can react to some events in my CakePHP application.

rodrigorm commented 7 years ago

Maybe a mapper between League\Event and Cake\Event

cleptric commented 7 years ago

This would definitely be something very useful. We already talked about this topic before.

In the meantime, you can simply subclass the QueuesadillaShell and override the QueuesadillaShell::getWorker method.

public function getWorker($engine, $logger) {
        $worker->attachListener('Worker.job.failure', function ($event) {
            ...
        });
        return $worker;
}
rodrigorm commented 7 years ago

This is what I will do for now. :)