Sonyflake (sonyflake_ex v0.1.0)
Documentation for Sonyflake.
Link to this section Summary
Functions
Get time elapsed since the SonyFlake ID generator was initialised.
Decompose a generated sonyflake id back to its components.
Generates and returns the next unique ID.
Link to this section Functions
Link to this function
current_elapsed_time(sonyflake)
Specs
current_elapsed_time(%Sonyflake{
elapsed_time: term(),
machine_id: term(),
msb: term(),
sequence: term(),
start_time: number()
}) :: integer()
Get time elapsed since the SonyFlake ID generator was initialised.
Link to this function
decompose(id)
Specs
decompose(non_neg_integer()) :: [ {:id, non_neg_integer()} | {:machine_id, non_neg_integer()} | {:msb, non_neg_integer()} | {:sequence, non_neg_integer()} | {:time, non_neg_integer()}, ... ]
Decompose a generated sonyflake id back to its components.
Link to this function
new()
Specs
new() :: %Sonyflake{
elapsed_time: 0,
machine_id: number(),
msb: 0,
sequence: 255,
start_time: integer()
}
Create an instance of Sonyflake unique ID generator.
Link to this function
next_id(sonyflake)
Specs
next_id(%Sonyflake{
elapsed_time: integer(),
machine_id: integer(),
msb: any(),
sequence: integer(),
start_time: number()
}) ::
{:ok,
%Sonyflake{
elapsed_time: integer(),
machine_id: integer(),
msb: any(),
sequence: integer(),
start_time: number()
}, integer()}
Generates and returns the next unique ID.
Raises a TimeoutError after the SonyFlake time overflows.
Link to this function