Class: ActionCable::SubscriptionAdapter::EventedRedis
- Defined in:
- lib/action_cable/subscription_adapter/evented_redis.rb
Overview
:nodoc:
Constant Summary collapse
- @@mutex =
Mutex.new
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #broadcast(channel, payload) ⇒ Object
-
#initialize ⇒ EventedRedis
constructor
A new instance of EventedRedis.
- #shutdown ⇒ Object
- #subscribe(channel, message_callback, success_callback = nil) ⇒ Object
- #unsubscribe(channel, message_callback) ⇒ Object
Constructor Details
#initialize ⇒ EventedRedis
Returns a new instance of EventedRedis.
24 25 26 27 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 24 def initialize(*) super @redis_connection_for_broadcasts = @redis_connection_for_subscriptions = nil end |
Instance Method Details
#broadcast(channel, payload) ⇒ Object
29 30 31 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 29 def broadcast(channel, payload) redis_connection_for_broadcasts.publish(channel, payload) end |
#shutdown ⇒ Object
43 44 45 46 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 43 def shutdown redis_connection_for_subscriptions.pubsub.close_connection @redis_connection_for_subscriptions = nil end |
#subscribe(channel, message_callback, success_callback = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 33 def subscribe(channel, , success_callback = nil) redis_connection_for_subscriptions.pubsub.subscribe(channel, &).tap do |result| result.callback { |reply| success_callback.call } if success_callback end end |
#unsubscribe(channel, message_callback) ⇒ Object
39 40 41 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 39 def unsubscribe(channel, ) redis_connection_for_subscriptions.pubsub.unsubscribe_proc(channel, ) end |