Skip to main content

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.

This API is deprecated and will be removed in a future release.

Use IConsensusRegisterCollection for typing and ConsensusRegisterCollectionFactory to create instances. This implementation class will be removed in a future release.

This API is provided for existing users, but is not recommended for new users.

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​

ParameterDescription
T

Constructors​

ConstructorAlertsDescription
(constructor)(id, runtime, attributes)BetaConstructs a new consensus register collection. If the object is non-local an id and service interfaces will be provided

Methods​

MethodAlertsModifiersReturn TypeDescription
applyStashedOp(content)Betavoid
keys()Betastring[]
loadCore(storage)BetaPromise<void>
onDisconnect()Betavoid
processMessagesCore(messagesCollection)Betavoid
read(key, readPolicy)BetaT | undefinedReturns the most recent local value of a register.
readVersions(key)BetaT[] | undefined
rollback(content, localOpMetadata)Betasealedvoid
summarizeCore(serializer)BetaISummaryTreeWithStats
write(key, value)BetaPromise<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

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);

Parameters​

ParameterTypeDescription
idstring
runtimeIFluidDataStoreRuntime
attributesIChannelAttributes

Method Details​

applyStashedOp​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

protected applyStashedOp(content: unknown): void;

Parameters​

ParameterTypeDescription
contentunknown

keys​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

keys(): string[];

Returns​

Return type: string[]

loadCore​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

protected loadCore(storage: IChannelStorageService): Promise<void>;

Parameters​

ParameterTypeDescription
storageIChannelStorageService

Returns​

Return type: Promise<void>

onDisconnect​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

protected onDisconnect(): void;

processMessagesCore​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

protected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;

Parameters​

ParameterTypeDescription
messagesCollectionIRuntimeMessageCollection

read​

Returns the most recent local value of a register.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

read(key: string, readPolicy?: ReadPolicy): T | undefined;

Parameters​

ParameterModifiersTypeDescription
keystringThe key to read
readPolicyoptionalReadPolicyThe ReadPolicy to apply. Defaults to Atomic.

Returns​

Return type: T | undefined

readVersions​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

readVersions(key: string): T[] | undefined;

Parameters​

ParameterTypeDescription
keystring

Returns​

Return type: T[] | undefined

rollback​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature​

/** @sealed */
protected rollback(content: unknown, localOpMetadata: unknown): void;

Parameters​

ParameterTypeDescription
contentunknown
localOpMetadataunknown

summarizeCore​

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;

Parameters​

ParameterTypeDescription
serializerIFluidSerializer

Returns​

Return type: ISummaryTreeWithStats

write​

Creates a new register or writes a new value. Returns a promise that will resolve when the write is acked.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature​

write(key: string, value: T): Promise<boolean>;

Parameters​

ParameterTypeDescription
keystring
valueT

Returns​

Promise if write was non-concurrent

Return type: Promise<boolean>