Establish a queue connection.

@param  array  $config
@return \Laravel\Horizon\RedisQueue
511496
public function connect(array $config)
    {
        return new RedisQueue(
            $this->redis, $config['queue'],
            Arr::get($config, 'connection', $this->connection),
            Arr::get($config, 'retry_after', 60),
            Arr::get($config, 'block_for', null)
        );
    }
660668
public function connect( array $config )
	{
		$options = $this->getOptions( $config );

		$dsn = array_get( $config, 'dsn' );

		return $this->createConnection( $dsn, $config, $options );
	}
958420
public function make(array $config)
    {
        Arr::requires($config, ['token']);

        $client = new Client();

        return new PagerdutyGateway($client, $config);
    }
1016283
public function openConnection($config)
    {
        $this->queue = new \IronMQ([
            "token"      => $config['token'],
            "project_id" => $config['project'],
            "host"       => $config['host']
        ]);
        if (!$this->queue) {
            \PHPUnit\Framework\Assert::fail('connection failed or timed-out.');
        }
    }
838585
public static function cluster(array $config = []): RedisInterface
    {
        $driver = $config['driver'] ?? '';

        if ($driver === 'native' || !PHP_REDIS_EXTENSION) {
            return new Cluster\Native($config);
        }

        return new Cluster\PhpRedis($config);
    }
380675
public function createConnector(array $config)
    {
        if (!isset($config['driver'])) {
            throw new Exception('A driver must be specified.');
        }

        switch ($config['driver']) {
            case 'mysql':
                return new MySqlConnector;
            case 'pgsql':
                return new PostgresConnector;
            case 'sqlite':
                return new SQLiteConnector;
            case 'sqlsrv':
                return new SqlServerConnector;
            case 'filesystem':
                return new FileSystemConnector;
        }
        throw new Exception("Unsupported driver [{$config['driver']}]");
    }
438867
public function connect(Array $config)
    {
        $dsn = $this->getDSN($config);
        $options = $this->getOptions($config);

        $connection = $this->createConnection($dsn, $config, $options);

        if (isset($config['charset'])) {
            $connection->prepare("set names '" . $config['charset'] . "'")->execute();
        }

        if (isset($config['timezone'])) {
            $connection->prepare("set time zone '" . $config['timezone'] . "'")->execute();
        }

        return $connection;
    }
701141
public function createConnection(array $config)
    {
        if (! isset($config['host'])) {
            throw new InvalidArgumentException("No host provided.");
        }

        $this->setHost($config['host']);

        // We check the configuration for request headers. Some API's require
        // certain headers for all requests. Providing them in the configuration
        // makes it easier to provide these headers on each request.
        if (isset($config['headers'])) {
            $this->setHeaders($config['headers']);
        }

        return $this;
    }
899352
public static function createRedisByConfig(array $config) {
        $Redis = new Connection();
        $Redis->setHost(@$config['host'])
            ->setPort(@$config['port']);
        (isset($config['persistent']))      && $Redis->setPersistent($config['persistent']);
        (isset($config['connect_timeout'])) && $Redis->setConnectTimeout($config['connect_timeout']);
        (isset($config['connect_tries']))   && $Redis->setConnectTries($config['connect_tries']);
        return $Redis;
    }
359844
public function configure($config = [])
    {
        $redisConfig = config('database.redis.' . $config['connection']);

        $this->config = [
            'host'     => $redisConfig['host'],
            'port'     => $redisConfig['port'],
            'database' => $redisConfig['database']
        ];

        return $this;
    }
557379
protected function createClient(array $config)
    {
        return tap(new Redis, function ($client) use ($config) {
            $this->establishConnection($client, $config);

            if (! empty($config['password'])) {
                $client->auth($config['password']);
            }

            if (! empty($config['database'])) {
                $client->select($config['database']);
            }

            if (! empty($config['prefix'])) {
                $client->setOption(Redis::OPT_PREFIX, $config['prefix']);
            }

            if (! empty($config['read_timeout'])) {
                $client->setOption(Redis::OPT_READ_TIMEOUT, $config['read_timeout']);
            }
        });
    }
1195463
protected function createServerSocket(array $config)
    {
        $protocol = $config['protocol'] ?? 'tcp';

        if (isset($this->serverSocketExtensions[$protocol])) {
            $serverSocket = call_user_func($this->serverSocketExtensions[$protocol], $this->app, $config);

            if (! $serverSocket instanceof ServerSocketContract) {
                throw new InvalidArgumentException(
                    "The protocol [{$protocol}] resolver must return a ServerSocket instance."
                );
            }

            return $serverSocket;
        }

        if (method_exists($this, $method = 'create'.Str::studly($protocol).'ServerSocket')) {
            return $this->$method($config);
        }

        throw new InvalidArgumentException("The protocol [{$protocol}] is not supported.");
    }
295260
public function createConnection(QueueConnectionTransfer $queueConnectionConfig)
    {
        return new Connection(
            $this->createAmqpStreamConnection($queueConnectionConfig),
            $this->createQueueEstablishmentHelper(),
            $queueConnectionConfig
        );
    }
854288
protected function createMemcachedDriver( array $config )
	{
		$prefix = $this->getPrefix( $config );

		$memcached = MemcachedConnector::i()->connect( $config['servers'] );

		return new MemcachedStore( $memcached, $prefix );
	}
240633
public function connect(array $config)
    {
        $dsn = $this->getDsn($config);

        $options = $this->getOptions($config);

        $connection = $this->createConnection($dsn, $config, $options);

        //
        $collation = $config['collation'];

        $charset = $config['charset'];

        $names = "set names '$charset'".
            (! is_null($collation) ? " collate '$collation'" : '');

        $connection->prepare($names)->execute();

        if (isset($config['strict']) && $config['strict']) {
            $connection->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute();
        }

        return $connection;
    }
143080
public function connect(array $config)
	{
		return new DatabaseQueue(
			$this->connections->connection(Arr::get($config, 'connection')),
			$config['table'],
			$config['queue'],
			Arr::get($config, 'expire', 60)
		);
	}
448342
protected function _connection(array $config)
    {
        $redis = new \Redis;
        $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host'];
        $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port'];
        $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout'];
        $connect = empty($config['persistent']) ? 'connect' : 'pconnect';
        $redis->$connect($host, $port, $timeout);
        return $redis;
    }