magicbus 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/magicbus/publisher.rb +5 -7
- data/lib/magicbus/version.rb +1 -1
- metadata +1 -1
data/lib/magicbus/publisher.rb
CHANGED
@@ -2,6 +2,7 @@ class MagicBus::Publisher
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
attr_accessor :conection
|
5
|
+
attr_accessor :channels
|
5
6
|
end
|
6
7
|
|
7
8
|
def self.scatter(group, action, model, &block)
|
@@ -34,13 +35,10 @@ class MagicBus::Publisher
|
|
34
35
|
def self.publish(user_id, data)
|
35
36
|
|
36
37
|
user_id = user_id.to_s
|
37
|
-
|
38
|
-
channel =
|
39
|
-
|
40
|
-
|
41
|
-
exchange = channel.fanout('syme')
|
42
|
-
exchange.publish(data.to_json)
|
43
|
-
end
|
38
|
+
channels[user_id] ||= AMQP::Channel.new(connection)
|
39
|
+
channel = channels[user_id]
|
40
|
+
exchange = channel.fanout('syme')
|
41
|
+
exchange.publish(data.to_json)
|
44
42
|
|
45
43
|
end
|
46
44
|
|
data/lib/magicbus/version.rb
CHANGED