Connect to the bus Redis instance

@param {Object} busModule
167041
function connect(busModule) {
  if (busModule) {
    module.exports.client = busModule.connect();
    BUS_MODULE = true;
  } else {
    log('info', `Connecting to default Redis event bus at ${process.env.CLAY_BUS_HOST}`);
    module.exports.client = new Redis(process.env.CLAY_BUS_HOST);
  }
}
544216
function uServicesManager(){

 client.publish('uServicesChannel', 'UPDATE');

 listenClient.on('message', function(channel, message) {

  client.get('uServices', function(err, reply) {
   if (reply !== null) {
    uServices = JSON.parse(reply);
   }
  });
 });

 listenClient.on("error", function (err) {
  console.log("Redis listen "+ err);
  listenClient.quit();
 });

 listenClient.subscribe('uServicesChannel');
}
679195
protected function registerRedisConnector($manager)
    {
        $app = $this->app;

        $manager->addConnector('redis', function () use ($app) {
            $redis = $app['redis'];

            return new Connectors\RedisConnector($redis);
        });
    }
1099265
function connectToRedis(db, opts) {

    // get the redis client
    var client = redis.createClient(opts.port, opts.host);

    // log any errors
    client.on('error', function (err) {
        redisOffline = true;
        console.log('connectToRedis error: ' + err);
    });

    client.on('ready', function () {
        redisOffline = false;
    });

    // if there is a password, do auth
    var deferred = Q.defer();
    if (opts.password) {
        client.auth(opts.password, function (authErr) {
            if (authErr) {
                deferred.reject(authErr);
                return;
            }

            client.select(db, function (err) {
                err ? deferred.reject(err) : deferred.resolve(client);
            });
        });
    }
    else {
        client.select(db, function (err) {
            err ? deferred.reject(err) : deferred.resolve(client);
        });
    }

    return deferred.promise;
}
772600
function _createClient (name, options, callback) {
  const log = logger.child({ redis: name })
  log.debug('Redis creating client: ' + name)
  let isReady = false

  const config = {}
  deepAssign(config, _defaults, options)
  let client = redis.createClient(config)

  callback = _once(callback)
  _clients[ name ] = client
  _clients[ name ].log = log

  log.debug({ clients: Object.keys(_clients) }, 'Redis clients')

  client.on('error', function (err) {
    log.error({ err: err }, 'Redis client error')
    callback(err)
  })

  client.on('warning', function (err) {
    log.warn({ err: err }, 'Redis client warning')
  })

  client.on('connect', function () {
    log.debug('Redis connected: ' + name)
  })

  client.on('ready', function () {
    log.debug('Redis client ready: ' + name)
    log.debug({ config: config }, 'Redis client config')
    log.debug(`Redis server version: ${safeGet(() => client.server_info.redis_version)}`)
    isReady = true
    callback(null, client)
  })

  client.on('reconnecting', function () {
    log.debug('Redis client reconnecting: ' + name)
  })

  client.on('end', function () {
    log.debug('Redis client end: ' + name)
    // Close the connection before removing reference.
    client.quit()
    client = null
    delete _clients[ name ]
    log.debug({ clients: Object.keys(_clients) }, 'Redis clients: ' + _clients.length)
    if (!isReady) {
      callback(new Error('Done - Failed to connect to Redis'))
    }
  })
}
333318
def __connect_to_bus(self, bus):
        
        def connect(bus_num):
            try:
                self.log.debug("Attempting to connect to bus %s..." % bus_num)
                self.bus = smbus.SMBus(bus_num)
                self.log.debug("Success")
            except IOError:
                self.log.debug("Failed")
                raise

        # If the bus is not explicitly stated, try 0 and then try 1 if that
        # fails
        if bus is None:
            try:
                connect(0)
                return
            except IOError:
                pass

            try:
                connect(1)
                return
            except IOError:
                raise
        else:
            try:
                connect(bus)
                return
            except IOError:
                raise
894838
private synchronized void connect() throws IOReactorException
    {
        if (m_connManager == null) {
            ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor();
            m_connManager = new PoolingNHttpClientConnectionManager(ioReactor);
            m_connManager.setMaxTotal(HTTP_EXPORT_MAX_CONNS);
            m_connManager.setDefaultMaxPerRoute(HTTP_EXPORT_MAX_CONNS);
        }

        if (m_client == null || !m_client.isRunning()) {
            HttpAsyncClientBuilder client = HttpAsyncClients.custom().setConnectionManager(m_connManager).
                    setRedirectStrategy(new HDFSUtils.HadoopRedirectStrategy());
            if (m_isKrb) {
                m_client = (CloseableHttpAsyncClient)Subject.doAs(m_context.getSubject(), new PrivilegedBuild(client));
            } else {
                m_client = client.build();
            }
            m_client.start();
        }
    }
1131008
def redis_client(address=None, connection_pool=None, timeout=None,
                 parser=None, **kwargs):
    '''
    '''
    if not connection_pool:
        if timeout == 0:
            if not async:
                raise ImportError('Asynchronous connection requires async '
                                  'bindings installed.')
            return async.pool.redis(address, **kwargs)
        else:
            kwargs['socket_timeout'] = timeout
            return Redis(address[0], address[1], **kwargs)
    else:
        return Redis(connection_pool=connection_pool)
914587
async def connect(self):
        

        if isinstance(self.connection, dict):
            # a dict like {'host': 'localhost', 'port': 6379,
            #              'db': 0, 'password': 'pass'}
            kwargs = self.connection.copy()
            address = (
                kwargs.pop('host', 'localhost'),
                kwargs.pop('port', 6379)
            )
            redis_kwargs = kwargs
        elif isinstance(self.connection, aioredis.Redis):
            self._pool = self.connection
        else:
            # a tuple or list ('localhost', 6379)
            # a string "redis://host:6379/0?encoding=utf-8" or
            # a unix domain socket path "/path/to/redis.sock"
            address = self.connection
            redis_kwargs = {}

        if self._pool is None:
            async with self._lock:
                if self._pool is None:
                    self.log.debug('Connecting %s', repr(self))
                    self._pool = await self._create_redis_pool(
                        address, **redis_kwargs,
                        minsize=1, maxsize=100)

        return await self._pool
72491
private function persistentConnect(\stdClass $connectionOptions, $persistentId)
    {
        if (!$this->connection->pconnect(
            $connectionOptions->host,
            $connectionOptions->port,
            $connectionOptions->timeout,
            $persistentId,
            $connectionOptions->retryDelay
        )) {
            throw new RedisConnectionException(
                "Can't connect to redis server with config: " . var_export($connectionOptions, true)
            );
        };
    }
58809
function() {
      return Promise.retry(function() {
        log.debug(format('Connecting to redis on %s:%s', REDIS_IP, REDIS_PORT));
        return redis.createClient(REDIS_PORT, REDIS_IP);
      });
    }
423129
function(parentModule, id, callback) {

  // Try to load the module.
  return Promise.try(function() {
    return parentModule.require(id);
  })
  // Ignore module not found errors, and decorate all others.
  .catch(function(err) {
    if (err.code !== 'MODULE_NOT_FOUND') {
      throw new KboxRequireError(id, err);
    }
  })
  // Return.
  .nodeify(callback);

}
1069789
public void connect() throws Exception {
        if (connection != null && !connection.isOpen()) {
            connection.open();
            transaction = connection.getModbusTransport().createTransaction();
            ((ModbusSerialTransaction) transaction).setTransDelayMS(transDelay);
            setTransaction(transaction);
        }
    }
1210538
private function connect()
	{
		// We want to only create the driver once.
		if (isset($this->driver))
		{
			return;
		}

		$host = isset($this->options['redis.host'])? $this->options['redis.host'] : self::REDIS_HOST;
		$port = isset($this->options['redis.port'])? $this->options['redis.port'] : self::REDIS_PORT;

		$this->driver = new RedisDriver;

		if (($host == 'localhost' || filter_var($host, FILTER_VALIDATE_IP)))
		{
			$this->driver->connect('tcp://' . $host . ':' . $port, $port);
		}
		else
		{
			$this->driver->connect($host, null);
		}
	}
287985
function connect(dbUri, debugFlag, mongos) {
    var deferred = Q.defer();
    var opts = {
        server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
        replset: { socketOptions: { keepAlive: 1, connectTimeoutMS : 30000 } }
    };

    if (mongos) {
        opts.mongos = true;
    }

    mongoose.set('debug', debugFlag);

    // make sure we disconnect any other existing connections
    mongoose.disconnect(function () {
        mongoose.connect(dbUri, opts, function (err)  {
            err ? deferred.reject(err) : deferred.resolve();
        });
    });

    return deferred.promise;
}
991123
function DistribusConnection(transport, id, receive) {
  this.transport = transport;
  this.id = id;

  // create a peer
  var peer = this.transport.host.create(id);
  peer.on('message', receive);

  // ready state
  this.ready = Promise.resolve(this);
}
63006
def get_connection(self, internal=False):
        
        # Determine the connection string to use.
        connect_string = self.connect_string
        if internal:
            connect_string = self.internal_connect_string

        # Stripe Redis protocol prefix coming from the API.
        connect_string = connect_string.strip('redis://')
        host, port = connect_string.split(':')

        # Build and return the redis client.
        return redis.StrictRedis(host=host, port=port, password=self._password)