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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97a994357baf82e1c1b8647810760c6711c3d000
4
- data.tar.gz: 5ce6886aa4eb78f1d66a09dc610207bdd26eae75
3
+ metadata.gz: 9ff0b2b418b4aa5885ab95513cf23ed0833deb4a
4
+ data.tar.gz: 3f63f7a19c9fd404e518ba409de814c35bd107a0
5
5
  SHA512:
6
- metadata.gz: 7a678059c9597b8366dc777598a0811ec5c5edf9883a1ee6b739ce5607f3152726885e8ca7000f06a76aa3de9677c1acdced648cdc6f8f91a15df2147e89e7bc
7
- data.tar.gz: 11f439a4eaa597b6e7f2633192609a92efe6d61b1a2b0e7cb839c63c2c0e5eb146be0c9314c035f7c96137a08e3949cd95472ec110744589603fb08eda256155
6
+ metadata.gz: 2da7634d1e55d9206e3e51e1e73983bb81c4ffd4e0a3a745b2e8042f40257e333bbc5a7b1809a0e34d07dc893f7538d6c57a40aa3d1280fb419c78ad6973bea2
7
+ data.tar.gz: 0c365f972184202f6f0488033009ce1fa6ba16e0f1866343373eadc03b61f46f161f944c0c89d02e8944701b5082c332560216bb03b6b7e3786469d55b6cffda
@@ -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
- self.queue_name queue, exclusive: exclusive
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 name_with_env(topic), **options
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)
@@ -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, durable: true)
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
- connection.tap do |c|
63
- c.start
64
- end
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
- return name unless defined?(::Rails)
69
- return name if name.match /\[(development|test|production|integration|pod)\]/
70
- name + "[#{Config.environment}]"
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
- @connection ||= Bunny.new RabidMQ::Config.load_config
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
@@ -1,3 +1,3 @@
1
1
  module RabidMQ
2
- VERSION = "0.1.30"
2
+ VERSION = "0.1.31"
3
3
  end
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: true, **options)
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, durable: true, **options)
24
- channel.fanout(name_with_env(topic), durable: durable, **options)
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.30
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-02-27 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny