module Sonyflake
Overview
A Crystal port of sony/sonyflake
require "sonyflake"
settings = Sonyflake::Settings.new(start_time: Time.utc(2020, 1, 1), machine_id: 1)
sonyflake = Sonyflake.new_sonyflake(settings)
puts sonyflake.next_id # => 302603879411875841
puts Sonyflake.get_instance.next_id # => 302603879411941377
Defined in:
sonyflake.crConstant Summary
-
BIT_LEN_MACHINE_ID =
(63 - BIT_LEN_TIME) - BIT_LEN_SEQUENCE
-
BIT_LEN_SEQUENCE =
8
-
BIT_LEN_TIME =
39
-
VERSION =
"0.1.0"
Constructors
-
.get_instance : Sonyflake
Get previously created instance
Class Method Summary
-
.new_sonyflake(settings : Settings) : Sonyflake | Nil
Generate a new sonyflake from the settings
Constructor Detail
Get previously created instance
sonyflake = Sonyflake.get_instance
Class Method Detail
Generate a new sonyflake from the settings
require "sonyflake"
settings = Sonyflake::Settings.new(start_time: Time.utc(2020, 1, 1), machine_id: 1_u16)
sonyflake = Sonyflake.new_sonyflake(settings)