class Sonyflake::Settings

Defined in:

Constructors

Instance Method Summary

Constructor Detail

def self.new(start_time : Time? = nil, machine_id : UInt16? = nil, check_machine_id : Proc(UInt16, Bool)? = 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.

Instance Method Detail

def check_machine_id(machine_id : UInt16) : Bool #

Check machine_id


def check_machine_id : Bool #

Check machine_id


def machine_id : UInt16 #

Get machine_id


def start_time : Time #