Async::RedisSourceAsyncRedisProtocolAuthenticated

class Authenticated

Executes AUTH after the user has established a connection.

Nested

Definitions

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

Create a new authenticated protocol.

Signature

parameter credentials Array

The credentials to use for authentication.

parameter protocol Object

The delegated protocol for connecting.

Implementation

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

def client(stream)

Create a new client and authenticate it.

Implementation

def client(stream)
	client = @protocol.client(stream)
	
	client.write_request(["AUTH", *@credentials])
	response = client.read_response
	
	if response != "OK"
		raise AuthenticationError, "Could not authenticate: #{response}"
	end
	
	return client
end