rabid_mq 0.1.19 → 0.1.20

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: 8f7aefbf3f6682d67ee501bb57e02eac146bdf5a
4
- data.tar.gz: a5cce8dc59df25b613e62b31f0088cf89bb85a44
3
+ metadata.gz: e1377b3526d20e974b3d6096c72247eb415feded
4
+ data.tar.gz: 78b3e87500b5794f660655a98a7305e3106b6909
5
5
  SHA512:
6
- metadata.gz: cb4a463aae74f725e30d68e913970b4def21f8a5fef0277763de2724991501988fe26ce7eb5c4fae2c94cc86bf0926ac0bcf44387bb70a88b126cad655bfe429
7
- data.tar.gz: f1567bb3ba086a600314973f96221c0ad30e893a051760d46440c7befabbae0501731a757f81334dbdc6bebc7985f8973d761c5100d7c90f366a960a44c8b031
6
+ metadata.gz: f150cef5b1fd066d7b75e982d94c1726ddcbe394e733f04eb6351cfdc94f545c22797fd85aaf3afd476bb2285cde5daeecec7fa2fc8bf4b063253723e31356b5
7
+ data.tar.gz: 35d91088d9e62803c955a0325d3486fa5a6bf57e3bbeb704412a749d0afe06e696a4d8bf0b6219ae268cce02466d8c9c54db31d465187212c59f4ac6ef0b3e5e
data/lib/rabid_mq.rb CHANGED
@@ -26,7 +26,7 @@ module RabidMQ
26
26
 
27
27
  # Get a channel with the Bunny::Session
28
28
  def channel
29
- connection.create_channel
29
+ connect.create_channel
30
30
  end
31
31
 
32
32
  # Start a new connection
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RabidMQ
2
- VERSION = "0.1.19"
2
+ VERSION = "0.1.20"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabid_mq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyrone Wilson