exnowflake v0.1.0 Exnowflake.Worker View Source

This worker generates unique time based IDs.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Generates a 64 bit integer based on time, worker ID and a sequence.

Returns milliseconds passed since epoch when ID was generated.

Returns the real timestamp of an ID in milliseconds.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

generate()

View Source
generate() :: {:ok, integer()} | {:error, :backwards_clock}

Generates a 64 bit integer based on time, worker ID and a sequence.

Link to this function

internal_timestamp(id)

View Source
internal_timestamp(integer()) :: integer()

Returns milliseconds passed since epoch when ID was generated.

Returns the real timestamp of an ID in milliseconds.