Creates new redis client

@param  string     $name

@throws RuntimeException

@return Predis\ClientInterface
170600
public function create($name)
    {
        $config = $this->getConfiguration($name);

        if(null === $config) {
            throw new \RuntimeException(
                "Connection with name: $name not found."
            );
        }

        return new Client($config);
    }
1127240
protected function resolve($name)
    {
        $options = Arr::get($this->config, 'options', []);

        if (isset($this->config[$name])) {
            return $this->connector()->connect($this->config[$name], $options);
        }

        if (isset($this->config['clusters'][$name])) {
            return $this->resolveCluster($name);
        }

        throw new \InvalidArgumentException(
            "Redis connection [{$name}] not configured."
        );
    }
1323011
private function createMethod(string $name): MethodInterface
    {
        $methodClass = $clientClass = null;

        foreach (['Postage', 'Tracking', 'Withdrawal'] as $ns) {
            $class = 'Ekyna\\Component\\Colissimo\\' . $ns . '\\Method\\' . ucwords($name) . 'Method';
            if (class_exists($class)) {
                $methodClass = $class;
                $clientClass = 'Ekyna\\Component\\Colissimo\\' . $ns . '\\Client';
                break;
            }
        }

        if (is_null($methodClass)) {
            throw new RuntimeException("Method {$name} does not exist");
        }

        return new $methodClass($this->factory->getClient($clientClass));
    }
288369
public function get($name)
    {
        $instance = self::getInstance();
        if (!$instance->offsetExists($name)) {
            throw new \RuntimeException(sprintf('Class %s Not Found', $name));
        }

        return $instance->offsetGet($name);
    }
687328
public static function getInstance($name = 'default')
    {
        if (isset(self::$instance[$name])) {
            return self::$instance[$name];
        }

        $config = Registry::get('config');
        $config = $config['redis'];
        if (!isset($config[$name], $config[$name]['host'])) {
            throw new ConfigException('No redis config!');
        }

        $config = $config[$name];
        $connectType = isset($config['pconnect']) && $config['pconnect'] ? 'pconnect' : 'connect';

        $redis = new self;
        if (!$redis->$connectType(
            $config['host'],
            isset($config['port']) ? $config['port'] : 6379,
            isset($config['timeout']) ? $config['timeout'] : 1
        )) {
            throw new RedisException('Redis server went away!');
        }

        if (isset($config['prefix'])) {
            $redis->setOption(Redis::OPT_PREFIX, $config['prefix']);
        }

        return self::$instance[$name] = $redis;
    }
891223
public function createClient($target)
    {
        try {
            $parts = $this->parseUrl($target);
        } catch (InvalidArgumentException $e) {
            return \React\Promise\reject($e);
        }

        $connecting = $this->connector->connect($parts['authority']);
        $deferred = new Deferred(function ($_, $reject) use ($connecting) {
            // connection cancelled, start with rejecting attempt, then clean up
            $reject(new \RuntimeException('Connection to Redis server cancelled'));

            // either close successful connection or cancel pending connection attempt
            $connecting->then(function (ConnectionInterface $connection) {
                $connection->close();
            });
            $connecting->cancel();
        });

        $protocol = $this->protocol;
        $promise = $connecting->then(function (ConnectionInterface $stream) use ($protocol) {
            return new StreamingClient($stream, $protocol->createResponseParser(), $protocol->createSerializer());
        }, function (\Exception $e) {
            throw new \RuntimeException(
                'Connection to Redis server failed because underlying transport connection failed',
                0,
                $e
            );
        });

        if (isset($parts['auth'])) {
            $promise = $promise->then(function (StreamingClient $client) use ($parts) {
                return $client->auth($parts['auth'])->then(
                    function () use ($client) {
                        return $client;
                    },
                    function ($error) use ($client) {
                        $client->close();

                        throw new \RuntimeException(
                            'Connection to Redis server failed because AUTH command failed',
                            0,
                            $error
                        );
                    }
                );
            });
        }

        if (isset($parts['db'])) {
            $promise = $promise->then(function (StreamingClient $client) use ($parts) {
                return $client->select($parts['db'])->then(
                    function () use ($client) {
                        return $client;
                    },
                    function ($error) use ($client) {
                        $client->close();

                        throw new \RuntimeException(
                            'Connection to Redis server failed because SELECT command failed',
                            0,
                            $error
                        );
                    }
                );
            });
        }

        $promise->then(array($deferred, 'resolve'), array($deferred, 'reject'));

        // use timeout from explicit ?timeout=x parameter or default to PHP's default_socket_timeout (60)
        $timeout = (float) isset($parts['timeout']) ? $parts['timeout'] : ini_get("default_socket_timeout");
        if ($timeout < 0) {
            return $deferred->promise();
        }

        return \React\Promise\Timer\timeout($deferred->promise(), $timeout, $this->loop)->then(null, function ($e) {
            if ($e instanceof TimeoutException) {
                throw new \RuntimeException(
                    'Connection to Redis server timed out after ' . $e->getTimeout() . ' seconds'
                );
            }
            throw $e;
        });
    }
316989
public function get($name)
    {
        if ($this->exists($name)) {
            return $this->container[$name];
        } else {
            throw new RuntimeException(sprintf('Attempted to retrieve non-existing dependency "%s"', $name));
        }
    }
513609
public function getClient(string $name = 'default')
    {
        if (!isset($this->clients[$name])) {
            throw new InvalidArgumentException("No client with name \"$name\"");
        }

        return $this->clients[$name];
    }
1268752
public function createSlaveClients($name)
    {
        $slaves = $this->slaves($name);
        $workingSlaves = array();
        foreach ($slaves as $slave) {
            if (!isset($slave[9])) {
                throw new Exception('Can\' retrieve slave status');
            }
            if (!strstr($slave[9], 's_down') && !strstr($slave[9], 'disconnected')) {
                $workingSlaves[] = new Client($slave[3], $slave[5], null, '', 0, $this->_authPassword);
            }
        }
        return $workingSlaves;
    }
1095456
protected function createCacheDriver($name)
    {
        $config = Arr::get($this->config, "cache.{$name}", []);
        $cache  = $this->getCacheRepository($config);

        return $this->createProvider(new Cache($name, $config, $cache));
    }
560033
public function _($name = null)
    {
        if (isset($name)) {
            $this->path[] = $name;
        }
        $client = new static($this->host, $this->headers);
        $client->setPath($this->path);
        $client->setCurlOptions($this->curlOptions);
        $client->setRetryOnLimit($this->retryOnLimit);
        $this->path = [];

        return $client;
    }
515577
public function create($className)
        {
            $facade = $this->helper->getFacadeClassName($className);

            if (!class_exists($facade)) {
                throw new RuntimeException("Class '$facade' not found");
            }
            $className = $this->helper->getSDKClassName($className);
            return new $facade(new $className($this->httpClient));
        }
1276613
public function createMasterClient($name)
    {
        $master = $this->getMasterAddressByName($name);
        if (!isset($master[0], $master[1])) {
            throw new RedisException('Master not found');
        }

        return Factory::client([
            'host' => $master[0],
            'port' => $master[1],
            'timeout' => $this->timeout,
            'persistent' => $this->persistent,
            'database' => $this->database,
            'password' => $this->getPassword(),
        ]);
    }
90453
public function add($name)
    {
        $this->repository->setCurrentUser($this->repository->getUserService()->loadUser($this->adminID));
        $contentTypeService = $this->repository->getContentTypeService();

        $contentTypeGroupStruct = $contentTypeService->newContentTypeGroupCreateStruct($name);

        try {
            $contentTypeGroup = $contentTypeService->createContentTypeGroup($contentTypeGroupStruct);
            return $contentTypeGroup;
        } catch (UnauthorizedException $e) {
            throw new \RuntimeException($e->getMessage());
        } catch (InvalidArgumentException $e) {
            throw new \RuntimeException($e->getMessage());
        }
    }
547222
public function getPage($name)
    {
        if (null === $this->pageObjectFactory) {
            throw new \RuntimeException('To create pages you need to pass a factory with setPageObjectFactory()');
        }

        return $this->pageObjectFactory->createPage($name);
    }
1358691
public function getService($name = null)
    {
        $name = $name ?: $this->defaultService;

        if (!$name) {
            throw new \RuntimeException(sprintf(
                'You must configure a default %s service, registered %s services: "%s"',
                $this->serviceType, $this->serviceType,
                implode('", "', array_keys($this->services))
            ));
        }

        if (isset($this->services[$name])) {
            return $this->services[$name];
        }

        $this->assertServiceExists($name);
        $this->services[$name] = $this->container->get($this->serviceMap[$name]);

        return $this->services[$name];
    }
109782
private function makeService($name, array $args = [])
    {
        if (!isset($this->services[$name]) || $args) {
            $apiClient = $this->sdk->createClient($name, $args);
            $model = $this->loadModel($name, $apiClient->getApi()->getApiVersion());
            $resourceClient = new ResourceClient($apiClient, $model);
            $this->services[$name] = new Resource($resourceClient, 'service', [], []);
        }

        return $this->services[$name];
    }