action_subscriber 2.3.0 → 2.4.0
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/README.md +1 -1
- data/lib/action_subscriber/default_routing.rb +1 -0
- data/lib/action_subscriber/route.rb +2 -0
- data/lib/action_subscriber/route_set.rb +1 -1
- data/lib/action_subscriber/router.rb +1 -0
- data/lib/action_subscriber/version.rb +1 -1
- data/routing.md +1 -0
- data/spec/lib/action_subscriber/router_spec.rb +22 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c72fc51c6d4da298f4078aab4dcc8c47846924a7
|
4
|
+
data.tar.gz: e3c4b28775c6253411f578cc76c205bb63df499f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 301ff28f924717c44385d6aeb5debc64b998fbdfa4c3808e0e5b7ce083ffafffeb285fca145ab65c3c6e0b483c354cba13c3b4c66dc764e397897c1aa43a07e5
|
7
|
+
data.tar.gz: 284132f6ff0c53f460e337c7e20d4d2d98ba75e04dbf5ba68f23368a69b913830b9b69a4057818aa98d2f26b9967a36cd03cb807dac1247d2a2955fc4801212f
|
data/README.md
CHANGED
@@ -72,7 +72,7 @@ ActionSubscriber needs to know how to connect to your rabbit server to start get
|
|
72
72
|
|
73
73
|
In an initializer, you can set the host and the port like this :
|
74
74
|
|
75
|
-
ActionSubscriber
|
75
|
+
ActionSubscriber.configure do |config|
|
76
76
|
config.hosts = ["rabbit1", "rabbit2", "rabbit3"]
|
77
77
|
config.port = 5672
|
78
78
|
end
|
@@ -2,6 +2,7 @@ module ActionSubscriber
|
|
2
2
|
class Route
|
3
3
|
attr_reader :acknowledgements,
|
4
4
|
:action,
|
5
|
+
:durable,
|
5
6
|
:exchange,
|
6
7
|
:prefetch,
|
7
8
|
:queue,
|
@@ -12,6 +13,7 @@ module ActionSubscriber
|
|
12
13
|
def initialize(attributes)
|
13
14
|
@acknowledgements = attributes.fetch(:acknowledgements)
|
14
15
|
@action = attributes.fetch(:action)
|
16
|
+
@durable = attributes.fetch(:durable)
|
15
17
|
@exchange = attributes.fetch(:exchange).to_s
|
16
18
|
@prefetch = attributes.fetch(:prefetch) { ::ActionSubscriber.config.prefetch }
|
17
19
|
@queue = attributes.fetch(:queue)
|
@@ -27,7 +27,7 @@ module ActionSubscriber
|
|
27
27
|
def setup_queue(route)
|
28
28
|
channel = ::ActionSubscriber::RabbitConnection.subscriber_connection.create_channel
|
29
29
|
exchange = channel.topic(route.exchange)
|
30
|
-
queue = channel.queue(route.queue)
|
30
|
+
queue = channel.queue(route.queue, :durable => route.durable)
|
31
31
|
queue.bind(exchange, :routing_key => route.routing_key)
|
32
32
|
queue
|
33
33
|
end
|
data/routing.md
CHANGED
@@ -34,6 +34,7 @@ The `route` method supports the following options:
|
|
34
34
|
|
35
35
|
* `acknowledgements` this toggles whether this route is expected to provide an acknowledgment (default `false`)
|
36
36
|
* This is the equivalent of calling `at_most_once!`, `at_least_once!` or `manual_acknowledgement!` in your subscriber class
|
37
|
+
* `durable` specifies whether the queue for this route should be a durable (default `false`)
|
37
38
|
* `exchange` specify which exchange you expect messages to be published to (default `"events"`)
|
38
39
|
* This is the equivalent of calling `exchange :actions` in your subscriber
|
39
40
|
* `publisher` this will prefix your queue and routing key with the publishers name
|
@@ -9,6 +9,7 @@ describe ActionSubscriber::Router do
|
|
9
9
|
expect(routes.first.acknowledgements).to eq(false)
|
10
10
|
expect(routes.first.action).to eq(:foo)
|
11
11
|
expect(routes.first.exchange).to eq("events")
|
12
|
+
expect(routes.first.durable).to eq(false)
|
12
13
|
expect(routes.first.routing_key).to eq("fake.foo")
|
13
14
|
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
14
15
|
expect(routes.first.queue).to eq("alice.fake.foo")
|
@@ -22,6 +23,7 @@ describe ActionSubscriber::Router do
|
|
22
23
|
expect(routes.first.acknowledgements).to eq(false)
|
23
24
|
expect(routes.first.action).to eq(:bluff)
|
24
25
|
expect(routes.first.exchange).to eq("events")
|
26
|
+
expect(routes.first.durable).to eq(false)
|
25
27
|
expect(routes.first.routing_key).to eq("amigo.fake.bluff")
|
26
28
|
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
27
29
|
expect(routes.first.queue).to eq("alice.amigo.fake.bluff")
|
@@ -35,6 +37,7 @@ describe ActionSubscriber::Router do
|
|
35
37
|
expect(routes.first.acknowledgements).to eq(false)
|
36
38
|
expect(routes.first.action).to eq(:crashed)
|
37
39
|
expect(routes.first.exchange).to eq("actions")
|
40
|
+
expect(routes.first.durable).to eq(false)
|
38
41
|
expect(routes.first.routing_key).to eq("fake.crashed")
|
39
42
|
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
40
43
|
expect(routes.first.queue).to eq("alice.fake.crashed")
|
@@ -48,6 +51,21 @@ describe ActionSubscriber::Router do
|
|
48
51
|
expect(routes.first.acknowledgements).to eq(true)
|
49
52
|
expect(routes.first.action).to eq(:foo)
|
50
53
|
expect(routes.first.exchange).to eq("events")
|
54
|
+
expect(routes.first.durable).to eq(false)
|
55
|
+
expect(routes.first.routing_key).to eq("fake.foo")
|
56
|
+
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
57
|
+
expect(routes.first.queue).to eq("alice.fake.foo")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "can specify a queue is durable" do
|
61
|
+
routes = described_class.draw_routes do
|
62
|
+
route FakeSubscriber, :foo, :durable => true
|
63
|
+
end
|
64
|
+
|
65
|
+
expect(routes.first.acknowledgements).to eq(false)
|
66
|
+
expect(routes.first.action).to eq(:foo)
|
67
|
+
expect(routes.first.exchange).to eq("events")
|
68
|
+
expect(routes.first.durable).to eq(true)
|
51
69
|
expect(routes.first.routing_key).to eq("fake.foo")
|
52
70
|
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
53
71
|
expect(routes.first.queue).to eq("alice.fake.foo")
|
@@ -71,6 +89,7 @@ describe ActionSubscriber::Router do
|
|
71
89
|
expect(routes.first.acknowledgements).to eq(false)
|
72
90
|
expect(routes.first.action).to eq(:foo)
|
73
91
|
expect(routes.first.exchange).to eq("events")
|
92
|
+
expect(routes.first.durable).to eq(false)
|
74
93
|
expect(routes.first.routing_key).to eq("russell.fake.foo")
|
75
94
|
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
76
95
|
expect(routes.first.queue).to eq("i-am-your-father")
|
@@ -84,6 +103,7 @@ describe ActionSubscriber::Router do
|
|
84
103
|
expect(routes.first.acknowledgements).to eq(false)
|
85
104
|
expect(routes.first.action).to eq(:foo)
|
86
105
|
expect(routes.first.exchange).to eq("events")
|
106
|
+
expect(routes.first.durable).to eq(false)
|
87
107
|
expect(routes.first.routing_key).to eq("make.it.so")
|
88
108
|
expect(routes.first.subscriber).to eq(FakeSubscriber)
|
89
109
|
expect(routes.first.queue).to eq("alice.russell.fake.foo")
|
@@ -107,12 +127,14 @@ describe ActionSubscriber::Router do
|
|
107
127
|
expect(routes.first.acknowledgements).to eq(true)
|
108
128
|
expect(routes.first.action).to eq(:bright)
|
109
129
|
expect(routes.first.exchange).to eq("party")
|
130
|
+
expect(routes.first.durable).to eq(false)
|
110
131
|
expect(routes.first.routing_key).to eq("tommy.sparkle.bright")
|
111
132
|
expect(routes.first.subscriber).to eq(SparkleSubscriber)
|
112
133
|
expect(routes.first.queue).to eq("alice.tommy.sparkle.bright")
|
113
134
|
expect(routes.last.acknowledgements).to eq(true)
|
114
135
|
expect(routes.last.action).to eq(:dim)
|
115
136
|
expect(routes.last.exchange).to eq("party")
|
137
|
+
expect(routes.last.durable).to eq(false)
|
116
138
|
expect(routes.last.routing_key).to eq("tommy.sparkle.dim")
|
117
139
|
expect(routes.last.subscriber).to eq(SparkleSubscriber)
|
118
140
|
expect(routes.last.queue).to eq("alice.tommy.sparkle.dim")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-
|
15
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -277,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
277
|
version: '0'
|
278
278
|
requirements: []
|
279
279
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.
|
280
|
+
rubygems_version: 2.5.2
|
281
281
|
signing_key:
|
282
282
|
specification_version: 4
|
283
283
|
summary: ActionSubscriber is a DSL that allows a rails app to consume messages from
|