propono 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +12 -0
- data/lib/propono/components/aws_client.rb +4 -2
- data/lib/propono/components/client.rb +2 -2
- data/lib/propono/services/queue_listener.rb +4 -3
- data/lib/propono/version.rb +1 -1
- data/test/components/client_test.rb +18 -1
- data/test/services/queue_listener_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53dbc7f715b2bb37de7874a88c8b3f968ea1fc4f
|
4
|
+
data.tar.gz: 11bce43d6c3753af3af92c9c91b293a376fae392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235e0650f5f1be3b1240b57b87c48fd66609cb2e7d915b8e6a409ed67e8475c680540cf0fc021aaa408915e3643c307a32afd1b5f1150c945b4ce7e361b0cffd
|
7
|
+
data.tar.gz: 221535790828808e5451dc8ba3ff32aa882c719d840c9d25cf5f4619839d22b1c2fa0e3dde48aa71a75bb6723f607516f4a56c75c3c8899a8354425b1bdf66ec
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -102,6 +102,18 @@ Propono::Client.new do |config|
|
|
102
102
|
end
|
103
103
|
```
|
104
104
|
|
105
|
+
### Options
|
106
|
+
|
107
|
+
#### Visiblity Timeout
|
108
|
+
|
109
|
+
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.
|
110
|
+
|
111
|
+
```
|
112
|
+
client.listen('long-running-tasks', visiblity_timeout: 3600) do |message|
|
113
|
+
puts "I just received: #{message}"
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
105
117
|
These can all also be set using the `client.config.access_key = "..."` syntax.
|
106
118
|
|
107
119
|
### Is it any good?
|
@@ -47,12 +47,14 @@ module Propono
|
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
def read_from_sqs(queue, num_messages, long_poll: true)
|
50
|
+
def read_from_sqs(queue, num_messages, long_poll: true, visibility_timeout: nil)
|
51
51
|
wait_time_seconds = long_poll ? 20 : 0
|
52
|
+
visibility_timeout ||= 30
|
52
53
|
sqs_client.receive_message(
|
53
54
|
queue_url: queue.url,
|
54
55
|
wait_time_seconds: wait_time_seconds,
|
55
|
-
max_number_of_messages: num_messages
|
56
|
+
max_number_of_messages: num_messages,
|
57
|
+
visibility_timeout: visibility_timeout
|
56
58
|
).messages
|
57
59
|
end
|
58
60
|
|
@@ -69,8 +69,8 @@ module Propono
|
|
69
69
|
#
|
70
70
|
# @param [String] topic The topic to subscribe to.
|
71
71
|
# @param &message_processor The block to yield for each message.
|
72
|
-
def listen(topic_name, &message_processor)
|
73
|
-
QueueListener.listen(aws_client, config, topic_name, &message_processor)
|
72
|
+
def listen(topic_name, options = {}, &message_processor)
|
73
|
+
QueueListener.listen(aws_client, config, topic_name, options, &message_processor)
|
74
74
|
end
|
75
75
|
|
76
76
|
# Listens on a queue and yields for each message
|
@@ -9,12 +9,13 @@ module Propono
|
|
9
9
|
new(*args, &message_processor).drain
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_reader :aws_client, :propono_config, :topic_name, :message_processor
|
13
|
-
def initialize(aws_client, propono_config, topic_name, &message_processor)
|
12
|
+
attr_reader :aws_client, :propono_config, :topic_name, :visibility_timeout, :message_processor
|
13
|
+
def initialize(aws_client, propono_config, topic_name, options = {}, &message_processor)
|
14
14
|
@aws_client = aws_client
|
15
15
|
@propono_config = propono_config
|
16
16
|
@topic_name = topic_name
|
17
17
|
@message_processor = message_processor
|
18
|
+
@visibility_timeout = options[:visibility_timeout] || nil
|
18
19
|
end
|
19
20
|
|
20
21
|
def listen
|
@@ -38,7 +39,7 @@ module Propono
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def read_messages_from_queue(queue, num_messages, long_poll: true)
|
41
|
-
messages = aws_client.read_from_sqs(queue, num_messages, long_poll: long_poll)
|
42
|
+
messages = aws_client.read_from_sqs(queue, num_messages, long_poll: long_poll, visibility_timeout: visibility_timeout)
|
42
43
|
if messages.empty?
|
43
44
|
false
|
44
45
|
else
|
data/lib/propono/version.rb
CHANGED
@@ -40,11 +40,28 @@ module Propono
|
|
40
40
|
QueueListener.expects(:listen).with(
|
41
41
|
client.aws_client,
|
42
42
|
client.config,
|
43
|
-
topic
|
43
|
+
topic,
|
44
|
+
{}
|
44
45
|
)
|
45
46
|
client.listen(topic)
|
46
47
|
end
|
47
48
|
|
49
|
+
def test_listen_calls_queue_listener_with_options
|
50
|
+
topic = 'foobar'
|
51
|
+
options = {foo: 'bar'}
|
52
|
+
|
53
|
+
client = Propono::Client.new
|
54
|
+
QueueListener.expects(:listen).with(
|
55
|
+
client.aws_client,
|
56
|
+
client.config,
|
57
|
+
topic,
|
58
|
+
options
|
59
|
+
)
|
60
|
+
client.listen(topic, options)
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
48
65
|
def test_drain_queue_calls_queue_listener
|
49
66
|
topic = 'foobar'
|
50
67
|
|
@@ -81,7 +81,7 @@ module Propono
|
|
81
81
|
|
82
82
|
def test_read_message_from_sqs
|
83
83
|
max_number_of_messages = 5
|
84
|
-
aws_client.expects(:read_from_sqs).with(@queue, max_number_of_messages, long_poll: true)
|
84
|
+
aws_client.expects(:read_from_sqs).with(@queue, max_number_of_messages, long_poll: true, visibility_timeout: nil)
|
85
85
|
@listener.send(:read_messages_from_queue, @queue, max_number_of_messages)
|
86
86
|
end
|
87
87
|
|
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.1.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-10
|
12
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-sns
|