Skip to content

Instantly share code, notes, and snippets.

@stillinbeta
Created January 10, 2017 18:22
Show Gist options
  • Save stillinbeta/1dfc71279e88a4ca4cb6263414d0d315 to your computer and use it in GitHub Desktop.
Save stillinbeta/1dfc71279e88a4ca4cb6263414d0d315 to your computer and use it in GitHub Desktop.
try_handle_msg(Props, State = #cb_state{update = Update}) ->
case build_record(Props, #maestro_domain{}, undefined, update) of
{ok, Domain = #maestro_domain{name=Name}, SeqNum, Action}
when (Action == update orelse Action == delete),
is_integer(SeqNum) orelse is_list(SeqNum) ->
Timestamp = utils:datetime_to_epoch(erlang:universaltime()),
Latency = Timestamp - utils:to_i(Domain#maestro_domain.emitted_at),
case Action of
update -> hermes_domain:update(Domain);
delete -> hermes_domain:delete(Name)
end,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment