kernel_events.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 methods `$event->getGearmanTask()` and `&$event->getContext()`.
  7. First method returns an instance of `\GearmanTask`.
  8. For more information about this GearmanEvent, read [GearmanClient::setCompleteCallback](http://www.php.net/manual/en/gearmanclient.setcompletecallback.php) documentation.
  9. The second method will return `$context` that you could add in the `addTask()` method.
  10. .. code-block:: yml
  11. services:
  12. my_event_listener:
  13. class: AcmeBundle\EventListener\MyEventListener
  14. tags:
  15. - { name: kernel.event_listener, event: gearman.client.callback.complete, method: onComplete }
  16. Created Callback
  17. ~~~~~~~~~~~~~~~~
  18. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackCreatedEvent` with methods `$event->getGearmanTask()` and `&$event->getContext()`.
  19. First method returns an instance of `\GearmanTask`.
  20. For more information about this GearmanEvent, read [GearmanClient::setCreatedCallback](http://www.php.net/manual/en/gearmanclient.setcreatedcallback.php) documentation.
  21. The second method will return `$context` that you could add in the `addTask()` method.
  22. .. code-block:: yml
  23. services:
  24. my_event_listener:
  25. class: AcmeBundle\EventListener\MyEventListener
  26. tags:
  27. - { name: kernel.event_listener, event: gearman.client.callback.created, method: onCreated }
  28. Data Callback
  29. ~~~~~~~~~~~~~
  30. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackDataEvent` with methods `$event->getGearmanTask()` and `&$event->getContext()`.
  31. First method returns an instance of `\GearmanTask`.
  32. For more information about this GearmanEvent, read [GearmanClient::setDataCallback](http://www.php.net/manual/en/gearmanclient.setdatacallback.php) documentation.
  33. The second method will return `$context` that you could add in the `addTask()` method.
  34. .. code-block:: yml
  35. services:
  36. my_event_listener:
  37. class: AcmeBundle\EventListener\MyEventListener
  38. tags:
  39. - { name: kernel.event_listener, event: gearman.client.callback.data, method: onData }
  40. Exception Callback
  41. ~~~~~~~~~~~~~~~~~~
  42. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackExceptionEvent` with no methods.
  43. For more information about this GearmanEvent, read [GearmanClient::setExceptionCallback](http://www.php.net/manual/en/gearmanclient.setexceptioncallback.php) documentation.
  44. .. code-block:: yml
  45. services:
  46. my_event_listener:
  47. class: AcmeBundle\EventListener\MyEventListener
  48. tags:
  49. - { name: kernel.event_listener, event: gearman.client.callback.exception, method: onExcept }
  50. Fail Callback
  51. ~~~~~~~~~~~~~
  52. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackFailEvent` with methods `$event->getGearmanTask()` and `&$event->getContext()`.
  53. First method returns an instance of `\GearmanTask`.
  54. For more information about this GearmanEvent, read [GearmanClient::setFailCallback](http://www.php.net/manual/en/gearmanclient.setfailcallback.php) documentation.
  55. The second method will return `$context` that you could add in the `addTask()` method.
  56. .. code-block:: yml
  57. services:
  58. my_event_listener:
  59. class: AcmeBundle\EventListener\MyEventListener
  60. tags:
  61. - { name: kernel.event_listener, event: gearman.client.callback.fail, method: onFail }
  62. Status Callback
  63. ~~~~~~~~~~~~~~~
  64. This event receives as a parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackStatusEvent` with methods `$event->getGearmanTask()` and `&$event->getContext()`.
  65. First method returns an instance of `\GearmanTask`.
  66. For more information about this GearmanEvent, read [GearmanClient::setStatusCallback](http://www.php.net/manual/en/gearmanclient.setstatuscallback.php) documentation.
  67. The second method will return `$context` that you could add in the `addTask()` method.
  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.status, method: onStatus }
  74. Warning Callback
  75. ~~~~~~~~~~~~~~~~
  76. This event receives as parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackWarningEvent` with methods `$event->getGearmanTask()` and `&$event->getContext()`.
  77. First method returns an instance of `\GearmanTask`.
  78. For more information about this GearmanEvent, read [GearmanClient::setWarningCallback](http://www.php.net/manual/en/gearmanclient.setwarningcallback.php) documentation.
  79. The second method will return `$context` that you could add in the `addTask()` method.
  80. .. code-block:: yml
  81. services:
  82. my_event_listener:
  83. class: AcmeBundle\EventListener\MyEventListener
  84. tags:
  85. - { name: kernel.event_listener, event: gearman.client.callback.warning, method: onWarning }
  86. Workload Callback
  87. ~~~~~~~~~~~~~~~~~
  88. This event receives as parameter an instance of `Mmoreram\GearmanBundle\Event\GearmanClientCallbackWorkloadEvent` with methods `$event->getGearmanTask()` and `&$event->getContext()`.
  89. First method returns an instance of `\GearmanTask`.
  90. For more information about this GearmanEvent, read [GearmanClient::setWorkloadCallback](http://www.php.net/manual/en/gearmanclient.setworkloadcallback.php) documentation.
  91. The second method will return `$context` that you could add in the `addTask()` method.
  92. .. code-block:: yml
  93. services:
  94. my_event_listener:
  95. class: AcmeBundle\EventListener\MyEventListener
  96. tags:
  97. - { name: kernel.event_listener, event: gearman.client.callback.workload, method: onWorkload }
  98. Execute Work Event
  99. ~~~~~~~~~~~~~~~~~~
  100. This event receives as parameter an instanceof `Mmoreram\GearmanBundle\Event\GearmanWorkExecutedEvent` with three methods:
  101. `$event->getJobs()` returns the configuration of the jobs,
  102. `$event->getIterationsRemaining()` returns the remaining iterations for these jobs,
  103. `$event->getReturnCode()` returns the return code of the last executed job.
  104. This event is dispatched after a job has been completed. After this event is completed, the worker continues with its iterations.
  105. .. code-block:: yml
  106. services:
  107. my_event_listener:
  108. class: AcmeBundle\EventListener\MyEventListener
  109. tags:
  110. - { name: kernel.event_listener, event: gearman.work.executed, method: onWorkExecuted }