racecar 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +61 -0
- data/.gitignore +1 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +69 -0
- data/lib/racecar/config.rb +1 -1
- data/lib/racecar/consumer_set.rb +5 -2
- data/lib/racecar/message.rb +4 -1
- data/lib/racecar/runner.rb +5 -2
- data/lib/racecar/version.rb +1 -1
- data/racecar.gemspec +1 -1
- metadata +6 -5
- data/.github/workflows/rspec.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2c32338556d27bfcbae35df0758163a457d2c6e3f520141206c5a9c0124cc68
|
4
|
+
data.tar.gz: 43d9c42d0d483c269b15d417ef59e2985da3ca3945d34d6772f8dd262ccbfaf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0467ac1cdefb6cad9870dd73b92f4a5a943b9f685ff3fc876b3f183d109ae3d29d7c2c7dffea8f31bca7c7b18565e5aba04d4865c94f2448a7228be175855a5b
|
7
|
+
data.tar.gz: e4ab43eb180995af916d447b006438b4a48cb808b29aabec52b455e246541a083192d1b560a957fa6f3ab7d5412dd12ab74aac49acc0b606c3df87cec90b93b6
|
@@ -0,0 +1,61 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- '**'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
unit-specs:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ["2.5", "2.6"]
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: zendesk/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: zendesk/setup-ruby@v1.58.0
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
22
|
+
bundler-cache: true
|
23
|
+
- name: Build and test with RSpec
|
24
|
+
run: bundle exec rspec --format documentation --require spec_helper --color --exclude-pattern='spec/integration/*_spec.rb'
|
25
|
+
|
26
|
+
integration-specs:
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
|
29
|
+
services:
|
30
|
+
zookeeper:
|
31
|
+
image: confluentinc/cp-zookeeper
|
32
|
+
ports:
|
33
|
+
- 2181:2181
|
34
|
+
env:
|
35
|
+
ZOOKEEPER_CLIENT_PORT: 2181
|
36
|
+
|
37
|
+
kafka:
|
38
|
+
image: confluentinc/cp-kafka
|
39
|
+
ports:
|
40
|
+
- 9092:9092
|
41
|
+
- 29092:29092
|
42
|
+
options: --health-cmd "kafka-topics --list --bootstrap-server=localhost:9092" --health-interval 10s --health-timeout 5s --health-retries 5
|
43
|
+
env:
|
44
|
+
KAFKA_BROKER_ID: 1
|
45
|
+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
46
|
+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
|
47
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
48
|
+
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
49
|
+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
50
|
+
|
51
|
+
steps:
|
52
|
+
- uses: zendesk/checkout@v2
|
53
|
+
- name: Set up Ruby
|
54
|
+
uses: zendesk/setup-ruby@v1.58.0
|
55
|
+
with:
|
56
|
+
ruby-version: 2.7
|
57
|
+
bundler-cache: true
|
58
|
+
- name: Build and test with RSpec
|
59
|
+
env:
|
60
|
+
RACECAR_BROKERS: localhost:9092
|
61
|
+
run: bundle exec rspec --format documentation --require spec_helper --color spec/integration/*_spec.rb
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## racecar v2.2.0
|
6
|
+
|
7
|
+
* [Racecar::ConsumerSet] **breaking change** `Racecar::ConsumerSet`'s functions `poll` and `batch_pall` expect the max wait values to be given in milliseconds. The defaults were using `config.max_wait_time`, which is in seconds. If you do not directly use `Racecar::ConsumerSet`, or always call its `poll` and `batch_poll` functions by specfiying the max wait time (the first argument), then this breaking change does not affect you. ([#214](https://github.com/zendesk/racecar/pull/214))
|
8
|
+
|
5
9
|
## racecar v2.1.1
|
6
10
|
|
7
11
|
* [Bugfix] Close RdKafka consumer in ConsumerSet#reset_current_consumer to prevent memory leak (#196)
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
racecar (2.1.1)
|
5
|
+
king_konf (~> 1.0.0)
|
6
|
+
rdkafka (~> 0.8.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.0.3.4)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
17
|
+
coderay (1.1.3)
|
18
|
+
concurrent-ruby (1.1.7)
|
19
|
+
diff-lcs (1.4.4)
|
20
|
+
dogstatsd-ruby (4.8.2)
|
21
|
+
ffi (1.13.1)
|
22
|
+
i18n (1.8.5)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
king_konf (1.0.0)
|
25
|
+
method_source (1.0.0)
|
26
|
+
mini_portile2 (2.5.0)
|
27
|
+
minitest (5.14.2)
|
28
|
+
pry (0.13.1)
|
29
|
+
coderay (~> 1.1)
|
30
|
+
method_source (~> 1.0)
|
31
|
+
rake (13.0.1)
|
32
|
+
rdkafka (0.8.1)
|
33
|
+
ffi (~> 1.9)
|
34
|
+
mini_portile2 (~> 2.1)
|
35
|
+
rake (>= 12.3)
|
36
|
+
rspec (3.10.0)
|
37
|
+
rspec-core (~> 3.10.0)
|
38
|
+
rspec-expectations (~> 3.10.0)
|
39
|
+
rspec-mocks (~> 3.10.0)
|
40
|
+
rspec-core (3.10.0)
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-expectations (3.10.0)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-mocks (3.10.0)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-support (3.10.0)
|
49
|
+
thread_safe (0.3.6)
|
50
|
+
timecop (0.9.2)
|
51
|
+
tzinfo (1.2.8)
|
52
|
+
thread_safe (~> 0.1)
|
53
|
+
zeitwerk (2.4.2)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
activesupport (>= 4.0, < 6.1)
|
60
|
+
bundler (>= 1.13, < 3)
|
61
|
+
dogstatsd-ruby (>= 4.0.0, < 5.0.0)
|
62
|
+
pry
|
63
|
+
racecar!
|
64
|
+
rake (> 10.0)
|
65
|
+
rspec (~> 3.0)
|
66
|
+
timecop
|
67
|
+
|
68
|
+
BUNDLED WITH
|
69
|
+
2.1.4
|
data/lib/racecar/config.rb
CHANGED
@@ -54,7 +54,7 @@ module Racecar
|
|
54
54
|
desc "How long to wait when trying to communicate with a Kafka broker"
|
55
55
|
float :socket_timeout, default: 30
|
56
56
|
|
57
|
-
desc "How long to allow the Kafka brokers to wait before returning messages"
|
57
|
+
desc "How long to allow the Kafka brokers to wait before returning messages (in seconds)"
|
58
58
|
float :max_wait_time, default: 1
|
59
59
|
|
60
60
|
desc "Maximum amount of data the broker shall return for a Fetch request"
|
data/lib/racecar/consumer_set.rb
CHANGED
@@ -17,7 +17,7 @@ module Racecar
|
|
17
17
|
@last_poll_read_nil_message = false
|
18
18
|
end
|
19
19
|
|
20
|
-
def poll(max_wait_time_ms = @config.
|
20
|
+
def poll(max_wait_time_ms = @config.max_wait_time_ms)
|
21
21
|
batch_poll(max_wait_time_ms, 1).first
|
22
22
|
end
|
23
23
|
|
@@ -31,7 +31,7 @@ module Racecar
|
|
31
31
|
# Any errors during polling are retried in an exponential backoff fashion. If an error
|
32
32
|
# occurs, but there is no time left for a backoff and retry, it will return the
|
33
33
|
# already collected messages and only retry on the next call.
|
34
|
-
def batch_poll(max_wait_time_ms = @config.
|
34
|
+
def batch_poll(max_wait_time_ms = @config.max_wait_time_ms, max_messages = @config.fetch_messages)
|
35
35
|
started_at = Time.now
|
36
36
|
remain_ms = max_wait_time_ms
|
37
37
|
maybe_select_next_consumer
|
@@ -130,6 +130,9 @@ module Racecar
|
|
130
130
|
@logger.debug "Capping #{wait_ms}ms to #{max_wait_time_ms-1}ms."
|
131
131
|
sleep (max_wait_time_ms-1)/1000.0
|
132
132
|
remain_ms = 1
|
133
|
+
elsif try == 0 && remain_ms == 0
|
134
|
+
@logger.debug "No time remains for polling messages. Will try on next call."
|
135
|
+
return nil
|
133
136
|
elsif wait_ms >= remain_ms
|
134
137
|
@logger.error "Only #{remain_ms}ms left, but want to wait for #{wait_ms}ms before poll. Will retry on next call."
|
135
138
|
@previous_retries = try
|
data/lib/racecar/message.rb
CHANGED
@@ -6,8 +6,11 @@ module Racecar
|
|
6
6
|
class Message
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
-
|
9
|
+
attr_reader :retries_count
|
10
|
+
|
11
|
+
def initialize(rdkafka_message, retries_count: nil)
|
10
12
|
@rdkafka_message = rdkafka_message
|
13
|
+
@retries_count = retries_count
|
11
14
|
end
|
12
15
|
|
13
16
|
def_delegators :@rdkafka_message, :topic, :partition, :offset, :key, :headers
|
data/lib/racecar/runner.rb
CHANGED
@@ -171,7 +171,7 @@ module Racecar
|
|
171
171
|
with_pause(message.topic, message.partition, message.offset..message.offset) do |pause|
|
172
172
|
begin
|
173
173
|
@instrumenter.instrument("process_message", instrumentation_payload) do
|
174
|
-
processor.process(Racecar::Message.new(message))
|
174
|
+
processor.process(Racecar::Message.new(message, retries_count: pause.pauses_count))
|
175
175
|
processor.deliver!
|
176
176
|
consumer.store_offset(message)
|
177
177
|
end
|
@@ -199,7 +199,10 @@ module Racecar
|
|
199
199
|
@instrumenter.instrument("process_batch", instrumentation_payload) do
|
200
200
|
with_pause(first.topic, first.partition, first.offset..last.offset) do |pause|
|
201
201
|
begin
|
202
|
-
|
202
|
+
racecar_messages = messages.map do |message|
|
203
|
+
Racecar::Message.new(message, retries_count: pause.pauses_count)
|
204
|
+
end
|
205
|
+
processor.process_batch(racecar_messages)
|
203
206
|
processor.deliver!
|
204
207
|
consumer.store_offset(messages.last)
|
205
208
|
rescue => e
|
data/lib/racecar/version.rb
CHANGED
data/racecar.gemspec
CHANGED
@@ -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.
|
23
|
+
spec.add_runtime_dependency "king_konf", "~> 1.0.0"
|
24
24
|
spec.add_runtime_dependency "rdkafka", "~> 0.8.0"
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", [">= 1.13", "< 3"]
|
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: 2.
|
4
|
+
version: 2.2.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: 2021-01-29 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.
|
20
|
+
version: 1.0.0
|
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.
|
27
|
+
version: 1.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rdkafka
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,11 +166,12 @@ extensions: []
|
|
166
166
|
extra_rdoc_files: []
|
167
167
|
files:
|
168
168
|
- ".circleci/config.yml"
|
169
|
-
- ".github/workflows/
|
169
|
+
- ".github/workflows/ci.yml"
|
170
170
|
- ".gitignore"
|
171
171
|
- ".rspec"
|
172
172
|
- CHANGELOG.md
|
173
173
|
- Gemfile
|
174
|
+
- Gemfile.lock
|
174
175
|
- LICENSE.txt
|
175
176
|
- Procfile
|
176
177
|
- README.md
|
data/.github/workflows/rspec.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
name: Execute Specs
|
2
|
-
|
3
|
-
on: [push]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
rspec:
|
7
|
-
|
8
|
-
runs-on: ubuntu-latest
|
9
|
-
|
10
|
-
strategy:
|
11
|
-
matrix:
|
12
|
-
ruby-version: ["2.5.x", "2.6.x"]
|
13
|
-
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@v1
|
16
|
-
- name: Set up Ruby 2.6
|
17
|
-
uses: actions/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: ${{ matrix.ruby-version }}
|
20
|
-
- name: Build and test with RSpec
|
21
|
-
run: |
|
22
|
-
gem install bundler --no-document
|
23
|
-
bundle install --jobs 4 --retry 3
|
24
|
-
bundle exec rspec --format documentation --require spec_helper --color
|