Skip to main content
Version: v1

ConsensusOrderedCollection Class

Implementation of a consensus collection shared object

Implements the shared object's communication, and the semantics around the release/complete mechanism following acquire.

Generally not used directly. A derived type will pass in a backing data type IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.

Signature

export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensusOrderedCollectionEvents<T>> implements IConsensusOrderedCollection<T>

Extends: SharedObject<IConsensusOrderedCollectionEvents

Implements: IConsensusOrderedCollection

Type Parameters

ParameterDefaultDescription
Tany

Constructors

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

Methods

MethodReturn TypeDescription
acquire(callback)Promise<boolean>Remove a value from the consensus collection. If the collection is empty, returns false. Otherwise calls callback with the value
add(value)Promise<void>Add a value to the consensus collection.
applyStashedOp()void
complete(acquireId)Promise<void>
completeCore(acquireId)void
isActive()boolean
loadCore(storage)Promise<void>
onDisconnect()void
processCore(message, local, localOpMetadata)void
release(acquireId)void
releaseCore(acquireId)void
summarizeCore(serializer)ISummaryTreeWithStats
waitAndAcquire(callback)Promise<void>Wait for a value to be available and acquire it from the consensus collection

Constructor Details

(constructor)

Constructs a new consensus collection. If the object is non-local an id and service interfaces will be provided

Signature

protected constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, data: IOrderedCollection<T>);

Parameters

ParameterTypeDescription
idstring
runtimeIFluidDataStoreRuntime
attributesIChannelAttributes
dataIOrderedCollection<T>

Method Details

acquire

Remove a value from the consensus collection. If the collection is empty, returns false. Otherwise calls callback with the value

Signature

acquire(callback: ConsensusCallback<T>): Promise<boolean>;

Parameters

ParameterTypeDescription
callbackConsensusCallback<T>

Returns

Return type: Promise<boolean>

add

Add a value to the consensus collection.

Signature

add(value: T): Promise<void>;

Parameters

ParameterTypeDescription
valueT

Returns

Return type: Promise<void>

applyStashedOp

Signature

protected applyStashedOp(): void;

complete

Signature

protected complete(acquireId: string): Promise<void>;

Parameters

ParameterTypeDescription
acquireIdstring

Returns

Return type: Promise<void>

completeCore

Signature

protected completeCore(acquireId: string): void;

Parameters

ParameterTypeDescription
acquireIdstring

isActive

Signature

protected isActive(): boolean;

Returns

Return type: boolean

loadCore

Signature

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

Parameters

ParameterTypeDescription
storageIChannelStorageService

Returns

Return type: Promise<void>

onDisconnect

Signature

protected onDisconnect(): void;

processCore

Signature

protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;

Parameters

ParameterTypeDescription
messageISequencedDocumentMessage
localboolean
localOpMetadataunknown

release

Signature

protected release(acquireId: string): void;

Parameters

ParameterTypeDescription
acquireIdstring

releaseCore

Signature

protected releaseCore(acquireId: string): void;

Parameters

ParameterTypeDescription
acquireIdstring

summarizeCore

Signature

protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;

Parameters

ParameterTypeDescription
serializerIFluidSerializer

Returns

Return type: ISummaryTreeWithStats

waitAndAcquire

Wait for a value to be available and acquire it from the consensus collection

Signature

waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;

Parameters

ParameterTypeDescription
callbackConsensusCallback<T>

Returns

Return type: Promise<void>