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

Returns a new instance of State.



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

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

Instance Method Details

#call(command) ⇒ Object



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

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

#closeObject



24
25
26
27
# File 'lib/redis_client/cluster/pub_sub.rb', line 24

def close
  @worker.exit if @worker&.alive?
  @client.close
end

#ensure_workerObject



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

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