WorkerRunningEvent.php 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Messenger\Event;
  11. use Symfony\Component\Messenger\Worker;
  12. /**
  13. * Dispatched after the worker processed a message or didn't receive a message at all.
  14. *
  15. * @author Tobias Schultze <http://tobion.de>
  16. */
  17. final class WorkerRunningEvent
  18. {
  19. private $worker;
  20. private $isWorkerIdle;
  21. public function __construct(Worker $worker, bool $isWorkerIdle)
  22. {
  23. $this->worker = $worker;
  24. $this->isWorkerIdle = $isWorkerIdle;
  25. }
  26. public function getWorker(): Worker
  27. {
  28. return $this->worker;
  29. }
  30. /**
  31. * Returns true when no message has been received by the worker.
  32. */
  33. public function isWorkerIdle(): bool
  34. {
  35. return $this->isWorkerIdle;
  36. }
  37. }