kkrypt0nn / spaceflake

⛄ A distributed generator to create unique IDs with ease in Go; inspired by Twitter's Snowflake

Home Page:https://krypton.ninja

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate Spaceflake at time

kkrypt0nn opened this issue · comments

Proposal

Be able to generate a Spaceflake where the base or timestamp of that Spaceflake can be customized. The argument would be of type Time and can be created with time.Date. It would contain two generators, one on a Worker type and another one with GeneratorSettings added as argument.

When using a worker

func (w *Worker) GenerateSpaceflakeAt(at time.Time) (*Spaceflake, error) {
    // ...
}

Without using a worker

func GenerateAt(s GeneratorSettings, at time.Time) (*Spaceflake, error) {
    // ...
}

Added as per version 1.4.0, see changelogs here.