Async::RedisSourceAsyncRedisProtocolSelected

class Selected

Executes AUTH after the user has established a connection.

Nested

Definitions

def initialize(index, protocol = Async::Redis::Protocol::RESP2)

Create a new authenticated protocol.

Signature

parameter index Integer

The database index to select.

parameter protocol Object

The delegated protocol for connecting.

Implementation

def initialize(index, protocol = Async::Redis::Protocol::RESP2)
	@index = index
	@protocol = protocol
end

def client(stream)

Create a new client and authenticate it.

Implementation

def client(stream)
	client = @protocol.client(stream)
	
	client.write_request(["SELECT", @index])
	response = client.read_response
	
	if response != "OK"
		raise SelectionError, "Could not select database: #{response}"
	end
	
	return client
end