-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from euranova/use_api_versions_for_new_api_calls
Use api versions for new api calls (depends on #319)
- Loading branch information
Showing
15 changed files
with
248 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /bin/sh | ||
|
||
# WARN: when changing something here, there should probably also be a change in scripts/ci_tests.sh | ||
|
||
mix test --include integration --include consumer_group --include server_0_p_10_and_later --include server_0_p_9_p_0 --include server_0_p_8_p_0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule KafkaEx.ApiVersions do | ||
|
||
def api_versions_map(api_versions) do | ||
api_versions | ||
|> Enum.reduce(%{}, fn version, version_map -> | ||
version_map |> Map.put(version.api_key, version) | ||
end) | ||
end | ||
|
||
|
||
def find_api_version(api_versions_map, message_type, {min_implemented_version, max_implemented_version}) do | ||
if api_versions_map == [:unsupported] do | ||
{:ok, min_implemented_version} | ||
else | ||
case KafkaEx.Protocol.api_key(message_type) do | ||
nil -> :unknown_message_for_client | ||
api_key -> case api_versions_map[api_key] do | ||
%{min_version: min} when min > max_implemented_version -> :no_version_supported | ||
%{max_version: max} when max < min_implemented_version -> :no_version_supported | ||
%{max_version: max} -> {:ok, Enum.min([max_implemented_version, max])} | ||
_ -> :unknown_message_for_server | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.