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 = make_pool(**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 make_pool(**options)

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

Implementation

def make_pool(**options)
	self.assign_default_tags(options[:tags] ||= {})
	
	Async::Pool::Controller.wrap(**options) do
		endpoint = resolve_address
		peer = endpoint.connect
		stream = ::IO::Stream(peer)
		
		@protocol.client(stream)
	end
end