Class: RedisClient::Cluster::PubSub::State

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_client/cluster/pub_sub.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, queue) ⇒ State



11
12
13
14
15
# File 'lib/redis_client/cluster/pub_sub.rb', line 11

def initialize(client, queue)
  @client = client
  @worker = nil
  @queue = queue
end

Instance Method Details

#call(command) ⇒ Object



17
18
19
# File 'lib/redis_client/cluster/pub_sub.rb', line 17

def call(command)
  @client.call_v(command)
end

#closeObject



25
26
27
28
29
30
# File 'lib/redis_client/cluster/pub_sub.rb', line 25

def close
  @worker.exit if @worker&.alive?
  @client.close
rescue ::RedisClient::ConnectionError
  # ignore
end

#ensure_workerObject



21
22
23
# File 'lib/redis_client/cluster/pub_sub.rb', line 21

def ensure_worker
  @worker = spawn_worker(@client, @queue) unless @worker&.alive?
end