Consensus Ordered Collection interface
An consensus ordered collection is a distributed data structure, which holds a collection of JSON-able or handles, and has a deterministic add/remove order.
export interface IConsensusOrderedCollection<T = any> extends ISharedObject<IConsensusOrderedCollectionEvents<T>>
The order the server receive the add/remove operation determines the order those operation are applied to the collection. Different clients issuing
acquire operations at the same time will be sequenced. The order dictates which
add is done first, thus determining the order in which it appears in the collection. It also determines which client will get the first removed item, etc. All operations are asynchronous. A function
waitAndAcquire is provided to wait for and remove an entry in the collection.
As a client acquires an item, it processes it and then returns a value (via callback) indicating whether it has completed processing the item, or whether the item should be released back to the collection for another client to process.
All objects added to the collection will be cloned (via JSON). They will not be references to the original input object. Thus changed to the input object will not reflect the object in the collection.
|acquire(callback)||Retrieves a value from the collection.|
|add(value)||Adds a value to the collection|
|waitAndAcquire(callback)||Wait for a value to be available and remove it from the consensus collection Calls callback with retrieved value.|
Retrieves a value from the collection.
acquire(callback: ConsensusCallback<T>): Promise<boolean>;
Returns true (and calls callback with acquired value) if collection was not empty. Otherwise returns false.
Adds a value to the collection
add(value: T): Promise<void>;
Wait for a value to be available and remove it from the consensus collection Calls callback with retrieved value.
waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;