class Sonyflake::Settings
- Sonyflake::Settings
- Reference
- Object
Defined in:
sonyflake.crConstructors
-
.new(start_time : Time | Nil = nil, machine_id : UInt16 | Nil = nil, check_machine_id : Proc(UInt16, Bool) | Nil = nil)
Create a new Sonyflake::Settings
Instance Method Summary
-
#check_machine_id(machine_id : UInt16) : Bool
Check machine_id
-
#check_machine_id : Bool
Check machine_id
-
#machine_id : UInt16
Get machine_id
- #start_time : Time
Constructor Detail
def self.new(start_time : Time | Nil = nil, machine_id : UInt16 | Nil = nil, check_machine_id : Proc(UInt16, Bool) | Nil = nil)
#
Create a new Sonyflake::Settings
require "sonyflake"
settings = Sonyflake::Settings.new(start_time: Time.utc(2020, 1, 1))
- start_time: The time since which the Sonyflake time is defined. If start_time is nil, the start time is set to "2014-09-01 00:00:00 +0000 UTC".
- machine_id: The unique ID of the Sonyflake instance. If machine_id is nil, the machine id is set to the lower 16 bits of the private ip address. (Not working right now)
- check_machine_id: The callback (Proc) that validate the uniqueness of the machine id. If check_machine_id is nil, no validation is done.