示例#1
0
 /**
  * @param ContainerInterface $container
  * @throws Exception
  */
 protected function boot(ContainerInterface $container)
 {
     $config = $container->make('Kraken\\Config\\ConfigInterface');
     $factory = $container->make('Kraken\\Channel\\ChannelModelFactoryInterface');
     $models = (array) $config->get('channel.models');
     foreach ($models as $modelClass) {
         if (!class_exists($modelClass)) {
             throw new ResourceUndefinedException("ChannelModel [{$modelClass}] does not exist.");
         }
         $factory->define($modelClass, function ($config) use($modelClass) {
             return new $modelClass($config);
         });
     }
     $plugins = (array) $config->get('channel.plugins');
     foreach ($plugins as $pluginClass) {
         if (!class_exists($pluginClass)) {
             throw new ResourceUndefinedException("FactoryPlugin [{$pluginClass}] does not exist.");
         }
         $plugin = new $pluginClass();
         if (!$plugin instanceof FactoryPluginInterface) {
             throw new InvalidArgumentException("FactoryPlugin [{$pluginClass}] does not implement FactoryPluginInterface.");
         }
         $plugin->registerPlugin($factory);
     }
 }
 /**
  * @param ContainerInterface $container
  * @throws Exception
  */
 protected function boot(ContainerInterface $container)
 {
     $config = $container->make('Kraken\\Config\\ConfigInterface');
     $factory = $container->make('Kraken\\Supervision\\SolverFactoryInterface');
     $handlers = (array) $config->get('supervision.solvers');
     foreach ($handlers as $handlerClass) {
         if (!class_exists($handlerClass)) {
             throw new ResourceUndefinedException("Solver [{$handlerClass}] does not exist.");
         }
         $factory->define($handlerClass, function ($runtime, $context = []) use($handlerClass) {
             return new $handlerClass($runtime, $context);
         });
     }
     $plugins = (array) $config->get('supervision.plugins');
     foreach ($plugins as $pluginClass) {
         if (!class_exists($pluginClass)) {
             throw new ResourceUndefinedException("SupervisorPlugin [{$pluginClass}] does not exist.");
         }
         $plugin = new $pluginClass();
         if (!$plugin instanceof FactoryPluginInterface) {
             throw new InvalidArgumentException("SupervisorPlugin [{$pluginClass}] does not implement SupervisorPluginInterface.");
         }
         $plugin->registerPlugin($factory);
     }
 }
示例#3
0
 /**
  * @param ContainerInterface $container
  * @throws Exception
  */
 protected function boot(ContainerInterface $container)
 {
     $config = $container->make('Kraken\\Config\\ConfigInterface');
     $factory = $container->make('Kraken\\Runtime\\Command\\CommandFactoryInterface');
     $commands = (array) $config->get('command.models');
     foreach ($commands as $commandClass) {
         if (!class_exists($commandClass)) {
             throw new ResourceUndefinedException("Command [{$commandClass}] does not exist.");
         }
         $factory->define($commandClass, function ($runtime, $context = []) use($commandClass) {
             return new $commandClass($runtime, $context);
         });
     }
     $plugins = (array) $config->get('command.plugins');
     foreach ($plugins as $pluginClass) {
         if (!class_exists($pluginClass)) {
             throw new ResourceUndefinedException("FactoryPlugin [{$pluginClass}] does not exist.");
         }
         $plugin = new $pluginClass();
         if (!$plugin instanceof FactoryPluginInterface) {
             throw new InvalidArgumentException("FactoryPlugin [{$pluginClass}] does not implement FactoryPluginInterface.");
         }
         $plugin->registerPlugin($factory);
     }
 }
 /**
  * @param ContainerInterface $container
  * @throws Exception
  */
 protected function boot(ContainerInterface $container)
 {
     $config = $container->make('Kraken\\Config\\ConfigInterface');
     $baseSupervisor = $container->make('Kraken\\Runtime\\Supervision\\SupervisorBaseInterface');
     $remoteSupervisor = $container->make('Kraken\\Runtime\\Supervision\\SupervisorRemoteInterface');
     $this->bootBaseSupervision($baseSupervisor, $config);
     $this->bootRemoteSupervision($remoteSupervisor, $config);
 }
示例#5
0
 /**
  * @param ContainerInterface $core
  */
 protected function boot(ContainerInterface $core)
 {
     $config = $core->make('Kraken\\Config\\ConfigInterface');
     $runtime = $core->make('Kraken\\Runtime\\RuntimeContainerInterface');
     $factory = $core->make('Kraken\\Runtime\\Command\\CommandFactoryInterface');
     $manager = $core->make('Kraken\\Runtime\\Command\\CommandManagerInterface');
     $manager->import($this->getDefaultCommands($runtime));
     $manager->import($this->getAppCommands($config, $factory, $runtime));
 }
 /**
  * @param ContainerInterface $container
  */
 protected function register(ContainerInterface $container)
 {
     $loop = $container->make('Kraken\\Loop\\LoopExtendedInterface');
     $runtime = $container->make('Kraken\\Runtime\\RuntimeContainerInterface');
     $error = $container->make('Kraken\\Runtime\\Supervision\\SupervisorBaseInterface');
     $manager = $container->make('Kraken\\Runtime\\RuntimeManagerInterface');
     $model = $runtime->getModel();
     $model->setLoop($loop);
     $model->setSupervisor($error);
     $model->setRuntimeManager($manager);
 }
示例#7
0
 /**
  * @param ContainerInterface $container
  */
 protected function boot(ContainerInterface $container)
 {
     $runtime = $container->make('Kraken\\Runtime\\RuntimeContainerInterface');
     $channel = $container->make('Kraken\\Runtime\\Service\\ChannelInternal');
     $loop = $container->make('Kraken\\Loop\\LoopInterface');
     $this->applyConsoleRouting($runtime, $channel);
     $runtime->on('create', function () use($channel) {
         $channel->start();
     });
     $runtime->on('destroy', function () use($loop, $channel) {
         $loop->onTick(function () use($channel) {
             $channel->stop();
         });
     });
 }
 /**
  * @param ContainerInterface $container
  */
 protected function boot(ContainerInterface $container)
 {
     $core = $container->make('Kraken\\Core\\CoreInterface');
     $factory = $container->make('Kraken\\Console\\Client\\Command\\CommandFactoryInterface');
     $manager = $container->make('Kraken\\Console\\Client\\Command\\CommandManagerInterface');
     $channel = $container->make('Kraken\\Console\\Client\\Service\\ChannelConsole');
     $console = $container->make('Kraken\\Console\\Client\\ClientInterface');
     $cmds = (array) $factory->getDefinitions();
     $commands = [];
     foreach ($cmds as $command => $definition) {
         $commands[] = $factory->create($command, [$channel, 'Server']);
     }
     $manager->setAutoExit(false);
     $manager->setVersion($core->getVersion());
     $manager->addCommands($commands);
     $console->onCommand(function () use($manager) {
         $manager->run();
     });
 }
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Filesystem\\FilesystemInterface');
     $container->remove('Kraken\\Filesystem\\FilesystemFactoryInterface');
     $container->remove('Kraken\\Filesystem\\FilesystemManagerInterface');
 }
 /**
  * @param ContainerInterface $container
  * @param RuntimeManagerFactoryInterface $managerFactory
  * @param mixed[] $default
  * @param mixed[] $config
  * @return RuntimeManagerInterface
  */
 private function createManager(ContainerInterface $container, RuntimeManagerFactoryInterface $managerFactory, $default, $config)
 {
     $managerClass = $config['class'];
     $managerConfig = array_merge($default, $config['config']);
     foreach ($managerConfig as $key => $value) {
         if (is_string($value) && class_exists($value)) {
             $managerConfig[$key] = $container->make($value);
         }
     }
     return $managerFactory->create($managerClass, [$managerConfig]);
 }
示例#11
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Console\\Server\\Manager\\ProjectManagerInterface');
 }
示例#12
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     unset($this->core);
     unset($this->context);
     $container->remove('Kraken\\Config\\ConfigInterface');
 }
示例#13
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Runtime\\RuntimeContextInterface');
     $container->remove('Kraken\\Runtime\\RuntimeContainerInterface');
 }
示例#14
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Loop\\LoopInterface');
     $container->remove('Kraken\\Loop\\LoopExtendedInterface');
 }
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Environment\\EnvironmentInterface');
 }
示例#16
0
 /**
  * @param ContainerInterface $container
  */
 public function unregister(ContainerInterface $container)
 {
     $container->remove(ResourceInterface::class);
 }
示例#17
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Log\\LoggerInterface');
     $container->remove('Kraken\\Log\\LoggerFactory');
 }
示例#18
0
 /**
  * @param ContainerInterface $container
  */
 protected function boot(ContainerInterface $container)
 {
     $console = $container->make('Kraken\\Console\\Client\\ClientInterface');
     $loop = $container->make('Kraken\\Loop\\LoopExtendedInterface');
     $console->setLoop($loop);
 }
示例#19
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Console\\Client\\Command\\CommandFactoryInterface');
     $container->remove('Kraken\\Console\\Client\\Command\\CommandManagerInterface');
 }
示例#20
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Util\\System\\SystemInterface');
 }
示例#21
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Event\\EventEmitterInterface');
 }
示例#22
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Core\\CoreInterface');
 }
示例#23
0
 /**
  * @param ContainerInterface $container
  */
 public function boot(ContainerInterface $container)
 {
     $res = $container->make(Resource::class);
     $res->data['booted'] = true;
 }
示例#24
0
 /**
  * @param ContainerInterface $container
  */
 protected function unregister(ContainerInterface $container)
 {
     $container->remove('Kraken\\Console\\Client\\Service\\ChannelConsole');
 }