karafka 1.2.0.beta4 → 1.2.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
  SHA256:
3
- metadata.gz: e7df4ccab5fe5e942f4d97bdcb099ed1f754e3902c52775f9272e0f351c879ff
4
- data.tar.gz: 73417de830c717ab59a74375091d45c43308c58b43fd00bdc7bd579b6f2ded6b
3
+ metadata.gz: 0bb0a1f72768ebf4bf720ebda57ebc26a0178275adabffd494b24e1612e9b38a
4
+ data.tar.gz: f586038a0498227e8a287cc173a23e77bb99b6cb8d453c39be55a220e2a0d361
5
5
  SHA512:
6
- metadata.gz: 37cfeeb29cf0728d21e1dcd269c0432ec972bd6cc0b08f690fa49c3e2026ab2b8d2c558229c227dded52ee8a631859a17757422041fdce3ad424993573a5e6ac
7
- data.tar.gz: 85061228901bdced44d5cf699d10ceb51a0bc818d39fdbcbd1f24b667d75d459f405262ca9036e63357637850d7084da8e71429808e6fd6f094cfbb82f581f05
6
+ metadata.gz: e2b862da6372bc91f76bc01c20eb21ccde9d61d67749ccce97eadd2f739484dbd68a149d08d6e275d94d95b6ce9610d86c2d01e85bb1841a80e048ed832810ac
7
+ data.tar.gz: 06fb89700e59f810ec984b54f0424cfdeb98c79e17b8629010f011e68edff5fa1e345576a7b28ed07aff440739ed11824016da6083601a92b8f83fcca68e576e
@@ -1,6 +1,6 @@
1
1
  # Karafka framework changelog
2
2
 
3
- ## 1.2.0.beta4
3
+ ## 1.2.0
4
4
  - Spec improvements
5
5
  - #260 - Specs missing randomization
6
6
  - #251 - Shutdown upon non responding (unreachable) cluster is not possible
@@ -17,6 +17,7 @@
17
17
  - #184 - Seek to
18
18
  - #284 - Dynamic Params parent class
19
19
  - #275 - ssl_ca_certs_from_system
20
+ - #296 - Instrument forceful exit with an error
20
21
  - Replaced some of the activesupport parts with dry-inflector
21
22
  - Lower ActiveSupport dependency
22
23
  - Remove configurators in favor of the after_init block configurator
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (1.2.0.beta4)
4
+ karafka (1.2.0)
5
5
  activesupport (>= 4.0)
6
6
  dry-configurable (~> 0.7)
7
7
  dry-inflector (~> 0.1.1)
@@ -28,13 +28,13 @@ GEM
28
28
  king_konf (~> 0.1.8)
29
29
  ruby-kafka (~> 0.5.1)
30
30
  diff-lcs (1.3)
31
- docile (1.1.5)
31
+ docile (1.3.0)
32
32
  dry-configurable (0.7.0)
33
33
  concurrent-ruby (~> 1.0)
34
34
  dry-container (0.6.0)
35
35
  concurrent-ruby (~> 1.0)
36
36
  dry-configurable (~> 0.1, >= 0.1.3)
37
- dry-core (0.4.4)
37
+ dry-core (0.4.5)
38
38
  concurrent-ruby (~> 1.0)
39
39
  dry-equalizer (0.2.0)
40
40
  dry-events (0.1.0)
@@ -66,8 +66,8 @@ GEM
66
66
  dry-equalizer (~> 0.2)
67
67
  dry-logic (~> 0.4, >= 0.4.0)
68
68
  dry-types (~> 0.12.0)
69
- envlogic (1.0.4)
70
- activesupport
69
+ envlogic (1.1.0)
70
+ dry-inflector (~> 0.1)
71
71
  i18n (0.9.5)
72
72
  concurrent-ruby (~> 1.0)
73
73
  inflecto (0.0.2)
@@ -75,8 +75,8 @@ GEM
75
75
  king_konf (0.1.10)
76
76
  minitest (5.11.3)
77
77
  multi_json (1.13.1)
78
- null-logger (0.1.4)
79
- rake (12.3.0)
78
+ null-logger (0.1.5)
79
+ rake (12.3.1)
80
80
  require_all (2.0.0)
81
81
  rouge (2.2.1)
82
82
  rspec (3.7.0)
@@ -92,9 +92,9 @@ GEM
92
92
  diff-lcs (>= 1.2.0, < 2.0)
93
93
  rspec-support (~> 3.7.0)
94
94
  rspec-support (3.7.1)
95
- ruby-kafka (0.5.3)
96
- simplecov (0.15.1)
97
- docile (~> 1.1.0)
95
+ ruby-kafka (0.5.4)
96
+ simplecov (0.16.1)
97
+ docile (~> 1.1)
98
98
  json (>= 1.8, < 3)
99
99
  simplecov-html (~> 0.10.0)
100
100
  simplecov-html (0.10.2)
data/README.md CHANGED
@@ -8,7 +8,7 @@ Karafka allows you to capture everything that happens in your systems in large s
8
8
 
9
9
  Karafka not only handles incoming messages but also provides tools for building complex data-flow applications that receive and send messages.
10
10
 
11
- **Warning**: Wiki and all the docs refer to the 1.2.0.beta2. Sorry for the inconvenience. We will release the stable 1.2.0 version soon.
11
+ **Warning**: Wiki and all the docs refer to the 1.2.0.beta4. Sorry for the inconvenience. We will release the stable 1.2.0 version soon.
12
12
 
13
13
  ## How does it work
14
14
 
@@ -31,21 +31,25 @@ module Karafka
31
31
  # always yield an array of messages, so we have consistent API (always a batch)
32
32
  kafka_consumer.each_message(*settings) { |message| yield([message]) }
33
33
  end
34
- rescue Kafka::ProcessingError => e
34
+ rescue Kafka::ProcessingError => error
35
35
  # If there was an error during consumption, we have to log it, pause current partition
36
36
  # and process other things
37
37
  Karafka.monitor.instrument(
38
38
  'connection.client.fetch_loop.error',
39
39
  caller: self,
40
- error: e.cause
40
+ error: error.cause
41
41
  )
42
- pause(e.topic, e.partition)
42
+ pause(error.topic, error.partition)
43
43
  retry
44
44
  # This is on purpose - see the notes for this method
45
45
  # rubocop:disable RescueException
46
- rescue Exception => e
46
+ rescue Exception => error
47
47
  # rubocop:enable RescueException
48
- Karafka.monitor.instrument('connection.client.fetch_loop.error', caller: self, error: e)
48
+ Karafka.monitor.instrument(
49
+ 'connection.client.fetch_loop.error',
50
+ caller: self,
51
+ error: error
52
+ )
49
53
  retry
50
54
  end
51
55
 
@@ -86,6 +86,21 @@ module Karafka
86
86
  info "Responded from #{calling} using #{responder} with following data #{data}"
87
87
  end
88
88
 
89
+ # Logs info that we're going to stop the Karafka server
90
+ # @param _event [Dry::Events::Event] event details including payload
91
+ def on_server_stop(_event)
92
+ # We use a separate thread as logging can't be called from trap context
93
+ Thread.new { info "Stopping Karafka server #{::Process.pid}" }
94
+ end
95
+
96
+ # Logs an error that Karafka was unable to stop the server gracefully and it had to do a
97
+ # forced exit
98
+ # @param _event [Dry::Events::Event] event details including payload
99
+ def on_server_stop_error(_event)
100
+ # We use a separate thread as logging can't be called from trap context
101
+ Thread.new { error "Forceful Karafka server #{::Process.pid} stop" }
102
+ end
103
+
89
104
  USED_LOG_LEVELS.each do |log_level|
90
105
  define_method log_level do |*args|
91
106
  Karafka.logger.send(log_level, *args)
@@ -34,6 +34,8 @@ module Karafka
34
34
  async_producer.call.retry
35
35
  sync_producer.call.error
36
36
  sync_producer.call.retry
37
+ server.stop
38
+ server.stop.error
37
39
  ].freeze
38
40
 
39
41
  private_constant :BASE_EVENTS
@@ -67,8 +67,9 @@ module Karafka
67
67
  # Stops Karafka with a supervision (as long as there is a shutdown timeout)
68
68
  # If consumers won't stop in a given timeframe, it will force them to exit
69
69
  def stop_supervised
70
- Karafka::App.stop!
70
+ Karafka.monitor.instrument('server.stop', {})
71
71
 
72
+ Karafka::App.stop!
72
73
  # If there is no shutdown timeout, we don't exit and wait until all the consumers
73
74
  # had done their work
74
75
  return unless Karafka::App.config.shutdown_timeout
@@ -81,8 +82,11 @@ module Karafka
81
82
  sleep SUPERVISION_SLEEP
82
83
  end
83
84
 
85
+ Karafka.monitor.instrument('server.stop.error', {})
84
86
  # We're done waiting, lets kill them!
85
87
  consumer_threads.each(&:terminate)
88
+
89
+ # exit is not within the instrumentation as it would not trigger due to exit
86
90
  Kernel.exit FORCEFUL_EXIT_CODE
87
91
  end
88
92
  end
@@ -19,6 +19,8 @@ class KarafkaApp < Karafka::App
19
19
  config.client_id = 'example_app'
20
20
  config.backend = :inline
21
21
  config.batch_fetching = true
22
+ # Uncomment this for Rails app integration
23
+ # config.logger = Rails.logger
22
24
  end
23
25
 
24
26
  after_init do |config|
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '1.2.0.beta4'
6
+ VERSION = '1.2.0'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-03-08 00:00:00.000000000 Z
13
+ date: 2018-03-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -289,9 +289,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
289
289
  version: 2.3.0
290
290
  required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  requirements:
292
- - - ">"
292
+ - - ">="
293
293
  - !ruby/object:Gem::Version
294
- version: 1.3.1
294
+ version: '0'
295
295
  requirements: []
296
296
  rubyforge_project:
297
297
  rubygems_version: 2.7.6