Esempio n. 1
0
 /**
  * Code to be executed by the WORKER when the task is run
  *
  * @param WorkEvent $event
  * @return void
  */
 public function execute(WorkEvent $event)
 {
     if ($this->getAuxPayload() !== 'payload') {
         throw new TaskFailedException("Payload incorrect (" . $this->getAuxPayload() . ")", $event);
     }
     $this->memory_pool->set('alpha', 1);
     $this->memory_pool->set('state', 'STARTING');
     $event->setResult('done woo!');
 }
Esempio n. 2
0
 /**
  * Execute a task
  *
  * @param TaskSchema $task
  * @param WorkEvent  $event
  */
 protected function executeTask(TaskSchema $task, WorkEvent $event)
 {
     $memory_pool = $this->getWorkflow()->getJailMemoryPool() ? JailedMemoryPool::jail($this->getMemoryPool(), ':' . $event->getExecutionId()) : $this->getMemoryPool();
     $class = $task->getClass();
     /** @var TaskInterface $obj */
     $obj = new $class($memory_pool, $event->getInput(), $this->getAuxPayload());
     if (!$obj instanceof TaskInterface) {
         throw new \DomainException("Class for task " . $task->getActivityName() . " is not a TaskInterface");
     }
     $obj->execute($event);
 }
Esempio n. 3
0
 /**
  * Code to be executed by the WORKER when the task is run
  *
  * @param WorkEvent $event
  * @return void
  */
 public function execute(WorkEvent $event)
 {
     if ($this->getAuxPayload() !== 'payload') {
         throw new TaskFailedException("Payload incorrect (" . $this->getAuxPayload() . ")", $event);
     }
     $event->setResult("bravo's your man");
     if ($event->getInput() == 'lalala') {
         $this->memory_pool->set('bravo', 2);
     } elseif ($event->getInput() !== self::EXPECTED_INPUT) {
         throw new TaskFailedException("Input is incorrect. Should be: '" . self::EXPECTED_INPUT . "', is '" . $event->getInput() . "'", $event);
     }
     $this->memory_pool->set('state', 'WORKING');
 }
Esempio n. 4
0
 /**
  * Code to be executed by the WORKER when the task is run
  *
  * @param WorkEvent $event
  * @return void
  */
 public function execute(WorkEvent $event)
 {
     if ($this->getAuxPayload() !== 'payload') {
         throw new TaskFailedException("Payload incorrect (" . $this->getAuxPayload() . ")", $event);
     }
     $input = json_decode($event->getInput(), true);
     if ($input['bravo-result'] !== self::EXPECTED_RESULT) {
         throw new TaskFailedException("Input ['bravo-result'] is incorrect. Should be: '" . self::EXPECTED_RESULT . "', is '" . $input['bravo-result'] . "'", $event);
     }
     if ($input['bravo-memory'] !== self::EXPECTED_MEMORY) {
         throw new TaskFailedException("Input ['bravo-memory'] is incorrect. Should be: '" . self::EXPECTED_MEMORY . "', is '" . $input['bravo-memory'] . "'", $event);
     }
     $this->memory_pool->set('charlie', 3);
     $this->memory_pool->set('state', 'COMPLETE');
     $event->setResult("charlie wins!");
 }
Esempio n. 5
0
 /**
  * Code to be executed by the WORKER when the task is run
  *
  * @param WorkEvent $event
  * @return void
  */
 public function execute(WorkEvent $event)
 {
     $this->memory_pool->set('omega', "Hello World");
     $this->memory_pool->set('state', 'FAILED');
     $event->setResult("oh ohh!");
 }