Struct monteflake::MonteFlake [] [src]

pub struct MonteFlake { /* fields omitted */ }

MonteFlake creates a configurable Snowflake ID generator where the epoch and bitwidths may be adjusted to your liking from the defaults. MonteFlake id generation will always increase in value from the time its instantiated. No other guarantees are made. If a MonteFlake generator is created after a clock moves back from other MonteFlake generated ids conflicting ID values are entirely possible.

Methods

impl MonteFlake
[src]

Build a new monteflake with default options id: 0 epoch: 2013-01-01T00:00:00Z in milliseconds since the unix epoch bitwidths (42 timestamp bits, 10 id bits, 12 sequence bits)

Set the epoch of a MonteFlake generator

Set the id of a MonteFlake generator

Set the bitwidths of a MonteFlake generator

generate the next id internally this updates at least the current sequence value, possibly the timestamp value if enough time has elapsed to matter

encode into an id the current time, id of the generator (machine, node, shard), and sequence value the current time (ts) is the number of milliseconds passed since the unix epoch

decode from an encoded id the time, id of the generator, and sequence id the current time (ts) is the number of milliseconds passed since the unix epoch