/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $factory = new CommandFactory(); $manager = new CommandManager(); $core->instance('Surume\\Command\\CommandFactoryInterface', $factory); $core->instance('Surume\\Command\\CommandManagerInterface', $manager); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $model = $config->get('loop.model'); $loop = new Loop(new $model()); $core->instance('Surume\\Loop\\LoopInterface', $loop); $core->instance('Surume\\Loop\\LoopExtendedInterface', $loop); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $errorManager = $core->make('Surume\\Supervisor\\SupervisorInterface', [null, $config->get('error.manager.params')]); $errorSupervisor = $core->make('Surume\\Supervisor\\SupervisorInterface', [null, $config->get('error.supervisor.params')]); $core->instance('Surume\\Runtime\\Supervisor\\SupervisorBaseInterface', $errorManager); $core->instance('Surume\\Runtime\\Supervisor\\SupervisorRemoteInterface', $errorSupervisor); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $factory = new FilesystemAdapterFactory(); $fsCloud = new FilesystemManager(); $fsDisk = new Filesystem($factory->create('Local', [['path' => $core->basePath()]])); $disks = $config->get('filesystem.cloud'); foreach ($disks as $disk => $config) { $fsCloud->mountFilesystem($disk, new Filesystem($factory->create($config['factory'], [$config['config']]))); } $core->instance('Surume\\Filesystem\\FilesystemInterface', $fsDisk); $core->instance('Surume\\Filesystem\\FilesystemManagerInterface', $fsCloud); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $loop = $core->make('Surume\\Loop\\LoopInterface'); $context = $core->make('Surume\\Core\\CoreInputContextInterface'); $modelFactory = new ChannelModelFactory($context->alias(), $loop); $factory = new ChannelFactory($context->alias(), $modelFactory, $loop); $core->instance('Surume\\Channel\\ChannelModelFactoryInterface', $modelFactory); $core->factory('Surume\\Channel\\ChannelModelInterface', function () use($modelFactory) { return $modelFactory->create('Surume\\Channel\\Model\\Null\\NullModel'); }); $core->instance('Surume\\Channel\\ChannelFactoryInterface', $factory); $core->factory('Surume\\Channel\\ChannelBaseInterface', [$factory, 'create']); $core->factory('Surume\\Channel\\ChannelCompositeInterface', [$factory, 'create']); }
/** * @param CoreInterface $core * @throws Exception */ protected function register(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $factory = new CommandFactory(); $commands = (array) $config->get('command.models'); foreach ($commands as $commandClass) { if (!class_exists($commandClass)) { throw new ResourceUndefinedException("ConsoleCommand [{$commandClass}] does not exist."); } $factory->define($commandClass, function ($handler) use($commandClass) { return new $commandClass($handler); }); } $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); } $core->instance('Surume\\Console\\Client\\Command\\CommandFactoryInterface', $factory); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $config = $core->make('Surume\\Config\\ConfigInterface'); $factory = $core->make('Surume\\Channel\\ChannelFactoryInterface'); $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $console = $factory->create('Surume\\Channel\\ChannelBase', [$runtime->parent() === null ? $config->get('channel.channels.console.class') : 'Surume\\Channel\\Model\\Null\\NullModel', array_merge($config->get('channel.channels.console.config'), ['hosts' => Runtime::RESERVED_CONSOLE_CLIENT])]); $core->instance('Surume\\Runtime\\Channel\\ConsoleInterface', $console); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $factory = new SolverFactory($runtime); $config = []; $core->instance('Surume\\Supervisor\\SolverFactoryInterface', $factory); $core->factory('Surume\\Supervisor\\SupervisorInterface', function (SolverFactoryInterface $passedFactory = null, $passedConfig = [], $passedRules = []) use($factory, $config) { return new Supervisor($passedFactory !== null ? $passedFactory : $factory, array_merge($config, $passedConfig), $passedRules); }); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $this->commander = $core->make('Surume\\Command\\CommandManagerInterface'); $config = $core->make('Surume\\Config\\ConfigInterface'); $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $factory = $core->make('Surume\\Channel\\ChannelFactoryInterface'); $master = $factory->create('Surume\\Channel\\ChannelBase', [$runtime->parent() !== null ? $config->get('channel.channels.master.class') : 'Surume\\Channel\\Model\\Null\\NullModel', array_merge($config->get('channel.channels.master.config'), ['hosts' => $runtime->parent() !== null ? $runtime->parent() : $runtime->alias()])]); $slave = $factory->create('Surume\\Channel\\ChannelBase', [$config->get('channel.channels.slave.class'), $config->get('channel.channels.slave.config')]); $composite = $factory->create('Surume\\Channel\\ChannelComposite')->setBus('master', $master)->setBus('slave', $slave); $core->instance('Surume\\Runtime\\Channel\\ChannelInterface', $composite); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $factory = $core->make('Surume\\Channel\\ChannelFactoryInterface'); $config = $core->make('Surume\\Config\\ConfigInterface'); $console = $core->make('Surume\\Console\\Client\\ConsoleClientInterface'); $channel = $factory->create('Surume\\Channel\\ChannelBase', [$config->get('channel.channels.console.class'), array_merge($config->get('channel.channels.console.config'), ['hosts' => Runtime::RESERVED_CONSOLE_SERVER])]); $this->applyConsoleController($channel); $console->onStart(function () use($channel) { $channel->start(); }); $console->onStop(function () use($channel) { $channel->stop(); }); $core->instance('Surume\\Console\\Client\\Channel\\ConsoleInterface', $channel); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $this->commander = $core->make('Surume\\Command\\CommandManagerInterface'); $config = $core->make('Surume\\Config\\ConfigInterface'); $runtime = $core->make('Surume\\Runtime\\RuntimeInterface'); $factory = $core->make('Surume\\Channel\\ChannelFactoryInterface'); $master = $factory->create('Surume\\Channel\\ChannelBase', [$config->get('channel.channels.master.class'), $config->get('channel.channels.master.config')]); $slave = $factory->create('Surume\\Channel\\ChannelBase', [$config->get('channel.channels.slave.class'), array_merge($config->get('channel.channels.slave.config'), ['name' => Runtime::RESERVED_CONSOLE_CLIENT])]); $composite = $factory->create('Surume\\Channel\\ChannelComposite')->setBus('master', $master)->setBus('slave', $slave); // $composite->on('connect', function($alias) { // echo "Connected [$alias]\n"; // }); // $composite->on('disconnect', function($alias) { // echo "Disconnected [$alias]\n"; // }); $this->applyConsoleRouting($runtime, $composite); $core->instance('Surume\\Runtime\\Channel\\ChannelInterface', $composite); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $context = $core->make('Surume\\Core\\CoreInputContextInterface'); $config = $core->make('Surume\\Config\\ConfigInterface'); $env = new Environment($context, $config); $env->setOption('error_reporting', E_ALL); $env->setOption('log_errors', '1'); $env->setOption('display_errors', '0'); $inis = (array) $config->get('core.ini'); foreach ($inis as $option => $value) { $env->setOption($option, $value); } $this->setProcessProperties($env); $env->registerErrorHandler(['Surume\\Throwable\\ErrorEnvHandler', 'handleError']); $env->registerShutdownHandler(['Surume\\Throwable\\ErrorEnvHandler', 'handleShutdown']); $env->registerExceptionHandler(['Surume\\Throwable\\ExceptionEnvHandler', 'handleException']); $core->instance('Surume\\Core\\EnvironmentInterface', $env); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $core->instance('Surume\\Core\\CoreInputContextInterface', $this->console); $core->instance('Surume\\Console\\Client\\ConsoleClientInterface', $this->console); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $channel = $core->make('Surume\\Console\\Client\\Channel\\ConsoleInterface'); $manager = new CommandHandler($channel, 'ConsoleServer'); $core->instance('Surume\\Console\\Client\\Command\\CommandHandlerInterface', $manager); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $emitter = new EventEmitter($core->make('Surume\\Loop\\LoopInterface')); $core->instance('Surume\\Event\\EventEmitterInterface', $emitter); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $core->instance('Surume\\Core\\CoreInterface', $core); }
/** * @param CoreInterface $core */ protected function register(CoreInterface $core) { $core->instance('Surume\\Core\\CoreInputContextInterface', $this->runtime); $core->instance('Surume\\Runtime\\RuntimeInterface', $this->runtime); }