ConsensusRegisterCollectionClass Class
A distributed data structure that holds a set of registers with update versions. On concurrent updates, a register internally stores all possible versions of a value by using reference sequence number of the incoming update.
Using all the stored versions, we can then distinguish amongst different read policies. Below are the policies we support:
Atomic: Atomicity requires a linearizable register. A linearizable register behaves as if there is only a single copy of the data, and that every operation appears to take effect atomically at one point in time. This definition implies that operations are executed in an well-defined order. On a concurrent update, we perform a compare-and-set operation, where we compare a register sequence number with the incoming reference sequence number. The earliest operation overwriting prior sequence numbers wins since every client reaches to an agreement on the value. So we can safely return the first value.
LWW: The last write to a key always wins.
Use IConsensusRegisterCollection for typing and ConsensusRegisterCollectionFactory to create instances. This implementation class will be removed in a future release.
To use, import via @fluidframework/register-collection/legacy.
For more information about our API support guarantees, see here.
Signature
export declare class ConsensusRegisterCollection<T> extends SharedObject<IConsensusRegisterCollectionEvents> implements IConsensusRegisterCollection<T>
Extends: SharedObject<IConsensusRegisterCollectionEvents>
Implements: IConsensusRegisterCollection<T>
Type Parameters
| Parameter | Description |
|---|---|
| T |
Constructors
| Constructor | Alerts | Description |
|---|---|---|
| (constructor)(id, runtime, attributes) | Beta | Constructs a new consensus register collection. If the object is non-local an id and service interfaces will be provided |
Methods
| Method | Alerts | Modifiers | Return Type | Description |
|---|---|---|---|---|
| applyStashedOp(content) | Beta | void | ||
| keys() | Beta | string[] | ||
| loadCore(storage) | Beta | Promise<void> | ||
| onDisconnect() | Beta | void | ||
| processMessagesCore(messagesCollection) | Beta | void | ||
| read(key, readPolicy) | Beta | T | undefined | Returns the most recent local value of a register. | |
| readVersions(key) | Beta | T[] | undefined | ||
| rollback(content, localOpMetadata) | Beta | sealed | void | |
| summarizeCore(serializer) | Beta | ISummaryTreeWithStats | ||
| write(key, value) | Beta | Promise<boolean> | Creates a new register or writes a new value. Returns a promise that will resolve when the write is acked. |
Constructor Details
(constructor)
Constructs a new consensus register collection. If the object is non-local an id and service interfaces will be provided
For more information about our API support guarantees, see here.
Signature
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | |
| runtime | IFluidDataStoreRuntime | |
| attributes | IChannelAttributes |