watership 0.3.7 → 0.4.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/lib/watership/consumer.rb +25 -12
- data/lib/watership/version.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: c343b8f27c9dfabdbef3863bda8a918eeaf0097a
|
4
|
+
data.tar.gz: 977ef5d709616c80d9c3ca07a5d05dbd0f378570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99cc83e6ad322b28593c8ff9193343dc0f1c80a45e9a43219eeeafeb324ccde6d6057fc20edcc56c134e37716000227d60d3df045badff6d6e1fab718044c140
|
7
|
+
data.tar.gz: d763b661e3ecaa1df2bd646ae240d6eddc7a9ce865375996e7c9eef303e78afb07704460365ba448b3ac3b07050c680378fff72393e326918349ea4d4144386f
|
data/CHANGELOG.md
CHANGED
data/lib/watership/consumer.rb
CHANGED
@@ -16,28 +16,32 @@ module Watership
|
|
16
16
|
Thread.abort_on_exception = true
|
17
17
|
begin
|
18
18
|
queue.subscribe(@queue_opts) do |delivery_info, properties, payload|
|
19
|
-
success =
|
19
|
+
success = true
|
20
|
+
data = JSON.parse(payload)
|
20
21
|
begin
|
21
|
-
@consumer.call(
|
22
|
-
|
22
|
+
@consumer.call(data)
|
23
|
+
ack_message(delivery_info.delivery_tag)
|
23
24
|
rescue StandardError => exception
|
24
25
|
logger.error "Error thrown in subscribe block"
|
25
26
|
logger.error exception.message
|
26
27
|
logger.error exception.backtrace.join("\n")
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
retries = data["retries"] || 0
|
30
|
+
|
31
|
+
if retries.to_i < 3
|
32
|
+
Watership.enqueue(name: @consumer.class::QUEUE, payload: data.merge({retries: retries+1}))
|
33
|
+
end
|
34
|
+
|
35
|
+
Airbrake.notify(exception) if defined?(Airbrake)
|
36
|
+
Bugsnag.notify(exception, data: {payload: data, retries: retries}) if defined?(Bugsnag)
|
30
37
|
rescue Interrupt => exception
|
38
|
+
success = false
|
31
39
|
logger.error "Interrupt in subscribe block"
|
32
40
|
logger.warn "Stopped gracefully."
|
33
41
|
throw(:terminate)
|
34
42
|
ensure
|
35
|
-
|
36
|
-
|
37
|
-
channel.acknowledge(delivery_info.delivery_tag, false)
|
38
|
-
else
|
39
|
-
logger.info "Rejecting message"
|
40
|
-
channel.reject(delivery_info.delivery_tag, true)
|
43
|
+
unless success
|
44
|
+
reject_message(delivery_info.delivery_tag)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
end
|
@@ -48,6 +52,15 @@ module Watership
|
|
48
52
|
end
|
49
53
|
|
50
54
|
private
|
55
|
+
def ack_message(tag)
|
56
|
+
logger.info "Acking message"
|
57
|
+
channel.acknowledge(tag, false)
|
58
|
+
end
|
59
|
+
|
60
|
+
def reject_message(tag)
|
61
|
+
logger.info "Rejecting message"
|
62
|
+
channel.reject(tag, true)
|
63
|
+
end
|
51
64
|
|
52
65
|
def queue
|
53
66
|
@queue ||= channel.queue(@consumer.class::QUEUE, @channel_opts)
|
data/lib/watership/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Scofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|