kernel_events.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. Kernel Events
  2. =============
  3. GearmanBundle transforms Gearman callbacks to Symfony2 kernel events.
  4. Complete Callback
  5. ~~~~~~~~~~~~~~~~~
  6. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackCompleteEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  7. For more information about this GearmanEvent, read [GearmanClient::setCompleteCallback](http://www.php.net/manual/en/gearmanclient.setcompletecallback.php) documentation.
  8. .. code-block:: yml
  9. services:
  10. my_event_listener:
  11. class: AcmeBundle\EventListener\MyEventListener
  12. tags:
  13. - { name: kernel.event_listener, event: gearman.client.callback.complete, method: onComplete }
  14. Created Callback
  15. ~~~~~~~~~~~~~~~~
  16. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackCreatedEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  17. For more information about this GearmanEvent, read [GearmanClient::setCreatedCallback](http://www.php.net/manual/en/gearmanclient.setcreatedcallback.php) documentation.
  18. .. code-block:: yml
  19. services:
  20. my_event_listener:
  21. class: AcmeBundle\EventListener\MyEventListener
  22. tags:
  23. - { name: kernel.event_listener, event: gearman.client.callback.created, method: onCreated }
  24. Data Callback
  25. ~~~~~~~~~~~~~
  26. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackDataEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  27. For more information about this GearmanEvent, read [GearmanClient::setDataCallback](http://www.php.net/manual/en/gearmanclient.setdatacallback.php) documentation.
  28. .. code-block:: yml
  29. services:
  30. my_event_listener:
  31. class: AcmeBundle\EventListener\MyEventListener
  32. tags:
  33. - { name: kernel.event_listener, event: gearman.client.callback.data, method: onData }
  34. Exception Callback
  35. ~~~~~~~~~~~~~~~~~~
  36. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackExceptionEvent` with no methods.
  37. For more information about this GearmanEvent, read [GearmanClient::setExceptionCallback](http://www.php.net/manual/en/gearmanclient.setexceptioncallback.php) documentation.
  38. .. code-block:: yml
  39. services:
  40. my_event_listener:
  41. class: AcmeBundle\EventListener\MyEventListener
  42. tags:
  43. - { name: kernel.event_listener, event: gearman.client.callback.exception, method: onExcept }
  44. Fail Callback
  45. ~~~~~~~~~~~~~
  46. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackFailEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  47. For more information about this GearmanEvent, read [GearmanClient::setFailCallback](http://www.php.net/manual/en/gearmanclient.setfailcallback.php) documentation.
  48. .. code-block:: yml
  49. services:
  50. my_event_listener:
  51. class: AcmeBundle\EventListener\MyEventListener
  52. tags:
  53. - { name: kernel.event_listener, event: gearman.client.callback.fail, method: onFail }
  54. Status Callback
  55. ~~~~~~~~~~~~~~~
  56. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackStatusEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  57. For more information about this GearmanEvent, read [GearmanClient::setStatusCallback](http://www.php.net/manual/en/gearmanclient.setstatuscallback.php) documentation.
  58. .. code-block:: yml
  59. services:
  60. my_event_listener:
  61. class: AcmeBundle\EventListener\MyEventListener
  62. tags:
  63. - { name: kernel.event_listener, event: gearman.client.callback.status, method: onStatus }
  64. Warning Callback
  65. ~~~~~~~~~~~~~~~~
  66. This event receives as parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackWarningEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  67. For more information about this GearmanEvent, read [GearmanClient::setWarningCallback](http://www.php.net/manual/en/gearmanclient.setwarningcallback.php) documentation.
  68. .. code-block:: yml
  69. services:
  70. my_event_listener:
  71. class: AcmeBundle\EventListener\MyEventListener
  72. tags:
  73. - { name: kernel.event_listener, event: gearman.client.callback.warning, method: onWarning }
  74. Workload Callback
  75. ~~~~~~~~~~~~~~~~~
  76. This event receives as parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackWorkloadEvent` with one method `$event->getGearmanTask()`. This method returns an instance of `\GearmanTask`.
  77. For more information about this GearmanEvent, read [GearmanClient::setWorkloadCallback](http://www.php.net/manual/en/gearmanclient.setworkloadcallback.php) documentation.
  78. .. code-block:: yml
  79. services:
  80. my_event_listener:
  81. class: AcmeBundle\EventListener\MyEventListener
  82. tags:
  83. - { name: kernel.event_listener, event: gearman.client.callback.workload, method: onWorkload }
  84. Execute Work Event
  85. ~~~~~~~~~~~~~~~~~~
  86. This event receives as parameter an instanceof `Mmoreram\GearmanBundle\Event\GearmanWorkExecutedEvent` with three methods:
  87. `$event->getJobs()` returns the configuration of the jobs,
  88. `$event->getIterationsRemaining()` returns the remaining iterations for these jobs,
  89. `$event->getReturnCode()` returns the return code of the last executed job.
  90. This event is dispatched after a job has been completed. After this event is completed, the worker continues with its iterations.
  91. .. code-block:: yml
  92. services:
  93. my_event_listener:
  94. class: AcmeBundle\EventListener\MyEventListener
  95. tags:
  96. - { name: kernel.event_listener, event: gearman.work.executed, method: onWorkExecuted }