Ejemplo n.º 1
0
 /**
  *
  */
 public function testApiAll_RejectsPromise_IfAnyInputPromisesReject()
 {
     $test = $this->getTest();
     $mock = $test->createCallableMock();
     $mock->expects($test->once())->method('__invoke')->with($test->identicalTo(2));
     Promise::all([Promise::doResolve(1), Promise::doReject(2), Promise::doResolve(3)])->then($test->expectCallableNever(), $mock);
 }
Ejemplo n.º 2
0
 /**
  * @override
  * @inheritDoc
  */
 protected function command($params = [])
 {
     $runtime = $this->runtime;
     $channel = $this->channel;
     $promise = Promise::doResolve();
     return $promise->then(function () use($runtime) {
         return $runtime->getManager()->getRuntimes();
     })->then(function ($children) use($channel) {
         $promises = [];
         foreach ($children as $childAlias) {
             $req = $this->createRequest($channel, $childAlias, new RuntimeCommand('arch:status'));
             $promises[] = $req->call();
         }
         return Promise::all($promises);
     })->then(function ($childrenData) use($runtime) {
         return ['parent' => $runtime->getParent(), 'alias' => $runtime->getAlias(), 'name' => $runtime->getName(), 'state' => $runtime->getState(), 'children' => $childrenData];
     });
 }
Ejemplo n.º 3
0
 /**
  * @override
  * @inheritDoc
  */
 protected function command($params = [])
 {
     $runtime = $this->runtime;
     $channel = $this->channel;
     $promise = $this->runtime->start();
     return $promise->then(function () use($runtime) {
         return $runtime->getManager()->getRuntimes();
     })->then(function ($children) use($channel) {
         $promises = [];
         foreach ($children as $childAlias) {
             $req = $this->createRequest($channel, $childAlias, new RuntimeCommand('arch:start'));
             $promises[] = $req->call();
         }
         return Promise::all($promises);
     })->then(function () {
         return 'Part of architecture has been started.';
     }, function () {
         throw new RejectionException('Part of architecture could not be started.');
     });
 }
Ejemplo n.º 4
0
 /**
  * @override
  * @inheritDoc
  */
 public function flushProcesses($flags = Runtime::DESTROY_KEEP)
 {
     $promises = [];
     if ($flags === Runtime::DESTROY_KEEP) {
         return Promise::doReject(new RejectionException('Process storage could not be flushed because of force level set to DESTROY_KEEP.'));
     }
     foreach ($this->processes as $alias => $process) {
         $promises[] = $this->destroyProcess($alias, $flags);
     }
     return Promise::all($promises)->then(function () {
         $this->processes = [];
         $this->updateStorage();
         return 'Processes storage has been flushed.';
     });
 }
Ejemplo n.º 5
0
 /**
  * @override
  * @inheritDoc
  */
 public function flushRuntimes($flags = Runtime::DESTROY_KEEP)
 {
     return Promise::all([$this->flushThreads($flags), $this->flushProcesses($flags)]);
 }