juriansluiman/SlmQueue — pull request #50 by bakura10 (2013-06-03 07:37:05+00:00)
Title: Add support for events

@juriansluiman @basz

This PR adds support for events. As events add some overhead in ZF 2, I decided (according to our previous discussion), to keep it really simple. It triggers four events in the worker:

- EVENT_PROCESS_QUEUE_PRE : triggers after the queue is retrieved, but before any job to be processed.
- EVENT_PROCESS_JOB_PRE : triggers after one job is retrieved, but before it is executed.
- EVENT_PROCESS_JOB_POST : after the job is executed.
- EVENT_PROCESS_QUEUE_POST : after all the jobs are executed, or after a termination criteria is reached.

Queue events only have access to the queue, while job events have access to the queue and the job.

Listeners can be registered for all workers in a generic way (using the SlmQueue\Worker\WorkerInterface identifier) or using the concrete name of the worker instance.

If you like it, I'll add tests and write doc.