Class: ActionCable::SubscriptionAdapter::EventedRedis
- Includes:
- ChannelPrefix
- 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.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 26 def initialize(*) ActiveSupport::Deprecation.warn(<<-MSG.squish) The "evented_redis" subscription adapter is deprecated and will be removed in Rails 5.2. Please use the "redis" adapter instead. MSG super @redis_connection_for_broadcasts = @redis_connection_for_subscriptions = nil end |
Instance Method Details
#broadcast(channel, payload) ⇒ Object
37 38 39 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 37 def broadcast(channel, payload) redis_connection_for_broadcasts.publish(channel, payload) end |
#shutdown ⇒ Object
51 52 53 54 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 51 def shutdown redis_connection_for_subscriptions.pubsub.close_connection @redis_connection_for_subscriptions = nil end |
#subscribe(channel, message_callback, success_callback = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 41 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
47 48 49 |
# File 'lib/action_cable/subscription_adapter/evented_redis.rb', line 47 def unsubscribe(channel, ) redis_connection_for_subscriptions.pubsub.unsubscribe_proc(channel, ) end |