misc fix
This commit is contained in:
parent
27336f9859
commit
2f1c03a469
|
@ -38,6 +38,8 @@
|
|||
|
||||
-module(emqttd_guid).
|
||||
|
||||
-author("Feng Lee <feng@emqtt.io>").
|
||||
|
||||
-export([gen/0, new/0, timestamp/1]).
|
||||
|
||||
-define(MAX_SEQ, 16#FFFF).
|
||||
|
@ -54,17 +56,21 @@ gen() ->
|
|||
undefined -> new();
|
||||
{_Ts, NPid, Seq} -> next(NPid, Seq)
|
||||
end,
|
||||
put(guid, Guid), enc(Guid).
|
||||
put(guid, Guid), bin(Guid).
|
||||
|
||||
new() ->
|
||||
{ts(), npid(), 0}.
|
||||
|
||||
-spec timestamp(guid()) -> integer().
|
||||
timestamp(<<Ts:64, _/binary>>) ->
|
||||
Ts.
|
||||
|
||||
next(NPid, Seq) when Seq >= ?MAX_SEQ ->
|
||||
{ts(), NPid, 0};
|
||||
next(NPid, Seq) ->
|
||||
{ts(), NPid, Seq + 1}.
|
||||
|
||||
enc({Ts, NPid, Seq}) ->
|
||||
bin({Ts, NPid, Seq}) ->
|
||||
<<Ts:64, NPid:48, Seq:16>>.
|
||||
|
||||
ts() ->
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
%%%-----------------------------------------------------------------------------
|
||||
|
||||
%% TODO: issue #103
|
||||
%% 0.12.0 ???
|
||||
|
||||
-module(emqttd_log).
|
||||
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
|
||||
-author("Feng Lee <feng@emqtt.io>").
|
||||
|
||||
%% TODO:... 0.10.0...
|
||||
%% TODO:... 0.11.0...
|
||||
|
||||
|
|
Loading…
Reference in New Issue