Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/turtle_publisher.erl
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ handle_deliver(Tag, #amqp_msg { payload = Payload, props = Props },
ok = amqp_channel:cast(Ch, #'basic.ack' { delivery_tag = Tag }),
case track_lookup(CorrID, IF) of
{ok, Pid, T, IF2} ->
T2 = turtle_time:monotonic_time(),
T2 = erlang:monotonic_time(),
Pid ! {rpc_reply, {self(), CorrID}, T2 - T, Type, Payload},
{noreply, State#state { in_flight = IF2 }};
not_found ->
Expand Down Expand Up @@ -375,7 +375,7 @@ publish({cast, undefined}, Pub, AMQPMsg, #state{ channel = Ch, confirms = true }
publish({call, From}, Pub, AMQPMsg, #state{ channel = Ch, confirms = true, unacked = UA } = State) ->
Seq = amqp_channel:next_publish_seqno(Ch),
ok = amqp_channel:call(Ch, Pub, AMQPMsg),
T = turtle_time:monotonic_time(),
T = erlang:monotonic_time(),
{noreply, State#state{ unacked = gb_trees:insert(Seq, {From, T}, UA) }};
publish({rpc_call, From}, Pub, AMQPMsg,
#state {
Expand All @@ -391,7 +391,7 @@ publish({rpc_call, From}, Pub, AMQPMsg,
reply_to = ReplyQ,
correlation_id = <<CorrID:64/integer>> }},
ok = amqp_channel:call(Ch, Pub, WithReply),
T = turtle_time:monotonic_time(),
T = erlang:monotonic_time(),

{noreply, State#state {
corr_id = CorrID + 1,
Expand All @@ -404,7 +404,7 @@ publish({rpc_call, From}, Pub, AMQPMsg,
reply_to = ReplyQ,
correlation_id = <<CorrID:64/integer>> }},
ok = amqp_channel:call(Ch, Pub, WithReply),
T = turtle_time:monotonic_time(),
T = erlang:monotonic_time(),

Opaque = {self(), CorrID},
{reply, {ok, Opaque}, State#state {
Expand All @@ -415,7 +415,7 @@ publish({F, _X}, Pub, AMQPMsg, #state{ channel = Ch, confirms = false } = State)
{reply, ok, State}.

confirm(Reply, Seq, Multiple, #state { unacked = UA } = State) ->
T2 = turtle_time:monotonic_time(),
T2 = erlang:monotonic_time(),
{Results, UA1} = remove_delivery_tags(Seq, Multiple, UA),
reply_to_callers(T2, Reply, Results),
{ok, State#state { unacked = UA1 }}.
Expand Down Expand Up @@ -444,11 +444,11 @@ remove_delivery_tags(Seq, true, Unacked) ->

reply_to_callers(_T2, _Reply, []) -> ok;
reply_to_callers(T2, Reply, [{From, T1} | Callers]) ->
Window = turtle_time:convert_time_unit(T2 - T1, native, milli_seconds),
Window = erlang:convert_time_unit(T2 - T1, native, milli_seconds),
gen_server:reply(From, {Reply, Window}),
reply_to_callers(T2, Reply, Callers);
reply_to_callers(T2, ack, [{rpc, From, T1, CorrID} | Callers]) ->
Window = turtle_time:convert_time_unit(T2 - T1, native, milli_seconds),
Window = erlang:convert_time_unit(T2 - T1, native, milli_seconds),
Opaque = {self(), CorrID},
gen_server:reply(From, {ok, Opaque, Window}),
reply_to_callers(T2, ack, Callers);
Expand Down
28 changes: 14 additions & 14 deletions src/turtle_subscriber.erl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ handle_info(Info, #state { handle_info = undefined } = State) ->
lager:warning("Unknown info message: ~p", [Info]),
{noreply, State};
handle_info(Info, #state { handle_info = HandleInfo, invoke_state = IState } = State) ->
S = turtle_time:monotonic_time(),
S = erlang:monotonic_time(),
try HandleInfo(Info, IState) of
{ok, IState2} -> {noreply, State#state { invoke_state = IState2 }};
{Cmds, IState2} when is_list(Cmds) ->
Expand Down Expand Up @@ -154,14 +154,14 @@ handle_deliver_bulk({#'basic.deliver' {delivery_tag = DTag, routing_key = Key},
channel = Channel,
conn_name = CN,
name = N } = State) ->
S = turtle_time:monotonic_time(),
S = erlang:monotonic_time(),
Tag = {DTag, ReplyTo, CorrID},
try handle_message(Tag, Fun, Key, Content, IState) of
{[], S2} ->
E = turtle_time:monotonic_time(),
E = erlang:monotonic_time(),
exometer:update([CN, N, msgs], 1),
exometer:update([CN, N, latency],
turtle_time:convert_time_unit(E-S, native, milli_seconds)),
erlang:convert_time_unit(E-S, native, milli_seconds)),
{noreply, State#state { invoke_state = S2 }};
{Cmds, S2} when is_list(Cmds) ->
handle_commands(S, Cmds, State#state { invoke_state = S2 })
Expand All @@ -180,7 +180,7 @@ handle_deliver_single({#'basic.deliver' {delivery_tag = DTag, routing_key = Key}
correlation_id = CorrID,
reply_to = ReplyTo }} = Content},
#state { invoke = Fun, invoke_state = IState,channel = Channel } = State) ->
S = turtle_time:monotonic_time(),
S = erlang:monotonic_time(),
Tag = {DTag, ReplyTo, CorrID},
try
%% Transform a single message into the style of bulk messages
Expand Down Expand Up @@ -210,24 +210,24 @@ handle_commands(S, [C | Next],
#state { channel = Channel, conn_name = CN, name = N } = State) ->
case C of
{ack, Tag} ->
E = turtle_time:monotonic_time(),
E = erlang:monotonic_time(),
exometer:update([CN, N, msgs], 1),
exometer:update([CN, N, latency],
turtle_time:convert_time_unit(E-S, native, milli_seconds)),
erlang:convert_time_unit(E-S, native, milli_seconds)),
ok = amqp_channel:cast(Channel, #'basic.ack' { delivery_tag = delivery_tag(Tag) }),
handle_commands(S, Next, State);
{bulk_ack, Tag} ->
E = turtle_time:monotonic_time(),
E = erlang:monotonic_time(),
exometer:update([CN, N, msgs], 1),
exometer:update([CN, N, latency],
turtle_time:convert_time_unit(E-S, native, milli_seconds)),
erlang:convert_time_unit(E-S, native, milli_seconds)),
ok = amqp_channel:cast(Channel, #'basic.ack' { delivery_tag = delivery_tag(Tag), multiple = true }),
handle_commands(S, Next, State);
{bulk_nack, Tag} ->
E = turtle_time:monotonic_time(),
E = erlang:monotonic_time(),
exometer:update([CN, N, msgs], 1),
exometer:update([CN, N, latency],
turtle_time:convert_time_unit(E-S, native, milli_seconds)),
erlang:convert_time_unit(E-S, native, milli_seconds)),
ok = amqp_channel:cast(Channel, #'basic.nack' { delivery_tag = delivery_tag(Tag), multiple = true }),
handle_commands(S, Next, State);
{reject, Tag} ->
Expand All @@ -241,10 +241,10 @@ handle_commands(S, [C | Next],
#'basic.reject' { delivery_tag = delivery_tag(Tag), requeue = false}),
handle_commands(S, Next, State);
{reply, Tag, CType, Msg} ->
E = turtle_time:monotonic_time(),
E = erlang:monotonic_time(),
exometer:update([CN, N, msgs], 1),
exometer:update([CN, N, latency],
turtle_time:convert_time_unit(E-S, native, milli_seconds)),
erlang:convert_time_unit(E-S, native, milli_seconds)),
reply(Channel, Tag, CType, Msg),
ok = amqp_channel:cast(Channel, #'basic.ack' { delivery_tag = delivery_tag(Tag) }),
handle_commands(S, Next, State);
Expand Down Expand Up @@ -338,7 +338,7 @@ mode(#{}) -> single.
delivery_tag({Tag, _ReplyTo, _CorrID}) -> Tag.

shutdown(Reason, #state { handle_info = HandleInfo, invoke_state = IState } = State) ->
S = turtle_time:monotonic_time(),
S = erlang:monotonic_time(),
try HandleInfo({amqp_shutdown, Reason}, IState) of
{ok, IState2} -> {noreply, State#state { invoke_state = IState2 }};
{Cmds, IState2} when is_list(Cmds) ->
Expand Down
Loading