racecar 0.5.0.beta1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +16 -0
- data/README.md +43 -4
- data/exe/racecar +0 -2
- data/lib/racecar.rb +4 -0
- data/lib/racecar/cli.rb +16 -7
- data/lib/racecar/config.rb +9 -0
- data/lib/racecar/runner.rb +2 -0
- data/lib/racecar/version.rb +1 -1
- data/racecar.gemspec +2 -2
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4be479ec5ba06da85a4e862849154a75adad8d6a41ca100f702f3dde4948bea8
|
4
|
+
data.tar.gz: 23824056ce3ca58258dd125daef3ffdae3a29f04e2f10987d2d20ef6e1a1a7fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ddba5fa6de0bb0002cf90a19923314f0f6003c0cc175160a98efaf53888160d47bf432cfad97bd49d261ac52730974e528edd612671d03ba4d8e1ecb52b14fc
|
7
|
+
data.tar.gz: 487fd52700aa79902ddc1a160cc2fdb38dabb2b2d4d3f3204d0b716ad5f1460554385d4f0abc3f35f60e38ad61855a828075db3901fc0abeb8cfcfec9be18550
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,25 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## racecar v1.1.0
|
6
|
+
|
7
|
+
* Require ruby-kafka v1.0 or higher.
|
8
|
+
* Add error handling for required libraries (#149).
|
9
|
+
|
10
|
+
## racecar v1.0.1
|
11
|
+
|
12
|
+
* Add `--without-rails` option to boot consumer without Rails (#139).
|
13
|
+
|
14
|
+
## racecar v1.0.0
|
15
|
+
|
16
|
+
Unchanged from v0.5.0.
|
17
|
+
|
5
18
|
## racecar v0.5.0
|
6
19
|
|
7
20
|
* Add support for manually sending heartbeats with `heartbeat` (#105).
|
21
|
+
* Allow configuring `sasl_over_ssl`.
|
22
|
+
* Add current directory to `$LOAD_PATH` only when `--require` option is used (#117).
|
23
|
+
* Support for `ssl_verify_hostname` in the configuration (#120)
|
8
24
|
|
9
25
|
## racecar v0.4.2
|
10
26
|
|
data/README.md
CHANGED
@@ -205,8 +205,6 @@ The first time you execute `racecar` with a consumer class a _consumer group_ wi
|
|
205
205
|
|
206
206
|
### Producing messages
|
207
207
|
|
208
|
-
**WARNING:** This is an alpha feature, and could cause weird and unpredictable errors. Use with caution.
|
209
|
-
|
210
208
|
Consumers can produce messages themselves, allowing for powerful stream processing applications that transform and filter message streams. The API for this is simple:
|
211
209
|
|
212
210
|
```ruby
|
@@ -252,8 +250,8 @@ end
|
|
252
250
|
|
253
251
|
* `brokers` – A list of Kafka brokers in the cluster that you're consuming from. Defaults to `localhost` on port 9092, the default Kafka port.
|
254
252
|
* `client_id` – A string used to identify the client in logs and metrics.
|
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
|
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.
|
253
|
+
* `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 such that (for example) a consumer with the class name `BaconConsumer` would default to a group id of `bacon-consumer`.
|
254
|
+
* `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`.
|
257
255
|
|
258
256
|
#### Logging
|
259
257
|
|
@@ -334,6 +332,9 @@ Racecar supports configuring ruby-kafka's [Datadog](https://www.datadoghq.com/)
|
|
334
332
|
* `datadog_namespace` – The namespace to use for Datadog metrics.
|
335
333
|
* `datadog_tags` – Tags that should always be set on Datadog metrics.
|
336
334
|
|
335
|
+
#### Consumers Without Rails ####
|
336
|
+
|
337
|
+
By default, if Rails is detected, it will be automatically started when the consumer is started. There are cases where you might not want or need Rails. You can pass the `--without-rails` option when starting the consumer and Rails won't be started.
|
337
338
|
|
338
339
|
### Testing consumers
|
339
340
|
|
@@ -385,6 +386,44 @@ If you've ever used Heroku you'll recognize the format – indeed, deploying to
|
|
385
386
|
|
386
387
|
With Foreman, you can easily run these processes locally by executing `foreman run`; in production you'll want to _export_ to another process management format such as Upstart or Runit. [capistrano-foreman](https://github.com/hyperoslo/capistrano-foreman) allows you to do this with Capistrano.
|
387
388
|
|
389
|
+
#### Deploying to Kubernetes
|
390
|
+
|
391
|
+
If you run your applications in Kubernetes, use the following [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) spec as a starting point:
|
392
|
+
|
393
|
+
```yaml
|
394
|
+
apiVersion: apps/v1
|
395
|
+
kind: Deployment
|
396
|
+
metadata:
|
397
|
+
name: my-racecar-deployment
|
398
|
+
labels:
|
399
|
+
app: my-racecar
|
400
|
+
spec:
|
401
|
+
replicas: 3 # <-- this will give us three consumers in the group.
|
402
|
+
selector:
|
403
|
+
matchLabels:
|
404
|
+
app: my-racecar
|
405
|
+
strategy:
|
406
|
+
type: Recreate # <-- this is the important part.
|
407
|
+
template:
|
408
|
+
metadata:
|
409
|
+
labels:
|
410
|
+
app: my-racecar
|
411
|
+
spec:
|
412
|
+
containers:
|
413
|
+
- name: my-racecar
|
414
|
+
image: my-racecar-image
|
415
|
+
command: ["bundle", "exec", "racecar", "MyConsumer"]
|
416
|
+
env: # <-- you can configure the consumer using environment variables!
|
417
|
+
- name: RACECAR_BROKERS
|
418
|
+
value: kafka1,kafka2,kafka3
|
419
|
+
- name: RACECAR_OFFSET_COMMIT_INTERVAL
|
420
|
+
value: 5
|
421
|
+
```
|
422
|
+
|
423
|
+
The important part is the `strategy.type` value, which tells Kubernetes how to upgrade from one version of your Deployment to another. Many services use so-called _rolling updates_, where some but not all containers are replaced with the new version. This is done so that, if the new version doesn't work, the old version is still there to serve most of the requests. For Kafka consumers, this doesn't work well. The reason is that every time a consumer joins or leaves a group, every other consumer in the group needs to stop and synchronize the list of partitions assigned to each group member. So if the group is updated in a rolling fashion, this synchronization would occur over and over again, causing undesirable double-processing of messages as consumers would start only to be synchronized shortly after.
|
424
|
+
|
425
|
+
Instead, the `Recreate` update strategy should be used. It completely tears down the existing containers before starting all of the new containers simultaneously, allowing for a single synchronization stage and a much faster, more stable deployment update.
|
426
|
+
|
388
427
|
|
389
428
|
#### Running consumers in the background
|
390
429
|
|
data/exe/racecar
CHANGED
data/lib/racecar.rb
CHANGED
data/lib/racecar/cli.rb
CHANGED
@@ -23,10 +23,10 @@ module Racecar
|
|
23
23
|
def run
|
24
24
|
$stderr.puts "=> Starting Racecar consumer #{consumer_name}..."
|
25
25
|
|
26
|
-
RailsConfigFileLoader.load!
|
26
|
+
RailsConfigFileLoader.load! unless config.without_rails?
|
27
27
|
|
28
28
|
if File.exist?("config/racecar.rb")
|
29
|
-
require "config/racecar"
|
29
|
+
require "./config/racecar"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Find the consumer class by name.
|
@@ -94,11 +94,20 @@ module Racecar
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def build_parser
|
97
|
+
load_path_modified = false
|
98
|
+
|
97
99
|
OptionParser.new do |opts|
|
98
100
|
opts.banner = "Usage: racecar MyConsumer [options]"
|
99
101
|
|
100
102
|
opts.on("-r", "--require STRING", "Require a library before starting the consumer") do |lib|
|
101
|
-
|
103
|
+
$LOAD_PATH.unshift(Dir.pwd) unless load_path_modified
|
104
|
+
load_path_modified = true
|
105
|
+
begin
|
106
|
+
require lib
|
107
|
+
rescue => e
|
108
|
+
$stderr.puts "=> #{lib} failed to load: #{e.message}"
|
109
|
+
exit
|
110
|
+
end
|
102
111
|
end
|
103
112
|
|
104
113
|
opts.on("-l", "--log STRING", "Log to the specified file") do |logfile|
|
@@ -143,10 +152,10 @@ module Racecar
|
|
143
152
|
require "kafka/datadog"
|
144
153
|
|
145
154
|
datadog = Kafka::Datadog
|
146
|
-
datadog.host = config.datadog_host
|
147
|
-
datadog.port = config.datadog_port
|
148
|
-
datadog.namespace = config.datadog_namespace
|
149
|
-
datadog.tags = config.datadog_tags
|
155
|
+
datadog.host = config.datadog_host unless config.datadog_host.nil?
|
156
|
+
datadog.port = config.datadog_port unless config.datadog_port.nil?
|
157
|
+
datadog.namespace = config.datadog_namespace unless config.datadog_namespace.nil?
|
158
|
+
datadog.tags = config.datadog_tags unless config.datadog_tags.nil?
|
150
159
|
end
|
151
160
|
end
|
152
161
|
end
|
data/lib/racecar/config.rb
CHANGED
@@ -100,6 +100,9 @@ module Racecar
|
|
100
100
|
desc "The SCRAM mechanism to use, either `sha256` or `sha512`"
|
101
101
|
string :sasl_scram_mechanism, allowed_values: ["sha256", "sha512"]
|
102
102
|
|
103
|
+
desc "Whether to use SASL over SSL."
|
104
|
+
boolean :sasl_over_ssl, default: true
|
105
|
+
|
103
106
|
desc "The file in which to store the Racecar process' PID when daemonized"
|
104
107
|
string :pidfile
|
105
108
|
|
@@ -124,6 +127,12 @@ module Racecar
|
|
124
127
|
desc "Tags that should always be set on Datadog metrics"
|
125
128
|
list :datadog_tags
|
126
129
|
|
130
|
+
desc "Whether to check the server certificate is valid for the hostname"
|
131
|
+
boolean :ssl_verify_hostname, default: true
|
132
|
+
|
133
|
+
desc "Whether to boot Rails when starting the consumer"
|
134
|
+
boolean :without_rails, default: false
|
135
|
+
|
127
136
|
# The error handler must be set directly on the object.
|
128
137
|
attr_reader :error_handler
|
129
138
|
|
data/lib/racecar/runner.rb
CHANGED
@@ -32,7 +32,9 @@ module Racecar
|
|
32
32
|
sasl_scram_username: config.sasl_scram_username,
|
33
33
|
sasl_scram_password: config.sasl_scram_password,
|
34
34
|
sasl_scram_mechanism: config.sasl_scram_mechanism,
|
35
|
+
sasl_over_ssl: config.sasl_over_ssl,
|
35
36
|
ssl_ca_certs_from_system: config.ssl_ca_certs_from_system,
|
37
|
+
ssl_verify_hostname: config.ssl_verify_hostname
|
36
38
|
)
|
37
39
|
|
38
40
|
@consumer = kafka.consumer(
|
data/lib/racecar/version.rb
CHANGED
data/racecar.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "king_konf", "~> 0.3.7"
|
24
|
-
spec.add_runtime_dependency "ruby-kafka", "~> 0
|
24
|
+
spec.add_runtime_dependency "ruby-kafka", "~> 1.0"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "
|
26
|
+
spec.add_development_dependency "bundler", [">= 1.13", "< 3"]
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
end
|
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:
|
4
|
+
version: 1.1.0
|
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:
|
12
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: king_konf
|
@@ -31,28 +31,34 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0
|
34
|
+
version: '1.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0
|
41
|
+
version: '1.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.13'
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '3'
|
49
52
|
type: :development
|
50
53
|
prerelease: false
|
51
54
|
version_requirements: !ruby/object:Gem::Requirement
|
52
55
|
requirements:
|
53
|
-
- - "
|
56
|
+
- - ">="
|
54
57
|
- !ruby/object:Gem::Version
|
55
58
|
version: '1.13'
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3'
|
56
62
|
- !ruby/object:Gem::Dependency
|
57
63
|
name: rake
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,9 +141,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
141
|
version: '0'
|
136
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
143
|
requirements:
|
138
|
-
- - "
|
144
|
+
- - ">="
|
139
145
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
146
|
+
version: '0'
|
141
147
|
requirements: []
|
142
148
|
rubyforge_project:
|
143
149
|
rubygems_version: 2.7.6
|