Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max_wait_time usage #179

Merged
merged 1 commit into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/racecar/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ class Config < KingKonf::Config

attr_accessor :subscriptions, :logger

def max_wait_time_ms
max_wait_time * 1000
end

def initialize(env: ENV)
super(env: env)
@error_handler = proc {}
Expand Down
2 changes: 1 addition & 1 deletion lib/racecar/consumer_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def rdkafka_config(subscription)
"fetch.max.bytes" => @config.max_bytes,
"message.max.bytes" => subscription.max_bytes_per_partition,
"fetch.min.bytes" => @config.fetch_min_bytes,
"fetch.wait.max.ms" => @config.max_wait_time * 1000,
"fetch.wait.max.ms" => @config.max_wait_time_ms,
"group.id" => @config.group_id,
"heartbeat.interval.ms" => @config.heartbeat_interval * 1000,
"max.poll.interval.ms" => @config.max_poll_interval * 1000,
Expand Down
4 changes: 2 additions & 2 deletions lib/racecar/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def run
@instrumenter.instrument("main_loop", instrumentation_payload) do
case process_method
when :batch then
msg_per_part = consumer.batch_poll(config.max_wait_time).group_by(&:partition)
msg_per_part = consumer.batch_poll(config.max_wait_time_ms).group_by(&:partition)
msg_per_part.each_value do |messages|
process_batch(messages)
end
when :single then
message = consumer.poll(config.max_wait_time)
message = consumer.poll(config.max_wait_time_ms)
process(message) if message
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
end
end

describe '#max_wait_time_ms' do
before { config.max_wait_time = 12 }

it 'returns max_wait_time in milliseconds' do
expect(config.max_wait_time_ms).to eq(12_000)
end
end

describe "#validate!" do
before do
config.brokers = ["a"]
Expand Down