Twitter Snowflake-alike ID generator for .Net
This is a maintenance release. No changes in packages. From now on we use GitHub actions to build and publish Nuget packages.
Minor internal refactoring.
ID
is now a record
Minor internal refactoring. Also an Idgen.DependencyInjection package is now available.
This release contains a few (minor) breaking changes. Generated 2.x ID's are still compatible with 3.x ID's.
IdGenerator
have been replaced with a single constructor which accepts IdGeneratorOptions
that contains the ITimeSource
, IdStructure
and SequenceOverflowStrategy
.MaskConfig
class is now more appropriately named IdStructure
since it describes the structure of the generated ID's.UseSpinWait
property has moved to the IdGeneratorOptions
and is now an enum of type SequenceOverflowStrategy
instead of a boolean value. Note that this property has also been renamed in the config file (from useSpinWait
to sequenceOverflowStrategy
) and is no longer a boolean but requires
one of the values from SequenceOverflowStrategy
.ID
is now Id
(only used as return value by the FromId(...)
method)Fix concurrency issue (see PR #23). Upped version.
The IdGenerator
now offers a spinwaiting strategy when a sequenceoverflow occurs instead of throwing a SequenceOverflowException
. This will spinwait until the next tick and then return a new Id. New constructoroverloads have been added to be able to set this property at construction time. Also the configuration package supports this new option with a useSpinWait
attribute on the idGenerator
element.
TryCreate()
method (see #21)IDGen.Configuration
packageID
now implements IEquatable
ArgumentOutOfRangeExceptions
from the IdGenerator
's ctor messagesIf you're using the IdGenerator.GetFromConfig(...)
method make sure you check the README. The changes aren't big, but breaking nonetheless. How to fix:
IdGen.Configuration
packageIdGen.Configuration.IdGeneratorsSection, IdGen
IdGen.Configuration.IdGeneratorsSection, IdGen.Configuration
using IdGen.Configuration
IdGenerator.GetFromConfig(...)
to AppConfigFactory.GetFromConfig(...)
FromId()
method to 'decode' an Id