pwwka 0.9.0 → 0.10.0.RC
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/pwwka/configuration.rb +2 -0
- data/lib/pwwka/transmitter.rb +2 -1
- data/lib/pwwka/version.rb +1 -1
- data/spec/integration/send_and_receive_spec.rb +15 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9ca6b30eabfbff9601a75dc1cd81352b71853b5
|
4
|
+
data.tar.gz: c3cc723a732f32a6193cb7f8ca5f4dd0d0828e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5ca80c9bde14c9e8fab77512fc5c7d62184d2c264b990c762241d7588d41b690b2ee9b6ce095a4d99c89d2450712cb77d9b02c93a861949024bbd60bee99e46
|
7
|
+
data.tar.gz: 0cd0da1a9240c791a3105eed6dd255726ef6d56bf195e2c7bb1e08d3d45fecf8adf9b909cebc647163949eef702af222144597a224067f849dee88e29539401d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -133,13 +133,21 @@ To enqueue a message in a background Resque job, use `Transmitter.send_message_a
|
|
133
133
|
Pwwka::Transmitter.send_message_async(payload, routing_key, delay_by_ms: 5000) # default delay is 0
|
134
134
|
```
|
135
135
|
|
136
|
-
If `Resque::Plugins::ExponentialBackoff` is available, the job will use it.
|
136
|
+
If `Resque::Plugins::ExponentialBackoff` is available, the job will use it. (Important: Your load/require order is important if you want exponential backoff with the built-in job due to [its error handling](https://github.com/stitchfix/pwwka/blob/713c6003fa6cf52cb4713c02b39fe7ee07ebe2e9/lib/pwwka/send_message_async_job.rb#L8).)
|
137
137
|
Customize the backoff intervals using the configuration `send_message_resque_backoff_strategy`.
|
138
138
|
The default backoff will retry quickly in case of an intermittent glitch, and then every ten
|
139
139
|
minutes for half an hour.
|
140
140
|
|
141
141
|
The name of the queue created is `pwwka_send_message_async`.
|
142
142
|
|
143
|
+
You can configure Pwwka to use your own custom job using the `async_job_klass` configuration option. Example might be:
|
144
|
+
|
145
|
+
```
|
146
|
+
Pwwka.configure do |config|
|
147
|
+
config.async_job_klass = YourApp::PwwkaAsyncJob
|
148
|
+
end
|
149
|
+
```
|
150
|
+
|
143
151
|
#### Message Queuer
|
144
152
|
|
145
153
|
You can queue up messages and send them in a batch. This is most useful when multiple messages
|
data/lib/pwwka/configuration.rb
CHANGED
@@ -9,6 +9,7 @@ module Pwwka
|
|
9
9
|
attr_accessor :delayed_exchange_name
|
10
10
|
attr_accessor :logger
|
11
11
|
attr_accessor :options
|
12
|
+
attr_accessor :async_job_klass
|
12
13
|
attr_accessor :send_message_resque_backoff_strategy
|
13
14
|
attr_accessor :requeue_on_error
|
14
15
|
attr_writer :keep_alive_on_handler_klass_exceptions
|
@@ -24,6 +25,7 @@ module Pwwka
|
|
24
25
|
600, 600, 600] # longer-term outage?
|
25
26
|
@requeue_on_error = false
|
26
27
|
@keep_alive_on_handler_klass_exceptions = false
|
28
|
+
@async_job_klass = Pwwka::SendMessageAsyncJob
|
27
29
|
end
|
28
30
|
|
29
31
|
def keep_alive_on_handler_klass_exceptions?
|
data/lib/pwwka/transmitter.rb
CHANGED
@@ -75,7 +75,8 @@ module Pwwka
|
|
75
75
|
# Use Resque to enqueue the message.
|
76
76
|
# - :delay_by_ms:: Integer milliseconds to delay the message. Default is 0.
|
77
77
|
def self.send_message_async(payload, routing_key, delay_by_ms: 0)
|
78
|
-
|
78
|
+
job = Pwwka.configuration.async_job_klass
|
79
|
+
Resque.enqueue_in(delay_by_ms/1000, job, payload, routing_key)
|
79
80
|
end
|
80
81
|
|
81
82
|
# Send a less important message that doesn't have to go through. This eats
|
data/lib/pwwka/version.rb
CHANGED
@@ -89,6 +89,21 @@ describe "sending and receiving messages", :integration do
|
|
89
89
|
expect(AllReceiver.messages_received.size).to eq(1)
|
90
90
|
end
|
91
91
|
|
92
|
+
it "can queue a job to send a message to a specified Resque job queue" do
|
93
|
+
async_job_klass = double(:async_job_klass)
|
94
|
+
configuration = Pwwka::Configuration.new
|
95
|
+
configuration.async_job_klass = async_job_klass
|
96
|
+
|
97
|
+
allow(Pwwka).to receive(:configuration).and_return(configuration)
|
98
|
+
|
99
|
+
allow(Resque).to receive(:enqueue_in)
|
100
|
+
|
101
|
+
Pwwka::Transmitter.send_message_async({ sample: "payload", has: { deeply: true, nested: 4 }},
|
102
|
+
"pwwka.testing.bar")
|
103
|
+
|
104
|
+
expect(Resque).to have_received(:enqueue_in).with(anything, async_job_klass, anything, anything)
|
105
|
+
end
|
106
|
+
|
92
107
|
class AllReceiver < LoggingReceiver
|
93
108
|
end
|
94
109
|
class FooReceiver < AllReceiver
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwwka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0.RC
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stitch Fix Engineering
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2017-
|
18
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bunny
|
@@ -237,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
|
-
- - "
|
240
|
+
- - ">"
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
242
|
+
version: 1.3.1
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project:
|
245
245
|
rubygems_version: 2.5.1
|