appfuel-service 0.2.11 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/appfuel/service/config/sneakers.rb +1 -0
- data/lib/appfuel/service/initializers/message_broker.rb +1 -0
- data/lib/appfuel/service/msg_request.rb +5 -2
- data/lib/appfuel/service/version.rb +1 -1
- data/lib/appfuel/service/worker.rb +35 -17
- 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: 49f4ecb203ac98c01c7d7420023858517050c19b
|
4
|
+
data.tar.gz: 6dbc6d6f64d48174cc1da516652f3e866e6f2619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54faddafcf35f32c5df83012ab099907ea706201952fb55bd3a0ce561f78ccd9e03fd4e7a3a11cc6c4bbceafd7c3066bc839da0e5b1208ea10bc67ccd64ece1a
|
7
|
+
data.tar.gz: 02be1f89fd3ef210d00cc2efd041e053ef7e3b6611e9b7471bcc291b98a9edc597363c8be4c9b4c12859246069b6777897ec24dfa4a191da55487a62548b184b
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. (Pending ap
|
|
5
5
|
|
6
6
|
|
7
7
|
# Releases
|
8
|
+
## [[0.3.2]](https://github.com/rsb/appfuel/releases/tag/0.3.2) 2017-09-19
|
9
|
+
### Fixed
|
10
|
+
- worker did not log handled failures
|
11
|
+
|
12
|
+
## [[0.3.1]](https://github.com/rsb/appfuel/releases/tag/0.3.1) 2017-09-18
|
13
|
+
### Changed
|
14
|
+
- adding error handling/logging for rpc and non rpc requests
|
15
|
+
|
8
16
|
## [[0.3.0]](https://github.com/rsb/appfuel/releases/tag/0.2.11) 2017-09-15
|
9
17
|
### Changed
|
10
18
|
- update sneakers to `2.6`
|
@@ -16,7 +16,7 @@ module Appfuel
|
|
16
16
|
# @return MsgRequest
|
17
17
|
def initialize(msg, delivery_info, properties)
|
18
18
|
inputs = validate_inputs(msg)
|
19
|
-
action_route = properties.headers['action_route']
|
19
|
+
action_route = properties.headers['action_route'].to_s
|
20
20
|
@properties = properties
|
21
21
|
@delivery_info = delivery_info
|
22
22
|
|
@@ -40,8 +40,11 @@ module Appfuel
|
|
40
40
|
properties.correlation_id
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
def action_route?
|
44
|
+
!action_route.empty?
|
45
|
+
end
|
44
46
|
|
47
|
+
private
|
45
48
|
def validate_inputs(msg)
|
46
49
|
msg = msg.to_s
|
47
50
|
return {} if msg.empty?
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'sneakers/handlers/maxretry'
|
1
2
|
module Appfuel
|
2
3
|
module Service
|
3
4
|
class Worker
|
@@ -34,31 +35,27 @@ module Appfuel
|
|
34
35
|
# @param properties [Bunny::MessageProperties]
|
35
36
|
# @return [Appfuel::Response]
|
36
37
|
def work_with_params(msg, delivery_info, properties)
|
37
|
-
container = app_container
|
38
|
-
logger = container[:logger]
|
39
|
-
logger.info "[queue worker] accepting msg"
|
40
38
|
begin
|
41
|
-
request
|
39
|
+
request = create_request(msg, delivery_info, properties)
|
42
40
|
rescue => e
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
response = Appfuel::ResponseHandler.new.error(worker: [error_msg])
|
48
|
-
publish_rpc(request, response)
|
49
|
-
end
|
41
|
+
request = create_request('{}', delivery_info, properties)
|
42
|
+
handle_exception("failed to build request", e, request)
|
43
|
+
return ack!
|
44
|
+
end
|
50
45
|
|
51
|
-
|
46
|
+
begin
|
47
|
+
response = dispatch(request, app_container)
|
48
|
+
rescue => e
|
49
|
+
handle_exception("failed to dispatch", e, request)
|
50
|
+
return ack!
|
52
51
|
end
|
53
52
|
|
54
|
-
response = dispatch(request, container)
|
55
53
|
if response.failure?
|
56
|
-
|
57
|
-
logger.error
|
54
|
+
msg_line = response.error_messages.join(' ')
|
55
|
+
logger.error "[#{request.action_route}] #{msg_line}"
|
58
56
|
end
|
59
57
|
|
60
|
-
if
|
61
|
-
logger.info "[queue worker] returning rpc msg"
|
58
|
+
if rpc?(properties)
|
62
59
|
publish_rpc(request, response)
|
63
60
|
end
|
64
61
|
|
@@ -66,6 +63,10 @@ module Appfuel
|
|
66
63
|
end
|
67
64
|
|
68
65
|
|
66
|
+
def rpc?(properties)
|
67
|
+
properties.correlation_id && properties.reply_to
|
68
|
+
end
|
69
|
+
|
69
70
|
# Publish a response for the rpc request.
|
70
71
|
#
|
71
72
|
# @param request [MsgRequest]
|
@@ -81,8 +82,25 @@ module Appfuel
|
|
81
82
|
nil
|
82
83
|
end
|
83
84
|
|
85
|
+
def logger
|
86
|
+
@logger ||= app_container[:logger]
|
87
|
+
end
|
88
|
+
|
84
89
|
private
|
85
90
|
|
91
|
+
def handle_exception(label, e, request)
|
92
|
+
err_msg = "[queue #{queue}] #{label}: #{e.message}"
|
93
|
+
logger.error err_msg
|
94
|
+
if rpc?(request.properties)
|
95
|
+
response = create_error_response(queue, error_msg)
|
96
|
+
publish_rpc(request, response)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_error_response(key, err_msg)
|
101
|
+
Appfuel::ResponseHandler.new.error(key => [error_msg])
|
102
|
+
end
|
103
|
+
|
86
104
|
def create_request(msg, delivery_info, properties)
|
87
105
|
Appfuel::Service::MsgRequest.new(msg, delivery_info, properties)
|
88
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appfuel-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Scott-Buccleuch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appfuel
|