ScopedIdGenerator class
An IdGenerator that stamps a scope into every identifier it produces.
Entity ids have to be unique across a whole federation, not just within one store. A hub caches "which provider owns which id" and deduplicates aggregated listings by id; two nodes independently minting the same id would make one entity shadow the other, and route writes to the wrong machine. Independent processes cannot coordinate a counter, so the scope — normally the provider id — is what keeps them apart.
ScopedIdGenerator(RandomIdGenerator(), 'node-eu').next('rel');
// => 'rel-node-eu-1k3f9x'
The scope is also a diagnostic: an id in a log or a URL says which node created the record, which is the first thing you want to know when a federated deployment misbehaves.
- Implemented types
Constructors
- ScopedIdGenerator(IdGenerator inner, String scope)
-
Wraps
inner, stampingscopeinto every id.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- inner → IdGenerator
-
The generator supplying the unique part of each id.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope → String
-
The scope stamped into every id, normalised to lower-case alphanumerics
and
-.final
Methods
-
next(
[String prefix = '']) → String -
Returns a fresh identifier, optionally namespaced with
prefix(e.g.conn,node,req).override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited