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

Parameter Default Description
T any

Constructors

Constructor Description
(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

Method Return Type Description
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

Parameter Type Description
id string
runtime IFluidDataStoreRuntime
attributes IChannelAttributes
data IOrderedCollection<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

Parameter Type Description
callback ConsensusCallback<T>

Returns

Return type: Promise<boolean>

add

Add a value to the consensus collection.

Signature

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

Parameters

Parameter Type Description
value T

Returns

Return type: Promise<void>

applyStashedOp

Signature

protected applyStashedOp(): void;

complete

Signature

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

Parameters

Parameter Type Description
acquireId string

Returns

Return type: Promise<void>

completeCore

Signature

protected completeCore(acquireId: string): void;

Parameters

Parameter Type Description
acquireId string

isActive

Signature

protected isActive(): boolean;

Returns

Return type: boolean

loadCore

Signature

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

Parameters

Parameter Type Description
storage IChannelStorageService

Returns

Return type: Promise<void>

onDisconnect

Signature

protected onDisconnect(): void;

processCore

Signature

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

Parameters

Parameter Type Description
message ISequencedDocumentMessage
local boolean
localOpMetadata unknown

release

Signature

protected release(acquireId: string): void;

Parameters

Parameter Type Description
acquireId string

releaseCore

Signature

protected releaseCore(acquireId: string): void;

Parameters

Parameter Type Description
acquireId string

summarizeCore

Signature

protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;

Parameters

Parameter Type Description
serializer IFluidSerializer

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

Parameter Type Description
callback ConsensusCallback<T>

Returns

Return type: Promise<void>