racecar 0.4.2 → 0.5.0.beta1

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: c45d8677d5b6355960cdef16cddc745909b28145bb3243cfa64170f6f284609a
4
- data.tar.gz: dfed28e1acb40d781aedc6c0ae1d6d916b04efa48919cad6a05c4310720fee0b
3
+ metadata.gz: 5806641d4fcbd87d7625458de4ed60b19db3b4a8695d52dc062c72e1db281136
4
+ data.tar.gz: '08f9d6c439bcbc97bc05bcffb37d97b6eaf3b0a375deb85d1ad33dd2c004c9f7'
5
5
  SHA512:
6
- metadata.gz: 5a8f1c5077c03fb3dcca7124d6465ba6386f5a9a0dbe7ef5bf752073c58f04cc36c2665c1b5595b692289dfacddbb83e5cc022f07fbf05fc83dfcca266e743fb
7
- data.tar.gz: 75dc3b0d158f0a4b8fb8a8242dc7f4b2c043217792f6351a27d2a8698361e7e86fe04315a4b167202eb1703045b58183533019ef9dd48563db954c076ddb4b01
6
+ metadata.gz: 18b8f848e4830f538b679cb3301f9bdcff36f0ccf4a4dfd0b7edc125aaa4a738164dd879d10366878ca3b74876506471809880d5ce23a607e22c8fcf0de1768d
7
+ data.tar.gz: 32af67f7bafd1320423e60f18895e2264c8fe623a1ff3ef96d457255c286a795dcee35ed83e1dd6b581baa14f9defc889757daedaf516623f46e7a7273d98a10
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## racecar v0.5.0
6
+
7
+ * Add support for manually sending heartbeats with `heartbeat` (#105).
8
+
5
9
  ## racecar v0.4.2
6
10
 
7
11
  * Allow configuring `max_bytes` and `max_fetch_queue_size`.
data/README.md CHANGED
@@ -147,6 +147,32 @@ end
147
147
 
148
148
  An important detail is that, if an exception is raised while processing a batch, the _whole batch_ is re-processed.
149
149
 
150
+ #### Message headers
151
+
152
+ Any headers set on the message will be available when consuming the message:
153
+
154
+ ```ruby
155
+ message.headers #=> { "Header-A" => 42, ... }
156
+ ```
157
+
158
+ #### Heartbeats
159
+
160
+ In order to avoid your consumer being kicked out of its group during long-running message processing operations, it may be a good idea to periodically send so-called _heartbeats_ back to Kafka. This is done automatically for you after each message has been processed, but if the processing of a _single_ message takes a long time you may run into group stability issues.
161
+
162
+ If possible, intersperse `heartbeat` calls in between long-running operations in your consumer, e.g.
163
+
164
+ ```ruby
165
+ def process(message)
166
+ long_running_op_one(message)
167
+
168
+ # Signals back to Kafka that we're still alive!
169
+ heartbeat
170
+
171
+ long_running_op_two(message)
172
+ end
173
+ ```
174
+
175
+
150
176
  #### Tearing down resources when stopping
151
177
 
152
178
  When a Racecar consumer shuts down, it gets the opportunity to tear down any resources held by the consumer instance. For example, it may make sense to close any open files or network connections. Doing so is simple: just implement a `#teardown` method in your consumer class and it will be called during the shutdown procedure.
@@ -203,6 +229,8 @@ class GeoCodingConsumer < Racecar::Consumer
203
229
  end
204
230
  ```
205
231
 
232
+ You can set message headers by passing a `headers:` option with a Hash of headers.
233
+
206
234
  ### Configuration
207
235
 
208
236
  Racecar provides a flexible way to configure your consumer in a way that feels at home in a Rails application. If you haven't already, run `bundle exec rails generate racecar:install` in order to generate a config file. You'll get a separate section for each Rails environment, with the common configuration values in a shared `common` section.
@@ -227,6 +255,11 @@ end
227
255
  * `group_id` – The group id to use for a given group of consumers. Note that this _must_ be different for each consumer class. If left blank a group id is generated based on the consumer class name.
228
256
  * `group_id_prefix` – A prefix used when generating consumer group names. For instance, if you set the prefix to be `kevin.` and your consumer class is named `BaconConsumer`, the resulting consumer group will be named `kevin.bacon_consumer`.
229
257
 
258
+ #### Logging
259
+
260
+ * `logfile` – A filename that log messages should be written to. Default is `nil`, which means logs will be written to standard output.
261
+ * `log_level` – The log level for the Racecar logs, one of `debug`, `info`, `warn`, or `error`. Default is `info`.
262
+
230
263
  #### Consumer checkpointing
231
264
 
232
265
  The consumers will checkpoint their positions from time to time in order to be able to recover from failures. This is called _committing offsets_, since it's done by tracking the offset reached in each partition being processed, and committing those offset numbers to the Kafka offset storage API. If you can tolerate more double-processing after a failure, you can increase the interval between commits in order to better performance. You can also do the opposite if you prefer less chance of double-processing.
@@ -253,7 +286,7 @@ Kafka is _really_ good at throwing data at consumers, so you may want to tune th
253
286
  Racecar uses ruby-kafka under the hood, which fetches messages from the Kafka brokers in a background thread. This thread pushes fetch responses, possible containing messages from many partitions, into a queue that is read by the processing thread (AKA your code). The main way to control the fetcher thread is to control the size of those responses and the size of the queue.
254
287
 
255
288
  * `max_bytes` — The maximum size of message sets returned from a single fetch request.
256
- * `max_fetch_queue_size` — The maximum number of fetch responses to keep in the queue.
289
+ * `max_fetch_queue_size` — The maximum number of fetch responses to keep in the queue. Once reached, the fetcher will back off until the queue gets back down under to limit.
257
290
 
258
291
  The memory usage limit is roughly estimated as `max_bytes * max_fetch_queue_size`, plus whatever your application uses.
259
292
 
@@ -372,7 +405,7 @@ Again, the recommended approach is to manage the processes using process manager
372
405
 
373
406
  ### Handling errors
374
407
 
375
- When processing messages from a Kafka topic, your code may encounter an error and raise an exception. The cause is typically on of two things:
408
+ When processing messages from a Kafka topic, your code may encounter an error and raise an exception. The cause is typically one of two things:
376
409
 
377
410
  1. The message being processed is somehow malformed or doesn't conform with the assumptions made by the processing code.
378
411
  2. You're using some external resource such as a database or a network API that is temporarily unavailable.
@@ -59,7 +59,7 @@ module Racecar
59
59
  string :logfile
60
60
 
61
61
  desc "The log level for the Racecar logs"
62
- string :log_level
62
+ string :log_level, default: "info"
63
63
 
64
64
  desc "A valid SSL certificate authority"
65
65
  string :ssl_ca_cert
@@ -28,7 +28,8 @@ module Racecar
28
28
  end
29
29
  end
30
30
 
31
- def configure(producer:)
31
+ def configure(consumer:, producer:)
32
+ @_consumer = consumer
32
33
  @_producer = producer
33
34
  end
34
35
 
@@ -36,6 +37,10 @@ module Racecar
36
37
 
37
38
  protected
38
39
 
40
+ def heartbeat
41
+ @_consumer.trigger_heartbeat
42
+ end
43
+
39
44
  def produce(value, **options)
40
45
  @_producer.produce(value, **options)
41
46
  end
@@ -10,8 +10,10 @@ module Racecar
10
10
  end
11
11
 
12
12
  def stop
13
- processor.teardown
14
- consumer.stop unless consumer.nil?
13
+ Thread.new do
14
+ processor.teardown
15
+ consumer.stop unless consumer.nil?
16
+ end.join
15
17
  end
16
18
 
17
19
  def run
@@ -64,7 +66,7 @@ module Racecar
64
66
  compression_codec: config.producer_compression_codec,
65
67
  )
66
68
 
67
- processor.configure(producer: producer)
69
+ processor.configure(consumer: consumer, producer: producer)
68
70
 
69
71
  begin
70
72
  if processor.respond_to?(:process)
@@ -1,3 +1,3 @@
1
1
  module Racecar
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0.beta1"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_runtime_dependency "king_konf", "~> 0.3.6"
23
+ spec.add_runtime_dependency "king_konf", "~> 0.3.7"
24
24
  spec.add_runtime_dependency "ruby-kafka", "~> 0.6"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.13"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: racecar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-06-07 00:00:00.000000000 Z
12
+ date: 2019-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: king_konf
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.3.6
20
+ version: 0.3.7
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.3.6
27
+ version: 0.3.7
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: ruby-kafka
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -135,9 +135,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ">="
138
+ - - ">"
139
139
  - !ruby/object:Gem::Version
140
- version: '0'
140
+ version: 1.3.1
141
141
  requirements: []
142
142
  rubyforge_project:
143
143
  rubygems_version: 2.7.6