-
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 #325 from kafkaex/fix_compile_warnings
Fix compile warnings and credo
- Loading branch information
Showing
11 changed files
with
56 additions
and
48 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
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 |
---|---|---|
@@ -1,26 +1,33 @@ | ||
defmodule KafkaEx.ApiVersions do | ||
@moduledoc false | ||
|
||
def api_versions_map(api_versions) do | ||
api_versions | ||
|> Enum.reduce(%{}, fn version, version_map -> | ||
version_map |> Map.put(version.api_key, version) | ||
end) | ||
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 | ||
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 | ||
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 | ||
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
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