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.



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

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

Instance Method Details

#call(command) ⇒ Object



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

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

#closeObject



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

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

#ensure_workerObject



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

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