创建任务响应句柄

@param  string $name

@return One\Swoole\Components\Task\Contracts\TaskHandler
@throws \RuntimeException
506040
protected function createHandler(string $name): TaskHandler
    {
        $handler = Reflection::newInstance(ltrim($name, '\\'));

        if ($handler instanceof TaskHandler) {
            return $handler;
        }

        throw new RuntimeException('Task ' . $name . ' handler must implements `TaskHandler` interface');
    }
441290
public static function getInstance(string $name): \Swoole\Atomic
    {
        if(!static::$isInited)
        {
            throw new \RuntimeException('getInstance failed, AtomicManager is not initialized');
        }
        if(!isset(static::$atomics[$name]))
        {
            throw new \RuntimeException(sprintf('GetInstance failed, %s is not found', $name));
        }
        return static::$atomics[$name];
    }
1336992
public static function getInstance(string $name): \Swoole\Table
    {
        if(!static::$isInited)
        {
            throw new \RuntimeException('getInstance failed, MemoryTableManager is not initialized');
        }
        if(!isset(static::$tables[$name]))
        {
            throw new \RuntimeException(sprintf('GetInstance failed, %s is not found', $name));
        }
        return static::$tables[$name];
    }
1244060
public function getHandler($name) {
        if (!isset($this->instances[$name])) {
            $handlerClass = __NAMESPACE__ . '\\' . $name;
            $this->instances[$name] = new $handlerClass($this->builder);
        }
        return $this->instances[$name];
    }
747077
public function getConnector($name)
    {
        if (!$this->connector_map->hasKey($name)) {
            throw new RuntimeError(
                sprintf('Can\'t find connector with name: %s. Maybe a typo within the connections.xml?', $name)
            );
        }

        return $this->connector_map->getItem($name);
    }
1135310
public function getModuleByName($name)
    {
        $modules = $this->getModuleRepository();
        if ($modules->has($name) === false) {
            throw new RuntimeException("Module [$name] does not exists.");
        }

        return $modules->find($name);
    }
833585
public function getPool($name) : CacheItemPoolInterface
    {
        if (!$this->hasPool($name)) {
            throw new RuntimeException(sprintf('Could not find cache pool with name %s.', $name));
        }

        return $this->pools->get($name);
    }
156855
public function get_component( $name )
    {
        if(!array_key_exists($name, $this->components))
        {
            throw new \RuntimeException("Composite sub-component not found with name $name");
        }
        return $this->components[$name];
    }
1289243
public static function create($name)
    {
        $logger = new Logger($name);

        $localLogConfig = config('logger.local_log');
        if($localLogConfig['enabled'] && !in_array($name, $localLogConfig['exclude_names'])) {
            $streamHandler = self::streamHandler($name);
            $logger->pushHandler($streamHandler);
        }

        $logstashConfig = config('logger.logstash');
        if($logstashConfig['enabled'] && !in_array($name, $logstashConfig['exclude_names'])){
            $gelfHandler = self::logStashHandler($logstashConfig);
            $logger->pushHandler($gelfHandler);
        }

        $requestId = Request::header('x-request-id');
        $logger->setRequestId($requestId);

        return $logger;
    }
583576
public function getModel($name) {
        if(!isset($this->models[$name])){
            throw new RuntimeException(sprintf("The model document name '%s' is not added in chain model '%s'",$name,$this->id));
        }
        $this->models[$name]->setContainer($this->container);
        return $this->models[$name];
    }
216683
protected function load($name)
    {
        $template = $this->nameParser->parse($name);

        if (!$template instanceof TemplateReferenceInterface) {
            throw new \RuntimeException(sprintf('The template "%s" could not be parsed.', $name));
        }

        $key = $template->getLogicalName();
        if (isset($this->cache[$key])) {
            return $this->cache[$key];
        }

        $storage = $this->loader->load($template);

        if (!$storage instanceof Storage) {
            throw new \RuntimeException(sprintf('The template "%s" could not be loaded.', $name));
        }

        return $this->cache[$key] = $storage;
    }
497939
public function & getMemberByName( $name )
	{
		if( isset( $this->members[$name] ) )
			return $this->members[$name];
		throw new RuntimeException( "Member '$name' is unknown" );
	}
1284832
protected function getFilterService($name)
    {
        if (!isset($this->filters[$name])) {
            throw new \RuntimeException('The filter "%s" does not exist.');
        }

        return $this->container->get($this->filters[$name]);
    }
810977
public function & getMethod( $name )
	{
		if( isset( $this->methods[$name] ) )
			return $this->methods[$name];
		throw new RuntimeException( "Method '$name' is unknown" );
	}
910686
protected function _getUsedTasks($name) {
		$plugin = $this->getConfig(static::CONFIG_PLUGIN);
		if (substr($name, -4) === 'Task') {
			$className = App::className(($plugin ? $plugin . '.' : '') . $name, 'Shell/Task');
		} else {
			$className = App::className(($plugin ? $plugin . '.' : '') . $name, 'Shell');
		}
		if (!$className) {
			throw new Exception($name);
		}

		$reflection = new ReflectionClass($className);
		if ($reflection->isAbstract()) {
			return [];
		}

		try {
			/** @var \Cake\Console\Shell $object */
			$object = new $className();
			$object->loadTasks();
		} catch (Exception $e) {
			if ($this->getConfig(static::CONFIG_VERBOSE)) {
				$this->_io->warn('   Skipping shell task annotations: ' . $e->getMessage());
			}
			return [];
		} catch (\Throwable $e) {
			if ($this->getConfig(static::CONFIG_VERBOSE)) {
				$this->_io->warn('   Skipping shell task annotations: ' . $e->getMessage());
			}
			return [];
		}

		$map = $this->_invokeProperty($object, '_taskMap');
		if (!$map) {
			return [];
		}
		foreach ($map as $alias => $row) {
			$fullClass = App::className($row['class'], 'Shell/Task', 'Task');
			if (!$fullClass) {
				$this->_io->warn('   Skipping invalid task ' . $alias . ': ' . $row['class']);
				unset($map[$alias]);
				continue;
			}
			$map[$alias]['fullClass'] = $fullClass;
		}

		return $map;
	}
491018
public static function instance($name = 'default')
    {
        if (!isset(static::$_instances[$name])) {
            static::$_instances[$name] = new EventDispatcher();
        }

        return static::$_instances[$name];
    }
708215
private function resolve($name)
	{
		if (!class_exists($name))
		{
			// Get the scope of the current class and check there too
			$name = $this->getModelNamespace() . '\\' . $name;

			if (!class_exists($name))
			{
				throw new RuntimeException("Relationship '{$name}' not found");
			}
		}

		return new $name;
	}