Skip to content

Commit 8e7fcc6

Browse files
authored
Merge pull request #20 from narslan/fix-version-hash-handling
Handle commit-hash version strings from RabbitMQ built from source
2 parents 8256f13 + f2bdc5a commit 8e7fcc6

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

lib/connection/handler.ex

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,9 @@ defmodule RabbitMQStream.Connection.Handler do
121121

122122
# We need to extract the base version from the version string so we can compare
123123
# make decisions based on the version of the server.
124-
version =
125-
~r/(\d+)\.(\d+)\.(\d+)/
126-
|> Regex.run(response.data.peer_properties["version"], capture: :all_but_first)
127-
|> Enum.map(&String.to_integer/1)
124+
base_version = Version.parse!(response.data.peer_properties["version"])
128125

129-
peer_properties = Map.put(response.data.peer_properties, "base-version", version)
126+
peer_properties = Map.put(response.data.peer_properties, "base-version", base_version)
130127

131128
%{conn | peer_properties: peer_properties}
132129
|> Helpers.push_internal(:request, :sasl_handshake)
@@ -170,7 +167,7 @@ defmodule RabbitMQStream.Connection.Handler do
170167
%Connection{peer_properties: %{"base-version" => version}} = conn,
171168
%Response{command: :open} = response
172169
)
173-
when version < [3, 13] do
170+
when [version.major, version.minor] < [3, 13] do
174171
Logger.debug("Successfully opened connection with vhost: \"#{conn.options[:vhost]}\"")
175172

176173
for request <- conn.connect_requests do
@@ -186,7 +183,7 @@ defmodule RabbitMQStream.Connection.Handler do
186183
%Connection{peer_properties: %{"base-version" => version}} = conn,
187184
%Response{command: :open} = response
188185
)
189-
when version >= [3, 13] do
186+
when [version.major, version.minor] >= [3, 13] do
190187
Logger.debug(
191188
"Successfully opened connection with vhost: \"#{conn.options[:vhost]}\". Initiating command version exchange."
192189
)

0 commit comments

Comments
 (0)