Class: ActionCable::SubscriptionAdapter::EventedRedis

Inherits:
Base
  • Object
show all
Includes:
ChannelPrefix
Defined in:
actioncable/lib/action_cable/subscription_adapter/evented_redis.rb

Overview

:nodoc:

Constant Summary collapse

@@mutex =
Mutex.new

Instance Attribute Summary

Attributes inherited from Base

#logger, #server

Instance Method Summary collapse

Constructor Details

#initializeEventedRedis

Returns a new instance of EventedRedis.



28
29
30
31
32
33
34
35
36
37
# File 'actioncable/lib/action_cable/subscription_adapter/evented_redis.rb', line 28

def initialize(*)
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
    The "evented_redis" subscription adapter is deprecated and
    will be removed in Quails 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



39
40
41
# File 'actioncable/lib/action_cable/subscription_adapter/evented_redis.rb', line 39

def broadcast(channel, payload)
  redis_connection_for_broadcasts.publish(channel, payload)
end

#shutdownObject



53
54
55
56
# File 'actioncable/lib/action_cable/subscription_adapter/evented_redis.rb', line 53

def shutdown
  redis_connection_for_subscriptions.pubsub.close_connection
  @redis_connection_for_subscriptions = nil
end

#subscribe(channel, message_callback, success_callback = nil) ⇒ Object



43
44
45
46
47
# File 'actioncable/lib/action_cable/subscription_adapter/evented_redis.rb', line 43

def subscribe(channel, message_callback, success_callback = nil)
  redis_connection_for_subscriptions.pubsub.subscribe(channel, &message_callback).tap do |result|
    result.callback { |reply| success_callback.call } if success_callback
  end
end

#unsubscribe(channel, message_callback) ⇒ Object



49
50
51
# File 'actioncable/lib/action_cable/subscription_adapter/evented_redis.rb', line 49

def unsubscribe(channel, message_callback)
  redis_connection_for_subscriptions.pubsub.unsubscribe_proc(channel, message_callback)
end