Async::RedisSourceAsyncRedisSentinelClient

class SentinelClient

Definitions

def initialize(endpoints, master_name: DEFAULT_MASTER_NAME, role: :master, protocol: Protocol::RESP2, **options)

Create a new instance of the SentinelClient.

Implementation

def initialize(endpoints, master_name: DEFAULT_MASTER_NAME, role: :master, protocol: Protocol::RESP2, **options)
	@endpoints = endpoints
	@master_name = master_name
	@role = role
	@protocol = protocol
	
	# A cache of sentinel connections.
	@sentinels = {}
	
	@pool = connect(**options)
end

attr :master_name

Signature

attribute String

The name of the master instance.

attr :role

Signature

attribute Symbol

The role of the instance that you want to connect to.

def connect(**options)

Override the parent method. The only difference is that this one needs to resolve the master/slave address.

Implementation

def connect(**options)
	Async::Pool::Controller.wrap(**options) do
		endpoint = resolve_address
		peer = endpoint.connect
		stream = ::IO::Stream(peer)
		
		@protocol.client(stream)
	end
end