-
Notifications
You must be signed in to change notification settings - Fork 162
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
Avoid parsing nil response when connection timeout occured #235
Changes from all commits
1e7abb6
1f1d59f
82a17f6
f32de68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,21 +165,24 @@ defmodule KafkaEx.Server0P8P2 do | |
Logger.log(:error, "Leader for topic #{fetch_request.topic} is not available") | ||
{:topic_not_found, state} | ||
_ -> | ||
response = broker | ||
|> NetworkClient.send_sync_request(fetch_data, config_sync_timeout()) | ||
|> Fetch.parse_response | ||
state = %{state | correlation_id: state.correlation_id + 1} | ||
last_offset = response |> hd |> Map.get(:partitions) |> hd |> Map.get(:last_offset) | ||
if last_offset != nil && fetch_request.auto_commit do | ||
offset_commit_request = %OffsetCommit.Request{ | ||
topic: fetch_request.topic, | ||
offset: last_offset, | ||
partition: fetch_request.partition, | ||
consumer_group: state.consumer_group} | ||
{_, state} = offset_commit(state, offset_commit_request) | ||
{response, state} | ||
else | ||
{response, state} | ||
response = NetworkClient.send_sync_request(broker, fetch_data, config_sync_timeout()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long (max is 80, was 93). |
||
case response do | ||
nil -> {response, state} | ||
_ -> | ||
response = Fetch.parse_response(response) | ||
state = %{state | correlation_id: state.correlation_id + 1} | ||
last_offset = response |> hd |> Map.get(:partitions) |> hd |> Map.get(:last_offset) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long (max is 80, was 95). |
||
if last_offset != nil && fetch_request.auto_commit do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function body is nested too deep (max depth is 2, was 3). |
||
offset_commit_request = %OffsetCommit.Request{ | ||
topic: fetch_request.topic, | ||
offset: last_offset, | ||
partition: fetch_request.partition, | ||
consumer_group: state.consumer_group} | ||
{_, state} = offset_commit(state, offset_commit_request) | ||
{response, state} | ||
else | ||
{response, state} | ||
end | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long (max is 80, was 93).