phobos 1.6.1 → 1.7.0

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: 6e7de0ef712ba1636a2c66ceb7fbfa159e479c87
4
- data.tar.gz: 5bbaa97f07e0f6aa5825b49220daa2f6cac239dd
3
+ metadata.gz: aa6ceb9067bc80835a1460e43cbe613f7fdaaa23
4
+ data.tar.gz: 43281f6ada2fe5b824da9cc236d56523c58cee02
5
5
  SHA512:
6
- metadata.gz: 3ffa62ee7edcd651dabc33fa6f3bfc96cf3ab30076b49254d89e1c6f0443843159022945c483126fa3e0d5ac8674526a350693405448b327681d0752dc281b31
7
- data.tar.gz: aaf894ba3a7ac6c5c01d1b06ee621995fecd5bd0ed368bc28235bdd2a756b55fcb9d7f8955987429e8ed3ae850dc231c4d43ef6fb08e5c611685caf4929729bb
6
+ metadata.gz: ad5569add3dd9748cb746943816285d3518052dbc148b2102975b60744782081afc81c5d520f7ca80e090505b4c6b592b49959aa8d22820367f799739d4c2e7d
7
+ data.tar.gz: 2e110cdba90db10a6c0cf4a51bee1f8bdf31ea1090f303d44d817654d6c8dd14837eba52a6a83419e35c31a385a3dc01a083df16142128805adc9e5d5d65b29c
data/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## UNRELEASED
8
8
 
9
+ ## [1.7.0] - 2017-12-05
10
+ ### Fixed
11
+ - Test are failing with ruby-kafka 0.5.0 #48
12
+ - Allow Phobos to run in apps using ActiveSupport 3.x #57
13
+ ### Added
14
+ - Property (handler) added to listener instrumentation #60
15
+ ### Removed
16
+ - Property (time_elapsed) removed - use duration instead #24
17
+ ### Changed
18
+ - Max bytes per partition is now 1 MB by default #56
19
+
9
20
  ## [1.6.1] - 2017-11-16
10
21
  ### Fixed
11
22
  - `Phobos::Test::Helper` is broken #53
data/README.md CHANGED
@@ -378,32 +378,35 @@ end
378
378
  * listener_id
379
379
  * group_id
380
380
  * topic
381
+ * handler
381
382
  * `listener.start` is sent when listener starts. It includes the following payload:
382
383
  * listener_id
383
384
  * group_id
384
385
  * topic
386
+ * handler
385
387
  * `listener.process_batch` is sent after process a batch. It includes the following payload:
386
388
  * listener_id
387
389
  * group_id
388
390
  * topic
391
+ * handler
389
392
  * batch_size
390
393
  * partition
391
394
  * offset_lag
392
395
  * highwater_mark_offset
393
- * time_elapsed
394
396
  * `listener.process_message` is sent after process a message. It includes the following payload:
395
397
  * listener_id
396
398
  * group_id
397
399
  * topic
400
+ * handler
398
401
  * key
399
402
  * partition
400
403
  * offset
401
404
  * retry_count
402
- * time_elapsed
403
405
  * `listener.retry_handler_error` is sent after waited for `handler#consume` retry. It includes the following payload:
404
406
  * listener_id
405
407
  * group_id
406
408
  * topic
409
+ * handler
407
410
  * key
408
411
  * partition
409
412
  * offset
@@ -416,18 +419,22 @@ end
416
419
  * listener_id
417
420
  * group_id
418
421
  * topic
422
+ * handler
419
423
  * `listener.stopping` is sent when the listener receives signal to stop
420
424
  * listener_id
421
425
  * group_id
422
426
  * topic
427
+ * handler
423
428
  * `listener.stop_handler` is sent after stopping the handler
424
429
  * listener_id
425
430
  * group_id
426
431
  * topic
432
+ * handler
427
433
  * `listener.stop` is send after stopping the listener
428
434
  * listener_id
429
435
  * group_id
430
436
  * topic
437
+ * handler
431
438
 
432
439
  ## <a name="plugins"></a> Plugins
433
440
 
@@ -438,6 +445,15 @@ List of gems that enhance Phobos:
438
445
  * Ensures that your handler will consume messages only once
439
446
  * Allows your system to quickly reprocess events in case of failures
440
447
 
448
+ * [Phobos Checkpoint UI](https://github.com/klarna/phobos_checkpoint_ui) gives your Phobos DB Checkpoint powered app a web gui with the features below. Maintaining a Kafka consumer app has never been smoother:
449
+ * Search events and inspect payload
450
+ * See failures and retry / delete them
451
+
452
+ * [Phobos Prometheus](https://github.com/phobos/phobos_prometheus) adds prometheus metrics to your phobos consumer.
453
+ * Measures total messages and batches processed
454
+ * Measures total duration needed to process each message (and batch)
455
+ * Adds `/metrics` endpoit to scrape data
456
+
441
457
  ## <a name="development"></a> Development
442
458
 
443
459
  After checking out the repo:
@@ -18,17 +18,13 @@ module Phobos
18
18
 
19
19
  def execute
20
20
  instrument('listener.process_batch', @metadata) do |metadata|
21
- time_elapsed = measure do
22
- @batch.messages.each do |message|
23
- Phobos::Actions::ProcessMessage.new(
24
- listener: @listener,
25
- message: message,
26
- listener_metadata: @listener_metadata
27
- ).execute
28
- end
21
+ @batch.messages.each do |message|
22
+ Phobos::Actions::ProcessMessage.new(
23
+ listener: @listener,
24
+ message: message,
25
+ listener_metadata: @listener_metadata
26
+ ).execute
29
27
  end
30
-
31
- metadata.merge!(time_elapsed: time_elapsed)
32
28
  end
33
29
  end
34
30
  end
@@ -8,7 +8,6 @@ module Phobos
8
8
  def initialize(listener:, message:, listener_metadata:)
9
9
  @listener = listener
10
10
  @message = message
11
- @listener_metadata = listener_metadata
12
11
  @metadata = listener_metadata.merge(
13
12
  key: message.key,
14
13
  partition: message.partition,
@@ -56,20 +55,13 @@ module Phobos
56
55
  end
57
56
 
58
57
  def process_message(payload)
59
- instrument('listener.process_message', @metadata) do |metadata|
60
- consume_result = nil
61
- time_elapsed = measure do
62
- handler = @listener.handler_class.new
63
- preprocessed_payload = handler.before_consume(payload)
58
+ instrument('listener.process_message', @metadata) do
59
+ handler = @listener.handler_class.new
60
+ preprocessed_payload = handler.before_consume(payload)
64
61
 
65
- @listener.handler_class.around_consume(preprocessed_payload, @metadata) do
66
- consume_result = handler.consume(preprocessed_payload, @metadata)
67
- end
62
+ @listener.handler_class.around_consume(preprocessed_payload, @metadata) do
63
+ handler.consume(preprocessed_payload, @metadata)
68
64
  end
69
-
70
- metadata.merge!(time_elapsed: time_elapsed)
71
-
72
- consume_result
73
65
  end
74
66
  end
75
67
  end
data/lib/phobos/cli.rb CHANGED
@@ -41,21 +41,21 @@ module Phobos
41
41
  end
42
42
 
43
43
  desc 'start', 'Starts Phobos'
44
- option :config,
45
- aliases: ['-c'],
46
- default: 'config/phobos.yml',
47
- banner: 'Configuration file'
48
- option :boot,
49
- aliases: ['-b'],
50
- banner: 'File path to load application specific code',
51
- default: 'phobos_boot.rb'
52
- option :listeners,
53
- aliases: ['-l'],
54
- banner: 'Separate listeners config file (optional)'
55
- option :skip_config,
56
- default: false,
57
- type: :boolean,
58
- banner: 'Skip config file'
44
+ method_option :config,
45
+ aliases: ['-c'],
46
+ default: 'config/phobos.yml',
47
+ banner: 'Configuration file'
48
+ method_option :boot,
49
+ aliases: ['-b'],
50
+ banner: 'File path to load application specific code',
51
+ default: 'phobos_boot.rb'
52
+ method_option :listeners,
53
+ aliases: ['-l'],
54
+ banner: 'Separate listeners config file (optional)'
55
+ method_option :skip_config,
56
+ default: false,
57
+ type: :boolean,
58
+ banner: 'Skip config file'
59
59
  def start
60
60
  Phobos::CLI::Start.new(options).execute
61
61
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/notifications'
2
+
1
3
  module Phobos
2
4
  module Instrumentation
3
5
  NAMESPACE = 'phobos'
@@ -17,11 +19,5 @@ module Phobos
17
19
  yield(extra) if block_given?
18
20
  end
19
21
  end
20
-
21
- def measure
22
- start = Time.now.utc
23
- yield if block_given?
24
- (Time.now.utc - start).round(3)
25
- end
26
22
  end
27
23
  end
@@ -3,7 +3,7 @@ module Phobos
3
3
  include Phobos::Instrumentation
4
4
 
5
5
  KAFKA_CONSUMER_OPTS = %i(session_timeout offset_commit_interval offset_commit_threshold heartbeat_interval).freeze
6
- DEFAULT_MAX_BYTES_PER_PARTITION = 524288 # 512 KB
6
+ DEFAULT_MAX_BYTES_PER_PARTITION = 1048576 # 1 MB
7
7
  DELIVERY_OPTS = %w[batch message].freeze
8
8
 
9
9
  attr_reader :group_id, :topic, :id
@@ -124,7 +124,7 @@ module Phobos
124
124
  private
125
125
 
126
126
  def listener_metadata
127
- { listener_id: id, group_id: group_id, topic: topic }
127
+ { listener_id: id, group_id: group_id, topic: topic, handler: handler_class.to_s }
128
128
  end
129
129
 
130
130
  def create_kafka_consumer
@@ -1,3 +1,3 @@
1
1
  module Phobos
2
- VERSION = '1.6.1'
2
+ VERSION = '1.7.0'
3
3
  end
data/phobos.gemspec CHANGED
@@ -51,10 +51,10 @@ Gem::Specification.new do |spec|
51
51
  spec.add_development_dependency 'simplecov'
52
52
  spec.add_development_dependency 'timecop'
53
53
 
54
- spec.add_dependency 'ruby-kafka', '>= 0.3.14', '< 0.5.0'
54
+ spec.add_dependency 'ruby-kafka', '>= 0.3.14'
55
55
  spec.add_dependency 'concurrent-ruby', '>= 1.0.2'
56
56
  spec.add_dependency 'concurrent-ruby-ext', '>= 1.0.2'
57
- spec.add_dependency 'activesupport', '>= 4.0.0'
57
+ spec.add_dependency 'activesupport', '>= 3.0.0'
58
58
  spec.add_dependency 'logging'
59
59
  spec.add_dependency 'exponential-backoff'
60
60
  spec.add_dependency 'thor'
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.6.1
4
+ version: 1.7.0
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: 2017-11-16 00:00:00.000000000 Z
17
+ date: 2017-12-05 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: bundler
@@ -107,9 +107,6 @@ dependencies:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: 0.3.14
110
- - - "<"
111
- - !ruby/object:Gem::Version
112
- version: 0.5.0
113
110
  type: :runtime
114
111
  prerelease: false
115
112
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,9 +114,6 @@ dependencies:
117
114
  - - ">="
118
115
  - !ruby/object:Gem::Version
119
116
  version: 0.3.14
120
- - - "<"
121
- - !ruby/object:Gem::Version
122
- version: 0.5.0
123
117
  - !ruby/object:Gem::Dependency
124
118
  name: concurrent-ruby
125
119
  requirement: !ruby/object:Gem::Requirement
@@ -154,14 +148,14 @@ dependencies:
154
148
  requirements:
155
149
  - - ">="
156
150
  - !ruby/object:Gem::Version
157
- version: 4.0.0
151
+ version: 3.0.0
158
152
  type: :runtime
159
153
  prerelease: false
160
154
  version_requirements: !ruby/object:Gem::Requirement
161
155
  requirements:
162
156
  - - ">="
163
157
  - !ruby/object:Gem::Version
164
- version: 4.0.0
158
+ version: 3.0.0
165
159
  - !ruby/object:Gem::Dependency
166
160
  name: logging
167
161
  requirement: !ruby/object:Gem::Requirement