ID Generators
In addition to standard settings, writeable state managers can also utilize id generators for assigning globally unique ids to each input event
Id generator class is defined with "id.generator" setting and can be one of the following classes.
All id generators can use the following parameters:
id.prefix
Prefix to add to generated ids
ID-
-
id.suffix
Suffix to add to generated ids
-val
-
id.digits
Minimum number of digits for an id
10
-
id.filler
Character to repeat as prefix if id is shorter than minimum number of digits
X
0
RandomIDGenerator
Generates a random globally unique ID each time. This has no settings.
NumberIDGenerator
Uses instance of a number to generate unique numerical ids. Uses the following state parameters:
id.numberGenerator
Class name of number generator to use
com.rierino.handler.util.generator.ConstantNumberGenerator
-
id.label
Label to use for numbers generated if number generator is shared between different types of data
product
-
id.checksum
Whether to calculate a checksum digit for generated number
true
false
id.checkReverse
Whether the checksum digit should be subtracted from 10
true
false
id.checkOddMultiplier
Number to multiply each odd digit with for checksum calculation
3
1
id.checkEvenMultiplier
Number to multiply each even digit with for checksum calculation
1
1
ConstantNumberGenerator
Produces a constant number only, using "id.value" setting, assigning same id to all records, only used for testing purposes.
EpochNumberGenerator
Produces number based on epoch time in milliseconds, which does not guarantee uniqueness especially for a distributed deployment.
MongoNumberGenerator
Through "id.system" and "id.collection" settings, uses a MongoDB collection for creating and tracking globally unique ids.
MongoNumberGenerator is a buffered number generator, where "id.buffer" can be set to define maximum increments allowed for "reserving" ids on each request.
Buffering happens in exponential iterations (e.g. reserving 1, 2, 4, 8, ... until max is reached) so that continuous system restarts do not result in unnecessary reservations.
OffsetPartitionedIDGenerator
Uses source partition, key and offset of the event for generating unique ids. This has no settings.
PartitionedIDGenerator
instances of another id generator class, with each instance dedicated to a . Partition is suffixed to the id generated by used instances, ensuring global uniqueness across partitions. Uses the following state parameters:
id.partitioned.class
Class name of inner generator to use
com.rierino.handler.util.generator.NumberIDGenerator
com.rierino.handler.util.generator.RandomIDGenerator
Dependent ID Generators
These id generators generate ids for children of an existing entity (e.g. variants of a product), in a [prefix][delimiter][newid] type format. The following settings are shared among these generators:
id.digits
Number of digits to generate children id with (prefixing shorted ids with 0)
4
-
id.suffixParent
Whether parent id should be a prefix or a suffix
true
false
id.delimiter
Delimiter between parent and child ids
-
id.parentPath
Json path of the data element keeping parent id for a child record
data.parent
data.parentId
DependentEventIDGenerator
Uses and increments an ID provided in event payload to generate a new ID. Typically used within a saga where a previous step calculates max child id so far.
id.maxChildPath
Json path of the max ID so far in event payload
prevId
maxId
DependentQueryIDGenerator
Uses and increments the max ID stored in a database to generate a new ID. Typically used with a query getting maximum child ID directly from a database table / collection.
id.eventParent
...
true
false
id.query.state
State manager keeping query details
query_local
query
id.query.id
Id of the query for selecting max child id for a given parent
product_maxid
_maxid
id.query.manager
Query manager which should run the query for selecting max child id
product_master
master
This generator injects "%%parentid%%" variable in executed query and expects the query to return maximum child id so far as "maxId" field.
Last updated