Identity Generator
Provide a standard interface for generating unique identifiers., (*1)
The purpose of this library is to solve the problem of generating
unique values that are "guaranteed" to be unique and are suitable
to be used as an identity for objects., (*2)
Why?
While it is generally not a problem for data stores that implement
sequential or auto increment ID fields natively to provide a
guaranteed unique identity, there are use cases where it makes
sense to randomize identity such that it is not able to be guessed
as it follows no predictable pattern., (*3)
As such, most of the GeneratorInterface implementations provided
by this library will be somewhat random in nature. This does not
preclude the use of sequential GeneratorInterface implementations., (*4)
Mobs
Mobs are used to group identities. If a mob is specified, the
value requested to be stored by the data store need only be
unique to that mob. This allows a single data store to potentially
store and manage unique identities across several namespaces., (*5)
The name 'group' can be ambiguous (and is a reserved word for potential
data stores) so 'mob' was chosen based on the definition:, (*6)
any group or collection of persons or things., (*7)
The "Uniqueness Guarantee"
The uniqueness guarantee is accomplished by attempting to add
a generated value to a data store. The data store needs to be
capable of knowing whether or not the value passed in is unique.
This guarantee of uniqueness is only as strong as the given
data store's ability to effectively determine uniqueness of a
given value., (*8)
A data store should throw NonUniqueIdentityException in the
case that a given value is not unique. The requested identity
and mob values are available via this exception., (*9)
What About Collisions?
The IdentityGenerator will make maxRetries attempts to
store generated values into the data store. This should allow
for handling a finite number of collisions gracefully., (*10)
Should maxRetries be exhausted, GenerateException is thrown.
It will contain a list of NonUniqueIdentityException exceptions
equal to the number of maxRetries., (*11)
Requirements
License
MIT, see LICENSE., (*12)
If you have questions or want to help out, join us in the
#dflydev channel on irc.freenode.net., (*13)