Packages
extreme
0.8.0
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/response.ex
defmodule Extreme.Response do
require Logger
alias Extreme.Messages, as: ExMsg
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}
response_struct ->
data = response_struct.decode data
{auth, correlation_id, data}
end
end
def reply(%{result: :Success} = data), do: {:ok, data}
def reply(%ExMsg.SubscriptionConfirmation{} = data), do: {:ok, data}
#def reply(%ExMsg.SubscriptionDropped{} = data), do: {:ok, data}
def reply(%ExMsg.StreamEventAppeared{} = data), do: {:ok, data}
def reply(%{result: _} = data), do: {:error, data.result, data}
def reply({:error, reason}), do: {:error, reason}
def reply(1), do: Logger.debug "HEARTBEAT"
def reply(response) do
Logger.error "Unhandled response: #{inspect response}"
{:error, :unhandled_response_type, response}
end
end