propono 2.1.0 → 2.2.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 +5 -5
- data/CHANGELOG.md +4 -1
- data/README.md +11 -1
- data/lib/propono/components/aws_client.rb +1 -1
- data/lib/propono/configuration.rb +3 -1
- data/lib/propono/services/queue_listener.rb +2 -2
- data/lib/propono/version.rb +1 -1
- data/test/configuration_test.rb +1 -1
- data/test/services/queue_listener_test.rb +26 -0
- metadata +3 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a9f4ef61f2fc61c86555f4ce3d2b8774066507e41d28c9e9b192b983f4f5c7a2
|
|
4
|
+
data.tar.gz: 60c26c57e8751eb45f9ebd10b43ee6d02445a274295a04aeeee8a3537354664b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a062a3fea085d58e0502d9e3a4b9e37c33e601a49fa59b7ac470a22587752458d0510242baceb4ae026bd121b5b5c22f0e29027a5de09dbf310301bda9093234
|
|
7
|
+
data.tar.gz: 4263d2200e6be98b1a6b99f7ba67d6af0661db8dd8427d5b362d79f18532c7c4af428fea750d36de01fc0c7558e9dc7726cc065cf1c7c90a9b77125c37b2e09e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Propono::Client.new.publish('some-topic', "The Best Message Ever")
|
|
|
23
23
|
|
|
24
24
|
## Changes from v1 to v2
|
|
25
25
|
|
|
26
|
-
Version 2 of Propono changed a few things:
|
|
26
|
+
Version 2 of Propono changed a few things:
|
|
27
27
|
- We moved from a global interface to a client interface. Rather than calling `publish` and equivalent on `Propono`, you should now initialize a `Propono::Client` and then call everything on that client. This fixes issues with thread safety and global config.
|
|
28
28
|
- We have also removed the dependancy on Fog and instead switch to the `sns` and `sqs` mini-gems of `aws-sdk`.
|
|
29
29
|
- UDP and TCP support have been removed, and `subscribe_by_post` has been removed.
|
|
@@ -99,11 +99,17 @@ Propono::Client.new do |config|
|
|
|
99
99
|
|
|
100
100
|
config.max_retries = "The number of retries if a message raises an exception before being placed on the failed queue"
|
|
101
101
|
config.num_messages_per_poll = "The number of messages retrieved per poll to SQS"
|
|
102
|
+
|
|
103
|
+
config.slow_queue_enabled = true
|
|
102
104
|
end
|
|
103
105
|
```
|
|
104
106
|
|
|
105
107
|
### Options
|
|
106
108
|
|
|
109
|
+
#### Async
|
|
110
|
+
|
|
111
|
+
By default messages are posted inline, blocking the main thread. The `async: true` option can be sent when posting a message, which will spawn a new thread for the message networking calls, and unblocking the main thread.
|
|
112
|
+
|
|
107
113
|
#### Visiblity Timeout
|
|
108
114
|
|
|
109
115
|
For certain tasks (e.g. video processing), being able to hold messages for longer is important. To achieve this, the [visibility timeout of a message](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) can be changed on the call to listen. e.g.
|
|
@@ -114,6 +120,10 @@ client.listen('long-running-tasks', visiblity_timeout: 3600) do |message|
|
|
|
114
120
|
end
|
|
115
121
|
```
|
|
116
122
|
|
|
123
|
+
### Slow Queue
|
|
124
|
+
|
|
125
|
+
The slow queue can be disabled by setting `slow_queue_enabled` to `false`. This will yield performance improvements if you do not make use of the "slow queue" functionality.
|
|
126
|
+
|
|
117
127
|
These can all also be set using the `client.config.access_key = "..."` syntax.
|
|
118
128
|
|
|
119
129
|
### Is it any good?
|
|
@@ -22,6 +22,7 @@ module Propono
|
|
|
22
22
|
add_setting :logger
|
|
23
23
|
add_setting :max_retries
|
|
24
24
|
add_setting :num_messages_per_poll
|
|
25
|
+
add_setting :slow_queue_enabled, required: false
|
|
25
26
|
|
|
26
27
|
add_setting :use_iam_profile, required: false
|
|
27
28
|
add_setting :queue_suffix, required: false
|
|
@@ -32,7 +33,8 @@ module Propono
|
|
|
32
33
|
queue_suffix: "",
|
|
33
34
|
use_iam_profile: false,
|
|
34
35
|
max_retries: 0,
|
|
35
|
-
num_messages_per_poll:
|
|
36
|
+
num_messages_per_poll: 1,
|
|
37
|
+
slow_queue_enabled: true
|
|
36
38
|
}
|
|
37
39
|
end
|
|
38
40
|
|
|
@@ -28,14 +28,14 @@ module Propono
|
|
|
28
28
|
def drain
|
|
29
29
|
raise ProponoError.new("topic_name is nil") unless topic_name
|
|
30
30
|
true while read_messages_from_queue(main_queue, 10, long_poll: false)
|
|
31
|
-
true while read_messages_from_queue(slow_queue, 10, long_poll: false)
|
|
31
|
+
true while read_messages_from_queue(slow_queue, 10, long_poll: false) if propono_config.slow_queue_enabled
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def read_messages
|
|
37
37
|
read_messages_from_queue(main_queue, propono_config.num_messages_per_poll) ||
|
|
38
|
-
|
|
38
|
+
(propono_config.slow_queue_enabled ? read_messages_from_queue(slow_queue, 1) : nil)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def read_messages_from_queue(queue, num_messages, long_poll: true)
|
data/lib/propono/version.rb
CHANGED
data/test/configuration_test.rb
CHANGED
|
@@ -58,6 +58,7 @@ module Propono
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
# Keep this test in sync with the one below, just with the config enabled
|
|
61
62
|
def test_drain_should_continue_if_queue_empty
|
|
62
63
|
@listener.expects(:read_messages_from_queue).with(@slow_queue, 10, long_poll: false).returns(false)
|
|
63
64
|
@listener.expects(:read_messages_from_queue).with(@queue, 10, long_poll: false).returns(false)
|
|
@@ -65,6 +66,16 @@ module Propono
|
|
|
65
66
|
assert true
|
|
66
67
|
end
|
|
67
68
|
|
|
69
|
+
# Keep this test in sync with the one above, just with the config disabled
|
|
70
|
+
def test_drain_ignores_slow_queue_if_disabled
|
|
71
|
+
propono_config.slow_queue_enabled = false
|
|
72
|
+
|
|
73
|
+
@listener.expects(:read_messages_from_queue).with(@slow_queue, 10, long_poll: false).never
|
|
74
|
+
@listener.expects(:read_messages_from_queue).with(@queue, 10, long_poll: false).returns(false)
|
|
75
|
+
@listener.drain
|
|
76
|
+
assert true
|
|
77
|
+
end
|
|
78
|
+
|
|
68
79
|
def test_drain_raises_with_nil_topic
|
|
69
80
|
listener = QueueListener.new(aws_client, propono_config, nil) {}
|
|
70
81
|
assert_raises ProponoError do
|
|
@@ -217,6 +228,7 @@ module Propono
|
|
|
217
228
|
@listener.send(:move_to_corrupt_queue, @sqs_message1)
|
|
218
229
|
end
|
|
219
230
|
|
|
231
|
+
# Keep this test in sync with the one below, just with the config enabled
|
|
220
232
|
def test_if_no_messages_read_from_normal_queue_read_from_slow_queue
|
|
221
233
|
main_queue = mock
|
|
222
234
|
@listener.stubs(main_queue: main_queue)
|
|
@@ -228,6 +240,20 @@ module Propono
|
|
|
228
240
|
@listener.send(:read_messages)
|
|
229
241
|
end
|
|
230
242
|
|
|
243
|
+
# Keep this test in sync with the one above, just with the config disabled
|
|
244
|
+
def ignore_slow_queue_if_disabled
|
|
245
|
+
propono_config.slow_queue_enabled = false
|
|
246
|
+
|
|
247
|
+
main_queue = mock
|
|
248
|
+
@listener.stubs(main_queue: main_queue)
|
|
249
|
+
slow_queue = mock
|
|
250
|
+
@listener.stubs(slow_queue: slow_queue)
|
|
251
|
+
|
|
252
|
+
@listener.expects(:read_messages_from_queue).with(main_queue, propono_config.num_messages_per_poll).returns(false)
|
|
253
|
+
@listener.expects(:read_messages_from_queue).with(slow_queue, 1).never
|
|
254
|
+
@listener.send(:read_messages)
|
|
255
|
+
end
|
|
256
|
+
|
|
231
257
|
def test_if_read_messages_from_normal_do_not_read_from_slow_queue
|
|
232
258
|
main_queue = mock
|
|
233
259
|
@listener.stubs(main_queue: main_queue)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: propono
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MalcyL
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2019-09-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: aws-sdk-sns
|
|
@@ -177,8 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
177
|
- !ruby/object:Gem::Version
|
|
178
178
|
version: '0'
|
|
179
179
|
requirements: []
|
|
180
|
-
|
|
181
|
-
rubygems_version: 2.6.13
|
|
180
|
+
rubygems_version: 3.0.3
|
|
182
181
|
signing_key:
|
|
183
182
|
specification_version: 4
|
|
184
183
|
summary: General purpose pub/sub library built on top of AWS SNS and SQS
|
|
@@ -199,4 +198,3 @@ test_files:
|
|
|
199
198
|
- test/services/queue_listener_test.rb
|
|
200
199
|
- test/test_helper.rb
|
|
201
200
|
- test/utils/hash_test.rb
|
|
202
|
-
has_rdoc:
|