rabid_mq 0.1.30 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rabid_mq/listener.rb +7 -2
- data/lib/rabid_mq/publisher.rb +20 -22
- data/lib/rabid_mq/version.rb +1 -1
- data/lib/rabid_mq.rb +11 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ff0b2b418b4aa5885ab95513cf23ed0833deb4a
|
4
|
+
data.tar.gz: 3f63f7a19c9fd404e518ba409de814c35bd107a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da7634d1e55d9206e3e51e1e73983bb81c4ffd4e0a3a745b2e8042f40257e333bbc5a7b1809a0e34d07dc893f7538d6c57a40aa3d1280fb419c78ad6973bea2
|
7
|
+
data.tar.gz: 0c365f972184202f6f0488033009ce1fa6ba16e0f1866343373eadc03b61f46f161f944c0c89d02e8944701b5082c332560216bb03b6b7e3786469d55b6cffda
|
data/lib/rabid_mq/listener.rb
CHANGED
@@ -21,9 +21,14 @@ module RabidMQ
|
|
21
21
|
attr_reader :amqp_queue, :amqp_exchange, :routing_key
|
22
22
|
|
23
23
|
def amqp(queue, exchange, exclusive: false, routing_key: '#')
|
24
|
-
|
24
|
+
# Set up an exchange
|
25
25
|
self.exchange(exchange)
|
26
26
|
@routing_key = routing_key
|
27
|
+
|
28
|
+
# Set up Queue
|
29
|
+
self.queue_name queue, exclusive: exclusive
|
30
|
+
|
31
|
+
# Bind together
|
27
32
|
amqp_queue.bind(amqp_exchange, routing_key: routing_key)
|
28
33
|
end
|
29
34
|
|
@@ -44,7 +49,7 @@ module RabidMQ
|
|
44
49
|
# end
|
45
50
|
#
|
46
51
|
def exchange(topic, **options)
|
47
|
-
@amqp_exchange = RabidMQ.topic_exchange
|
52
|
+
@amqp_exchange = RabidMQ.topic_exchange topic, **options
|
48
53
|
end
|
49
54
|
|
50
55
|
def bind(exchange=amqp_exchange, routing_key: @routing_key, **options)
|
data/lib/rabid_mq/publisher.rb
CHANGED
@@ -23,8 +23,8 @@ module RabidMQ
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class << self
|
26
|
-
def amqp_broadcast(topic, payload, routing_key: self.default_amqp_routing_key)
|
27
|
-
exchange = topic_exchange(topic,
|
26
|
+
def amqp_broadcast(topic, payload, routing_key: self.default_amqp_routing_key, **options)
|
27
|
+
exchange = topic_exchange(topic, **options)
|
28
28
|
exchange.publish(payload, routing_key: routing_key)
|
29
29
|
rescue => e
|
30
30
|
if defined? ::Rails
|
@@ -42,11 +42,6 @@ module RabidMQ
|
|
42
42
|
self.name.underscore.gsub(/\//, '.')
|
43
43
|
end
|
44
44
|
|
45
|
-
# Provide a topic exchange on demand connected to the existing channel
|
46
|
-
def topic_exchange(topic, **options)
|
47
|
-
channel.topic(name_with_env(topic), **options)
|
48
|
-
end
|
49
|
-
|
50
45
|
# Provide fanout exchange
|
51
46
|
def fanout_exchange(topic, **options)
|
52
47
|
channel.fanout(name_with_env(topic), **options)
|
@@ -55,25 +50,28 @@ module RabidMQ
|
|
55
50
|
# Get a channel with the Bunny::Session
|
56
51
|
delegate :channel,
|
57
52
|
:reconnect,
|
53
|
+
:connection,
|
54
|
+
:name_with_env,
|
55
|
+
:topic_exchange,
|
58
56
|
to: ::RabidMQ
|
59
57
|
|
60
|
-
# Start a new connection
|
61
|
-
def amqp_connect
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
58
|
+
# # Start a new connection
|
59
|
+
# def amqp_connect
|
60
|
+
# connection.tap do |c|
|
61
|
+
# c.start
|
62
|
+
# end
|
63
|
+
# end
|
66
64
|
|
67
|
-
def name_with_env(name)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
65
|
+
# def name_with_env(name)
|
66
|
+
# return name unless defined?(::Rails)
|
67
|
+
# return name if name.match /\[(development|test|production|integration|pod)\]/
|
68
|
+
# name + "[#{Config.environment}]"
|
69
|
+
# end
|
72
70
|
|
73
|
-
# Provide a new or existing Bunny::Session
|
74
|
-
def connection
|
75
|
-
|
76
|
-
end
|
71
|
+
# # Provide a new or existing Bunny::Session
|
72
|
+
# def connection
|
73
|
+
# @connection ||= Bunny.new RabidMQ::Config.load_config
|
74
|
+
# end
|
77
75
|
|
78
76
|
end
|
79
77
|
end
|
data/lib/rabid_mq/version.rb
CHANGED
data/lib/rabid_mq.rb
CHANGED
@@ -15,13 +15,21 @@ module RabidMQ
|
|
15
15
|
class << self
|
16
16
|
|
17
17
|
# Provide a topic exchange on demand connected to the existing channel
|
18
|
-
def topic_exchange(topic, durable:
|
18
|
+
def topic_exchange(topic, durable: false, **options)
|
19
19
|
channel.topic(name_with_env(topic), durable: durable, **options)
|
20
|
+
rescue Bunny::PreconditionFailed => e
|
21
|
+
if e.message.match(/inequivalent arg 'durable'/).present?
|
22
|
+
durable = !durable
|
23
|
+
reconnect
|
24
|
+
topic_exchange(topic, durable: durable, **options)
|
25
|
+
else
|
26
|
+
fail e
|
27
|
+
end
|
20
28
|
end
|
21
29
|
|
22
30
|
# Provide fanout exchange
|
23
|
-
def fanout_exchange(topic,
|
24
|
-
channel.fanout(name_with_env(topic),
|
31
|
+
def fanout_exchange(topic, **options)
|
32
|
+
channel.fanout(name_with_env(topic), **options)
|
25
33
|
end
|
26
34
|
|
27
35
|
# Get a channel with the Bunny::Session
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabid_mq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyrone Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|