Class: Resque::Plugins::Pubsub::Exchange
- Inherits:
-
Object
- Object
- Resque::Plugins::Pubsub::Exchange
- Defined in:
- lib/resque/plugins/pubsub/exchange.rb
Class Method Summary collapse
- .perform(subscription_info) ⇒ Object
- .pubsub_namespace ⇒ Object
- .pubsub_namespace=(namespace) ⇒ Object
- .redis ⇒ Object
Class Method Details
.perform(subscription_info) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/resque/plugins/pubsub/exchange.rb', line 18 def perform(subscription_info) puts '[Exchange] handling a subscription on the exchange' puts "[Exchange] requested subscription is #{subscription_info.inspect}" puts "[Exchange] namespace is #{Exchange.redis.namespace}" Exchange.redis.sadd("#{subscription_info["topic"]}_subscribers", { :class => subscription_info['class'], :namespace => subscription_info['namespace'] }.to_json) end |
.pubsub_namespace ⇒ Object
25 26 27 |
# File 'lib/resque/plugins/pubsub/exchange.rb', line 25 def pubsub_namespace @pubsub_namespace end |
.pubsub_namespace=(namespace) ⇒ Object
29 30 31 32 33 |
# File 'lib/resque/plugins/pubsub/exchange.rb', line 29 def pubsub_namespace=(namespace) @pubsub_namespace = namespace @redis.client.disconnect if @redis @redis = nil end |
.redis ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/resque/plugins/pubsub/exchange.rb', line 10 def redis return @redis if @redis client_to_copy = Resque.redis.client redis_new = Redis.new(:host => client_to_copy.host, :port => client_to_copy.port, :thread_safe => true, :db => client_to_copy.db) puts "[Exchange] making a redis in exchange, namespace will be #{@pubsub_namespace}" @redis = Redis::Namespace.new(@pubsub_namespace || 'resque:pubsub', :redis => redis_new) end |