protected function createNewConnection(): \Plasma\DriverInterface {
        $connection = $this->factory->createDriver();
        
        // We relay a driver's specific events forward, e.g. PostgreSQL notifications
        $connection->on('eventRelay', function (string $eventName, ...$args) use (&$connection) {
            $args[] = $connection;
            $this->emit($eventName, $args);
        });
        
        $connection->on('close', function () use (&$connection) {
            $this->connections->delete($connection);
            $this->busyConnections->delete($connection);
            
            $this->emit('close', array($connection));
        });
        
        $connection->on('error', function (\Throwable $error) use (&$connection) {
            $this->emit('error', array($error, $connection));
        });
        
        $connection->connect($this->uri)->then(function () use (&$connection) {
            $this->connections->add($connection);
            $this->busyConnections->delete($connection);
        }, function (\Throwable $error) use (&$connection) {
            $this->connections->delete($connection);
            $this->busyConnections->delete($connection);
            
            $this->emit('error', array($error, $connection));
        });
        
        return $connection;
    }
protected function createNewConnection(): \Plasma\DriverInterface {
        $connection = $this->factory->createDriver();
        
        // We relay a driver's specific events forward, e.g. PostgreSQL notifications
        $connection->on('eventRelay', function (string $eventName, ...$args) use (&$connection) {
            $args[] = $connection;
            $this->emit($eventName, $args);
        });
        
        $connection->on('close', function () use (&$connection) {
            $this->connections->delete($connection);
            $this->busyConnections->delete($connection);
            
            $this->emit('close', array($connection));
        });
        
        $connection->on('error', function (\Throwable $error) use (&$connection) {
            $this->emit('error', array($error, $connection));
        });
        
        $connection->connect($this->uri)->then(function () use (&$connection) {
            $this->connections->add($connection);
            $this->busyConnections->delete($connection);
        }, function (\Throwable $error) use (&$connection) {
            $this->connections->delete($connection);
            $this->busyConnections->delete($connection);
            
            $this->emit('error', array($error, $connection));
        });
        
        return $connection;
    }
protected function createNewConnection ( ) : \ Plasma \ DriverInterface { $ connection = $ this -> factory -> createDriver ( ) ; // We relay a driver's specific events forward, e.g. PostgreSQL notifications $ connection -> on ( 'eventRelay' , function ( string $ eventName , ... $ args ) use ( & $ connection ) { $ args [ ] = $ connection ; $ this -> emit ( $ eventName , $ args ) ; } ) ; $ connection -> on ( 'close' , function ( ) use ( & $ connection ) { $ this -> connections -> delete ( $ connection ) ; $ this -> busyConnections -> delete ( $ connection ) ; $ this -> emit ( 'close' , array ( $ connection ) ) ; } ) ; $ connection -> on ( 'error' , function ( \ Throwable $ error ) use ( & $ connection ) { $ this -> emit ( 'error' , array ( $ error , $ connection ) ) ; } ) ; $ connection -> connect ( $ this -> uri ) -> then ( function ( ) use ( & $ connection ) { $ this -> connections -> add ( $ connection ) ; $ this -> busyConnections -> delete ( $ connection ) ; } , function ( \ Throwable $ error ) use ( & $ connection ) { $ this -> connections -> delete ( $ connection ) ; $ this -> busyConnections -> delete ( $ connection ) ; $ this -> emit ( 'error' , array ( $ error , $ connection ) ) ; } ) ; return $ connection ; }
Create a new connection.
@return \Plasma\DriverInterface
Create a new connection .