/
client_impl.ex
61 lines (49 loc) · 1.28 KB
/
client_impl.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
defmodule OffBroadwayAmqp10.Amqp10.Client.Impl do
@moduledoc """
AMQP Client Wrapper
"""
alias OffBroadwayAmqp10.Amqp10.State
alias OffBroadwayAmqp10.Amqp10.Client
@behaviour Client
@impl Client
def open_connection(%State{} = state) do
:amqp10_client.open_connection(state.connection_config)
end
@impl Client
def begin_session(%State{} = state) do
:amqp10_client.begin_session(state.connection)
end
@impl Client
def attach(%State{} = state) do
:amqp10_client_session.attach(state.session, state.receiver_config)
end
@impl Client
def flow_link_credit(%State{} = state, demand) do
:amqp10_client.flow_link_credit(state.receiver, demand, :never)
end
@impl Client
def accept_msg(%State{} = state, ack_data) do
:amqp10_client.accept_msg(state.receiver, ack_data)
end
@impl Client
def body(raw_msg) do
[payload] = :amqp10_msg.body(raw_msg)
payload
end
@impl Client
def headers(raw_msg) do
:amqp10_msg.headers(raw_msg)
end
@impl Client
def properties(raw_msg) do
:amqp10_msg.properties(raw_msg)
end
@impl Client
def application_properties(raw_msg) do
:amqp10_msg.application_properties(raw_msg)
end
@impl Client
def annotations(raw_msg) do
:amqp10_msg.message_annotations(raw_msg)
end
end