propono 2.1.0 → 2.2.0

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
- SHA1:
3
- metadata.gz: 53dbc7f715b2bb37de7874a88c8b3f968ea1fc4f
4
- data.tar.gz: 11bce43d6c3753af3af92c9c91b293a376fae392
2
+ SHA256:
3
+ metadata.gz: a9f4ef61f2fc61c86555f4ce3d2b8774066507e41d28c9e9b192b983f4f5c7a2
4
+ data.tar.gz: 60c26c57e8751eb45f9ebd10b43ee6d02445a274295a04aeeee8a3537354664b
5
5
  SHA512:
6
- metadata.gz: 235e0650f5f1be3b1240b57b87c48fd66609cb2e7d915b8e6a409ed67e8475c680540cf0fc021aaa408915e3643c307a32afd1b5f1150c945b4ce7e361b0cffd
7
- data.tar.gz: 221535790828808e5451dc8ba3ff32aa882c719d840c9d25cf5f4619839d22b1c2fa0e3dde48aa71a75bb6723f607516f4a56c75c3c8899a8354425b1bdf66ec
6
+ metadata.gz: a062a3fea085d58e0502d9e3a4b9e37c33e601a49fa59b7ac470a22587752458d0510242baceb4ae026bd121b5b5c22f0e29027a5de09dbf310301bda9093234
7
+ data.tar.gz: 4263d2200e6be98b1a6b99f7ba67d6af0661db8dd8427d5b362d79f18532c7c4af428fea750d36de01fc0c7558e9dc7726cc065cf1c7c90a9b77125c37b2e09e
@@ -1,4 +1,7 @@
1
- # 2.0.0 / 2017-03-14
1
+ # 2.2.0 / 2019-09-21
2
+ * [FEATURE] Add setting to disable slow queue
3
+
4
+ # 2.1.0 / 2017-03-14
2
5
  * [FEATURE] Added visibility_timeout to listen
3
6
 
4
7
  # 2.0.0 / 2017-03-14
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?
@@ -43,7 +43,7 @@ module Propono
43
43
  def set_sqs_policy(queue, policy)
44
44
  sqs_client.set_queue_attributes(
45
45
  queue_url: queue.url,
46
- attributes: { "Policy": policy }
46
+ attributes: { Policy: policy }
47
47
  )
48
48
  end
49
49
 
@@ -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: 10
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
- read_messages_from_queue(slow_queue, 1)
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)
@@ -1,3 +1,3 @@
1
1
  module Propono
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -65,7 +65,7 @@ module Propono
65
65
  end
66
66
 
67
67
  def test_default_num_messages_per_poll
68
- assert_equal 10, propono_config.num_messages_per_poll
68
+ assert_equal 1, propono_config.num_messages_per_poll
69
69
  end
70
70
 
71
71
  def test_num_messages_per_poll
@@ -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.1.0
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: 2017-11-10 00:00:00.000000000 Z
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
- rubyforge_project:
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: