phobos 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/config/phobos.yml.example +2 -0
- data/lib/phobos.rb +1 -2
- data/lib/phobos/actions/process_message.rb +1 -1
- data/lib/phobos/executor.rb +16 -9
- data/lib/phobos/listener.rb +8 -1
- data/lib/phobos/test/helper.rb +2 -4
- data/lib/phobos/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: 8f244c641277c9ee85b12ea07250670fba1a0e8c
|
4
|
+
data.tar.gz: 385b9b4dec2f3991b9a8d1345d1f838c4d1ce04d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e116a595f2d1de1881ff4c24b07b563c1f2798e28cc2af434b057b3b137fdd94b91bf44d767f4d138dd1b5114f2afba324c85b2eb1f8e4aba38173fb222ec9e1
|
7
|
+
data.tar.gz: 4359fba15e7de514376a5da2ab19c4796523c71155b9ea22a54317edae26c1ec9cfbcfefe5b3a856228aedcd405d1adb369ad21df1b72d8651becb7455aa0242
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
7
7
|
## UNRELEASED
|
8
8
|
|
9
|
+
## [1.7.1] - 2018-02-22
|
10
|
+
### Fixed
|
11
|
+
- Phobos overwrites ENV['RAILS_ENV'] with incorrect value #71
|
12
|
+
- Possible NoMethodError #force_encoding #63
|
13
|
+
- Phobos fails silently #66
|
14
|
+
### Added
|
15
|
+
- Add offset_retention_time to consumer options #62
|
16
|
+
|
9
17
|
## [1.7.0] - 2017-12-05
|
10
18
|
### Fixed
|
11
19
|
- Test are failing with ruby-kafka 0.5.0 #48
|
data/config/phobos.yml.example
CHANGED
@@ -70,6 +70,8 @@ consumer:
|
|
70
70
|
# number of messages that can be processed before their offsets are committed.
|
71
71
|
# If zero, offset commits are not triggered by message processing
|
72
72
|
offset_commit_threshold: 0
|
73
|
+
# the time period that committed offsets will be retained, in seconds. Defaults to the broker setting.
|
74
|
+
offset_retention_time:
|
73
75
|
# interval between heartbeats; must be less than the session window
|
74
76
|
heartbeat_interval: 10
|
75
77
|
|
data/lib/phobos.rb
CHANGED
@@ -31,13 +31,12 @@ module Phobos
|
|
31
31
|
attr_accessor :silence_log
|
32
32
|
|
33
33
|
def configure(configuration)
|
34
|
-
ENV['RAILS_ENV'] = ENV['RACK_ENV'] ||= 'development'
|
35
34
|
@config = DeepStruct.new(fetch_settings(configuration))
|
36
35
|
@config.class.send(:define_method, :producer_hash) { Phobos.config.producer&.to_hash }
|
37
36
|
@config.class.send(:define_method, :consumer_hash) { Phobos.config.consumer&.to_hash }
|
38
37
|
@config.listeners ||= []
|
39
38
|
configure_logger
|
40
|
-
logger.info { Hash(message: 'Phobos configured', env: ENV['RACK_ENV']) }
|
39
|
+
logger.info { Hash(message: 'Phobos configured', env: ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'N/A') }
|
41
40
|
end
|
42
41
|
|
43
42
|
def add_listeners(listeners_configuration)
|
data/lib/phobos/executor.rb
CHANGED
@@ -18,9 +18,9 @@ module Phobos
|
|
18
18
|
@threads = Concurrent::Array.new
|
19
19
|
@listeners = Phobos.config.listeners.flat_map do |config|
|
20
20
|
handler_class = config.handler.constantize
|
21
|
-
listener_configs = config.to_hash
|
21
|
+
listener_configs = config.to_hash.deep_symbolize_keys
|
22
22
|
max_concurrency = listener_configs[:max_concurrency] || 1
|
23
|
-
max_concurrency.
|
23
|
+
Array.new(max_concurrency).map do
|
24
24
|
configs = listener_configs.select { |k| LISTENER_OPTS.include?(k) }
|
25
25
|
Phobos::Listener.new(configs.merge(handler: handler_class))
|
26
26
|
end
|
@@ -48,7 +48,7 @@ module Phobos
|
|
48
48
|
return if @signal_to_stop
|
49
49
|
instrument('executor.stop') do
|
50
50
|
@signal_to_stop = true
|
51
|
-
@listeners.
|
51
|
+
@listeners.each(&:stop)
|
52
52
|
@threads.select(&:alive?).each { |thread| thread.wakeup rescue nil }
|
53
53
|
@thread_pool&.shutdown
|
54
54
|
@thread_pool&.wait_for_termination
|
@@ -58,6 +58,14 @@ module Phobos
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
+
def error_metadata(e)
|
62
|
+
{
|
63
|
+
exception_class: e.class.name,
|
64
|
+
exception_message: e.message,
|
65
|
+
backtrace: e.backtrace
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
61
69
|
def run_listener(listener)
|
62
70
|
retry_count = 0
|
63
71
|
backoff = listener.create_exponential_backoff
|
@@ -74,11 +82,8 @@ module Phobos
|
|
74
82
|
metadata = {
|
75
83
|
listener_id: listener.id,
|
76
84
|
retry_count: retry_count,
|
77
|
-
waiting_time: interval
|
78
|
-
|
79
|
-
exception_message: e.message,
|
80
|
-
backtrace: e.backtrace
|
81
|
-
}
|
85
|
+
waiting_time: interval
|
86
|
+
}.merge(error_metadata(e))
|
82
87
|
|
83
88
|
instrument('executor.retry_listener_error', metadata) do
|
84
89
|
Phobos.logger.error { Hash(message: "Listener crashed, waiting #{interval}s (#{e.message})").merge(metadata)}
|
@@ -88,7 +93,9 @@ module Phobos
|
|
88
93
|
retry_count += 1
|
89
94
|
retry unless @signal_to_stop
|
90
95
|
end
|
96
|
+
rescue Exception => e
|
97
|
+
Phobos.logger.error { Hash(message: "Failed to run listener (#{e.message})").merge(error_metadata(e)) }
|
98
|
+
raise e
|
91
99
|
end
|
92
|
-
|
93
100
|
end
|
94
101
|
end
|
data/lib/phobos/listener.rb
CHANGED
@@ -2,7 +2,14 @@ module Phobos
|
|
2
2
|
class Listener
|
3
3
|
include Phobos::Instrumentation
|
4
4
|
|
5
|
-
KAFKA_CONSUMER_OPTS = %i(
|
5
|
+
KAFKA_CONSUMER_OPTS = %i(
|
6
|
+
session_timeout
|
7
|
+
offset_commit_interval
|
8
|
+
offset_commit_threshold
|
9
|
+
heartbeat_interval
|
10
|
+
offset_retention_time
|
11
|
+
).freeze
|
12
|
+
|
6
13
|
DEFAULT_MAX_BYTES_PER_PARTITION = 1048576 # 1 MB
|
7
14
|
DELIVERY_OPTS = %w[batch message].freeze
|
8
15
|
|
data/lib/phobos/test/helper.rb
CHANGED
@@ -13,11 +13,9 @@ module Phobos
|
|
13
13
|
)
|
14
14
|
|
15
15
|
message = Kafka::FetchedMessage.new(
|
16
|
-
value: payload,
|
17
|
-
key: nil,
|
16
|
+
message: Kafka::Protocol::Message.new(value: payload, key: nil, offset: 13),
|
18
17
|
topic: TOPIC,
|
19
|
-
partition: 0
|
20
|
-
offset: 13,
|
18
|
+
partition: 0
|
21
19
|
)
|
22
20
|
|
23
21
|
Phobos::Actions::ProcessMessage.new(
|
data/lib/phobos/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phobos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Túlio Ornelas
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date:
|
17
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: bundler
|