Esempio n. 1
0
 /**
  * @param string|null $commandParent
  * @param string $commandName
  * @param string[] $commandParams
  * @return PromiseInterface
  */
 public function handle($commandParent, $commandName, $commandParams = [])
 {
     $protocol = $this->channel->createProtocol(new RuntimeCommand($commandName, $commandParams));
     if ($commandParent !== null) {
         $protocol->setDestination($commandParent);
     }
     $req = new Request($this->channel, $this->receiver, $protocol, ['timeout' => 2, 'retriesLimit' => 10, 'retriesInterval' => 1]);
     return $req->call();
 }
Esempio n. 2
0
 /**
  * @param mixed[] $params
  * @return mixed
  */
 protected function command($params = [])
 {
     $runtime = $this->runtime;
     $channel = $this->channel;
     $promise = Promise::doResolve();
     return $promise->then(function () use($runtime) {
         return $runtime->manager()->getRuntimes();
     })->then(function ($children) use($channel) {
         $promises = [];
         foreach ($children as $childAlias) {
             $req = new Request($channel, $childAlias, new RuntimeCommand('arch:status'));
             $promises[] = $req->call();
         }
         return Promise::all($promises);
     })->then(function ($childrenData) use($runtime) {
         return ['parent' => $runtime->parent(), 'alias' => $runtime->alias(), 'name' => $runtime->name(), 'state' => $runtime->state(), 'children' => $childrenData];
     });
 }
Esempio n. 3
0
 /**
  * @param mixed[] $params
  * @return mixed
  */
 protected function command($params = [])
 {
     $runtime = $this->runtime;
     $channel = $this->channel;
     $promise = $this->runtime->stop();
     return $promise->then(function () use($runtime) {
         return $runtime->manager()->getRuntimes();
     })->then(function ($children) use($channel) {
         $promises = [];
         foreach ($children as $childAlias) {
             $req = new Request($channel, $childAlias, new RuntimeCommand('arch:stop'));
             $promises[] = $req->call();
         }
         return Promise::all($promises);
     })->then(function () {
         return 'Part of architecture has been stopped.';
     }, function () {
         throw new RejectionException('Part of architecture could not be stopped.');
     });
 }
Esempio n. 4
0
 /**
  * @return PromiseInterface
  */
 public function getProcesses()
 {
     $req = new Request($this->channel, $this->receiver, new RuntimeCommand('process:get'));
     return $req->call();
 }
Esempio n. 5
0
 /**
  * @return PromiseInterface
  */
 public function getThreads()
 {
     $req = new Request($this->channel, $this->receiver, new RuntimeCommand('threads:get'));
     return $req->call();
 }
Esempio n. 6
0
 /**
  * @param mixed[] $params
  * @return mixed
  * @throws RejectionException
  */
 protected function command($params = [])
 {
     $req = new Request($this->channel, $this->config->get('main.alias'), new RuntimeCommand('arch:status'));
     return $req->call();
 }
Esempio n. 7
0
 /**
  * @param Error|Exception $ex
  * @param mixed[] $params
  * @return mixed
  */
 protected function handler($ex, $params = [])
 {
     $req = new Request($this->channel, $this->parent, new RuntimeCommand('cmd:error', ['exception' => get_class($ex), 'message' => $ex->getMessage()]));
     return $req->call();
 }
Esempio n. 8
0
 /**
  * @param string $alias
  * @return PromiseInterface
  */
 public function stopProcess($alias)
 {
     $req = new Request($this->channel, $alias, new RuntimeCommand('container:stop'));
     return $req->call();
 }