Class: RedisClient::Cluster::PubSub::State
- Inherits:
-
Object
- Object
- RedisClient::Cluster::PubSub::State
- Defined in:
- lib/redis_client/cluster/pub_sub.rb
Instance Method Summary collapse
- #call(command) ⇒ Object
- #close ⇒ Object
- #ensure_worker ⇒ Object
-
#initialize(client, queue) ⇒ State
constructor
A new instance of State.
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 |
#close ⇒ Object
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_worker ⇒ Object
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 |