snowflake-0.1.1.1: A loose port of Twitter Snowflake to Haskell. Generates arbitrary precision, unique, time-sortable identifiers.

LicenseApache 2.0
Maintaineredofic@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Data.Snowflake

Description

This generates unique(guaranteed) identifiers build from time stamp, counter(inside same millisecond) and node id - if you wish to generate ids across several nodes. Identifiers are convertible to Integer values which are monotonically increasing with respect to time.

Synopsis

Documentation

data SnowflakeConfig #

Configuration that specifies how much bits are used for each part of the id. There are no limits to total bit sum.

Constructors

SnowflakeConfig 

data Snowflake #

Generated identifier. Can be converted to Integer.

data SnowflakeGen #

Generator which contains needed state. You should use newSnowflakeGen to create instances.

newSnowflakeGen :: SnowflakeConfig -> Integer -> IO SnowflakeGen #

Create a new generator. Takes a configuration and node id.

nextSnowflake :: SnowflakeGen -> IO Snowflake #

Generates next id. The bread and butter. See module description for details.

defaultConfig :: SnowflakeConfig #

Default configuration using 40 bits for time, 16 for count and 8 for node id.

snowflakeToInteger :: Snowflake -> Integer #

Converts an identifier to an integer with respect to configuration used to generate it.