Ver Fonte

new GearmanWorkStartingEvent

David Moreau há 10 anos atrás
pai
commit
29e0ab901e
2 ficheiros alterados com 60 adições e 0 exclusões
  1. 51 0
      Event/GearmanWorkStartingEvent.php
  2. 9 0
      GearmanEvents.php

+ 51 - 0
Event/GearmanWorkStartingEvent.php

@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * Gearman Bundle for Symfony2
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * Feel free to edit as you please, and have fun.
+ *
+ * @author Marc Morera <yuhu@mmoreram.com>
+ */
+
+namespace Mmoreram\GearmanBundle\Event;
+
+use Symfony\Component\EventDispatcher\Event;
+
+/**
+ * GearmanWorkStartingEvent
+ *
+ * @author David Moreau <dmoreau@lafourchette.com>
+ */
+class GearmanWorkStartingEvent extends Event
+{
+    /**
+     * @var array
+     *
+     * Gearman jobs running
+     */
+    protected $jobs;
+
+    /**
+     * Construct method
+     *
+     * @param array $jobs Jobs
+     */
+    public function __construct(array $jobs)
+    {
+        $this->jobs = $jobs;
+    }
+
+    /**
+     * Get Gearman Work subscribed jobs
+     *
+     * @return array Subscribed jobs
+     */
+    public function getJobs()
+    {
+        return $this->jobs;
+    }
+}

+ 9 - 0
GearmanEvents.php

@@ -115,4 +115,13 @@ class GearmanEvents
      * @var string
      */
     const GEARMAN_WORK_EXECUTED = 'gearman.work.executed';
+
+    /**
+     * Sets a function to be called when a worker is starting a job.
+     *
+     * This will be fired when the worker start another work cycle.
+     *
+     * @var string
+     */
+    const GEARMAN_WORK_STARTING = 'gearman.work.starting';
 }