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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cd12824170706dbce596a3e5cdb94a3bd0f3996
4
- data.tar.gz: 07fd6d61b72382a28561d56f6c84a90446d84a7b
3
+ metadata.gz: 49f4ecb203ac98c01c7d7420023858517050c19b
4
+ data.tar.gz: 6dbc6d6f64d48174cc1da516652f3e866e6f2619
5
5
  SHA512:
6
- metadata.gz: b9df1660285c042835c7b22d01e0269d8d00eb20f7553a638d6e8fea03db8af78f6a50dce0628061e66cb64f633eb805a2a601e3248145aac2e08d3d7e09cdc5
7
- data.tar.gz: b0a32d7aaa27da86c5c31709bb2bf627ea3ef167f5b946ccf2063fd3cdc40c556c06d0274886f8b5a8d43029c21b7a74fe9f00c970ff60b2ef6a44f2980e7537
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`
@@ -34,6 +34,7 @@ module Appfuel
34
34
  workers: 1,
35
35
  threads: 1,
36
36
  prefetch: 1,
37
+ retry_timeout: 60 * 1000, # 60s
37
38
  timeout_job_after: 5,
38
39
  durable: true
39
40
 
@@ -10,6 +10,7 @@ Appfuel::Initialize.define('global.message_broker') do |config, container|
10
10
 
11
11
  require 'sneakers'
12
12
  require 'sneakers/runner'
13
+ require 'sneakers/handlers/maxretry'
13
14
 
14
15
  Sneakers.configure(config[:sneakers])
15
16
 
@@ -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
- private
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,5 +1,5 @@
1
1
  module Appfuel
2
2
  module Service
3
- VERSION = "0.2.11"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
@@ -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 = create_request(msg, delivery_info, properties)
39
+ request = create_request(msg, delivery_info, properties)
42
40
  rescue => e
43
- error_msg = "[queue worker] failed to create request " + e.message
44
- logger.error error_msg
45
- if properties.correlation_id && properties.reply_to
46
- request = create_request('{}', delivery_info, properties)
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
- return reject!
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
- logger = container[:logger]
57
- logger.error response.error_messages
54
+ msg_line = response.error_messages.join(' ')
55
+ logger.error "[#{request.action_route}] #{msg_line}"
58
56
  end
59
57
 
60
- if request.rpc?
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.11
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-15 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appfuel