Packages
extreme
1.0.3
1.1.4
1.1.3
1.1.2
1.1.1
1.1.1-rc01
1.1.0
1.1.0-rc9
1.1.0-rc8
1.1.0-rc7
1.1.0-rc6
1.1.0-rc5
1.1.0-rc4
1.1.0-rc3
1.1.0-rc2
1.1.0-rc1
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.1
0.12.0
0.11.0
0.10.4
0.10.3
0.10.2
0.10.1
0.10.0
0.9.2
0.9.1
0.9.0
0.8.1
0.8.0
0.7.1
0.7.0
0.6.2
0.6.1
0.6.0
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
Elixir TCP client for EventStore.
Current section
Files
Jump to
Current section
Files
lib/extreme/response.ex
defmodule Extreme.Response do
require Logger
def get_correlation_id(<<_message_type, _auth, correlation_id::16-binary, _data::binary>>),
do: correlation_id
def parse(<<message_type, auth, correlation_id::16-binary, data::binary>>) do
case Extreme.MessageResolver.decode_cmd(message_type) do
:not_authenticated ->
{:error, :not_authenticated, correlation_id}
:heartbeat_request_command ->
{:heartbeat_request, correlation_id}
:pong ->
{:pong, correlation_id}
:client_identified ->
{:client_identified, correlation_id}
:bad_request ->
{:error, :bad_request, correlation_id}
response_struct ->
data = response_struct.decode(data)
{auth, correlation_id, data}
end
end
def reply(%{result: error} = msg, _correlation_id) when error != :success,
do: {:error, error, msg}
def reply(response, _correlation_id), do: {:ok, response}
end