rabid_mq 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rabid_mq.rb +1 -1
- data/lib/rabid_mq/publisher.rb +36 -2
- data/lib/rabid_mq/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1377b3526d20e974b3d6096c72247eb415feded
|
4
|
+
data.tar.gz: 78b3e87500b5794f660655a98a7305e3106b6909
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f150cef5b1fd066d7b75e982d94c1726ddcbe394e733f04eb6351cfdc94f545c22797fd85aaf3afd476bb2285cde5daeecec7fa2fc8bf4b063253723e31356b5
|
7
|
+
data.tar.gz: 35d91088d9e62803c955a0325d3486fa5a6bf57e3bbeb704412a749d0afe06e696a4d8bf0b6219ae268cce02466d8c9c54db31d465187212c59f4ac6ef0b3e5e
|
data/lib/rabid_mq.rb
CHANGED
data/lib/rabid_mq/publisher.rb
CHANGED
@@ -30,12 +30,46 @@ module RabidMQ
|
|
30
30
|
|
31
31
|
alias_method :broadcast, :amqp_broadcast
|
32
32
|
|
33
|
-
delegate :topic_exchange, to: RabidMQ
|
34
|
-
|
35
33
|
def default_amqp_routing_key
|
36
34
|
self.name.underscore.gsub(/\//, '.')
|
37
35
|
end
|
38
36
|
|
37
|
+
# Provide a topic exchange on demand connected to the existing channel
|
38
|
+
def topic_exchange(topic, **options)
|
39
|
+
channel.topic(name_with_env(topic), **options)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Provide fanout exchange
|
43
|
+
def fanout_exchange(topic, **options)
|
44
|
+
channel.fanout(name_with_env(topic), **options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get a channel with the Bunny::Session
|
48
|
+
def channel
|
49
|
+
@channel ||= connect.create_channel
|
50
|
+
rescue Bunny::ChannelAlreadyClosed => e
|
51
|
+
@channel = nil
|
52
|
+
channel
|
53
|
+
end
|
54
|
+
|
55
|
+
# Start a new connection
|
56
|
+
def connect
|
57
|
+
connection.tap do |c|
|
58
|
+
c.start
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def name_with_env(name)
|
63
|
+
return name unless defined?(::Rails)
|
64
|
+
return name if name.match /\[(development|test|production|integration|pod)\]/
|
65
|
+
name + "[#{Rails.env}]"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Provide a new or existing Bunny::Session
|
69
|
+
def connection
|
70
|
+
@connection ||= Bunny.new RabidMQ::Config.load_config
|
71
|
+
end
|
72
|
+
|
39
73
|
end
|
40
74
|
end
|
41
75
|
end
|
data/lib/rabid_mq/version.rb
CHANGED