@fluidframework/ordered-collection 2.0.0-rc.2.0.2 → 2.0.0-rc.3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/api-report/ordered-collection.api.md +1 -1
- package/dist/consensusOrderedCollection.d.ts +4 -3
- package/dist/consensusOrderedCollection.d.ts.map +1 -1
- package/dist/consensusOrderedCollection.js +11 -11
- package/dist/consensusOrderedCollection.js.map +1 -1
- package/dist/consensusOrderedCollectionFactory.d.ts +1 -1
- package/dist/consensusOrderedCollectionFactory.d.ts.map +1 -1
- package/dist/consensusOrderedCollectionFactory.js.map +1 -1
- package/dist/consensusQueue.d.ts +1 -1
- package/dist/consensusQueue.d.ts.map +1 -1
- package/dist/consensusQueue.js.map +1 -1
- package/dist/interfaces.d.ts +1 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/legacy.d.ts +21 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +12 -0
- package/dist/snapshotableArray.js +2 -2
- package/dist/snapshotableArray.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/consensusOrderedCollection.d.ts +4 -3
- package/lib/consensusOrderedCollection.d.ts.map +1 -1
- package/lib/consensusOrderedCollection.js +3 -3
- package/lib/consensusOrderedCollection.js.map +1 -1
- package/lib/consensusOrderedCollectionFactory.d.ts +1 -1
- package/lib/consensusOrderedCollectionFactory.d.ts.map +1 -1
- package/lib/consensusOrderedCollectionFactory.js.map +1 -1
- package/lib/consensusQueue.d.ts +1 -1
- package/lib/consensusQueue.d.ts.map +1 -1
- package/lib/consensusQueue.js.map +1 -1
- package/lib/interfaces.d.ts +1 -1
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/legacy.d.ts +21 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +12 -0
- package/lib/snapshotableArray.js +1 -1
- package/lib/snapshotableArray.js.map +1 -1
- package/package.json +35 -56
- package/src/consensusOrderedCollection.ts +8 -6
- package/src/consensusOrderedCollectionFactory.ts +2 -1
- package/src/consensusQueue.ts +2 -1
- package/src/interfaces.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/snapshotableArray.ts +1 -1
- package/api-extractor-cjs.json +0 -8
- package/dist/ordered-collection-alpha.d.ts +0 -228
- package/dist/ordered-collection-beta.d.ts +0 -39
- package/dist/ordered-collection-public.d.ts +0 -39
- package/dist/ordered-collection-untrimmed.d.ts +0 -263
- package/lib/ordered-collection-alpha.d.ts +0 -228
- package/lib/ordered-collection-beta.d.ts +0 -39
- package/lib/ordered-collection-public.d.ts +0 -39
- package/lib/ordered-collection-untrimmed.d.ts +0 -263
- package/lib/test/consensusOrderedCollection.spec.js +0 -314
- package/lib/test/consensusOrderedCollection.spec.js.map +0 -1
- package/lib/test/types/validateOrderedCollectionPrevious.generated.js +0 -24
- package/lib/test/types/validateOrderedCollectionPrevious.generated.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
|
-
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
|
-
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
4
|
-
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
5
|
-
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
6
|
-
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
7
|
-
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
8
|
-
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
|
-
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
|
-
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
12
|
-
|
|
13
|
-
/* Excluded from this release type: acquireAndComplete */
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Callback provided to acquire() and waitAndAcquire() methods.
|
|
17
|
-
* @returns ConsensusResult indicating whether item was completed, or releases back to the queue.
|
|
18
|
-
* @alpha
|
|
19
|
-
*/
|
|
20
|
-
export declare type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Implementation of a consensus collection shared object
|
|
24
|
-
*
|
|
25
|
-
* Implements the shared object's communication, and the semantics around the
|
|
26
|
-
* release/complete mechanism following acquire.
|
|
27
|
-
*
|
|
28
|
-
* Generally not used directly. A derived type will pass in a backing data type
|
|
29
|
-
* IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.
|
|
30
|
-
* @alpha
|
|
31
|
-
*/
|
|
32
|
-
export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensusOrderedCollectionEvents<T>> implements IConsensusOrderedCollection<T> {
|
|
33
|
-
private readonly data;
|
|
34
|
-
/**
|
|
35
|
-
* The set of values that have been acquired but not yet completed or released
|
|
36
|
-
*/
|
|
37
|
-
private jobTracking;
|
|
38
|
-
/**
|
|
39
|
-
* Constructs a new consensus collection. If the object is non-local an id and service interfaces will
|
|
40
|
-
* be provided
|
|
41
|
-
*/
|
|
42
|
-
protected constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, data: IOrderedCollection<T>);
|
|
43
|
-
/**
|
|
44
|
-
* Add a value to the consensus collection.
|
|
45
|
-
*/
|
|
46
|
-
add(value: T): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Remove a value from the consensus collection. If the collection is empty, returns false.
|
|
49
|
-
* Otherwise calls callback with the value
|
|
50
|
-
*/
|
|
51
|
-
acquire(callback: ConsensusCallback<T>): Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* Wait for a value to be available and acquire it from the consensus collection
|
|
54
|
-
*/
|
|
55
|
-
waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
|
|
56
|
-
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
57
|
-
protected isActive(): boolean;
|
|
58
|
-
protected complete(acquireId: string): Promise<void>;
|
|
59
|
-
protected completeCore(acquireId: string): void;
|
|
60
|
-
protected release(acquireId: string): void;
|
|
61
|
-
protected releaseCore(acquireId: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
64
|
-
*/
|
|
65
|
-
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
66
|
-
protected onDisconnect(): void;
|
|
67
|
-
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
68
|
-
private submit;
|
|
69
|
-
private addCore;
|
|
70
|
-
private acquireCore;
|
|
71
|
-
private acquireInternal;
|
|
72
|
-
private removeClient;
|
|
73
|
-
private serializeValue;
|
|
74
|
-
private deserializeValue;
|
|
75
|
-
protected applyStashedOp(): void;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Implementation of a consensus stack
|
|
80
|
-
*
|
|
81
|
-
* An derived type of ConsensusOrderedCollection with a queue as the backing data and order.
|
|
82
|
-
* @alpha
|
|
83
|
-
*/
|
|
84
|
-
export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {
|
|
85
|
-
/**
|
|
86
|
-
* Create a new consensus queue
|
|
87
|
-
*
|
|
88
|
-
* @param runtime - data store runtime the new consensus queue belongs to
|
|
89
|
-
* @param id - optional name of theconsensus queue
|
|
90
|
-
* @returns newly create consensus queue (but not attached yet)
|
|
91
|
-
*/
|
|
92
|
-
static create<T = any>(runtime: IFluidDataStoreRuntime, id?: string): ConsensusQueue<T>;
|
|
93
|
-
/**
|
|
94
|
-
* Get a factory for ConsensusQueue to register with the data store.
|
|
95
|
-
*
|
|
96
|
-
* @returns a factory that creates and load ConsensusQueue
|
|
97
|
-
*/
|
|
98
|
-
static getFactory(): IChannelFactory;
|
|
99
|
-
/**
|
|
100
|
-
* Constructs a new consensus queue. If the object is non-local an id and service interfaces will
|
|
101
|
-
* be provided
|
|
102
|
-
*/
|
|
103
|
-
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/* Excluded from this release type: ConsensusQueueFactory */
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @alpha
|
|
110
|
-
*/
|
|
111
|
-
export declare enum ConsensusResult {
|
|
112
|
-
Release = 0,
|
|
113
|
-
Complete = 1
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Consensus Ordered Collection interface
|
|
118
|
-
*
|
|
119
|
-
* An consensus ordered collection is a distributed data structure, which
|
|
120
|
-
* holds a collection of JSON-able or handles, and has a
|
|
121
|
-
* deterministic add/remove order.
|
|
122
|
-
*
|
|
123
|
-
* @remarks
|
|
124
|
-
* The order the server receive the add/remove operation determines the
|
|
125
|
-
* order those operation are applied to the collection. Different clients
|
|
126
|
-
* issuing `add` or `acquire` operations at the same time will be sequenced.
|
|
127
|
-
* The order dictates which `add` is done first, thus determining the order
|
|
128
|
-
* in which it appears in the collection. It also determines which client
|
|
129
|
-
* will get the first removed item, etc. All operations are asynchronous.
|
|
130
|
-
* A function `waitAndAcquire` is provided to wait for and remove an entry in the collection.
|
|
131
|
-
*
|
|
132
|
-
* As a client acquires an item, it processes it and then returns a value (via callback)
|
|
133
|
-
* indicating whether it has completed processing the item, or whether the item should be
|
|
134
|
-
* released back to the collection for another client to process.
|
|
135
|
-
*
|
|
136
|
-
* All objects added to the collection will be cloned (via JSON).
|
|
137
|
-
* They will not be references to the original input object. Thus changed to
|
|
138
|
-
* the input object will not reflect the object in the collection.
|
|
139
|
-
* @alpha
|
|
140
|
-
*/
|
|
141
|
-
export declare interface IConsensusOrderedCollection<T = any> extends ISharedObject<IConsensusOrderedCollectionEvents<T>> {
|
|
142
|
-
/**
|
|
143
|
-
* Adds a value to the collection
|
|
144
|
-
*/
|
|
145
|
-
add(value: T): Promise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* Retrieves a value from the collection.
|
|
148
|
-
* @returns Returns true (and calls callback with acquired value) if collection was not empty.
|
|
149
|
-
* Otherwise returns false.
|
|
150
|
-
*/
|
|
151
|
-
acquire(callback: ConsensusCallback<T>): Promise<boolean>;
|
|
152
|
-
/**
|
|
153
|
-
* Wait for a value to be available and remove it from the consensus collection
|
|
154
|
-
* Calls callback with retrieved value.
|
|
155
|
-
*/
|
|
156
|
-
waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Events notifying about addition, acquisition, release and completion of items
|
|
161
|
-
* @alpha
|
|
162
|
-
*/
|
|
163
|
-
export declare interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {
|
|
164
|
-
/**
|
|
165
|
-
* Event fires when new item is added to the queue or
|
|
166
|
-
* an item previously acquired is returned back to a queue (including client loosing connection)
|
|
167
|
-
* @param newlyAdded - indicates if it's newly added item of previously acquired item
|
|
168
|
-
*/
|
|
169
|
-
(event: "add", listener: (value: T, newlyAdded: boolean) => void): this;
|
|
170
|
-
/**
|
|
171
|
-
* Event fires when a client acquired an item
|
|
172
|
-
* Fires both for locally acquired items, as well as items acquired by remote clients
|
|
173
|
-
*/
|
|
174
|
-
(event: "acquire", listener: (value: T, clientId?: string) => void): this;
|
|
175
|
-
/**
|
|
176
|
-
* "Complete event fires when a client completes an item.
|
|
177
|
-
*/
|
|
178
|
-
(event: "complete", listener: (value: T) => void): this;
|
|
179
|
-
/**
|
|
180
|
-
* Event fires when locally acquired item is being released back to the queue.
|
|
181
|
-
* Please note that release process is asynchronous, so it takes a while for it to happen
|
|
182
|
-
* ("add" event will be fired as result of it)
|
|
183
|
-
* @param intentional - indicates whether release was intentional (result of returning
|
|
184
|
-
* ConsensusResult.Release from callback) or it happened as result of lost connection.
|
|
185
|
-
*/
|
|
186
|
-
(event: "localRelease", listener: (value: T, intentional: boolean) => void): this;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/* Excluded from this release type: IConsensusOrderedCollectionFactory */
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Ordered Collection interface
|
|
193
|
-
*
|
|
194
|
-
* Collection of objects that has deterministic add and remove ordering.
|
|
195
|
-
* Object implementing this interface can be used as the data backing
|
|
196
|
-
* for the ConsensusOrderedCollection
|
|
197
|
-
* @alpha
|
|
198
|
-
*/
|
|
199
|
-
export declare interface IOrderedCollection<T = any> extends ISnapshotable<T> {
|
|
200
|
-
/**
|
|
201
|
-
* Adds a value to the collection
|
|
202
|
-
*/
|
|
203
|
-
add(value: T): any;
|
|
204
|
-
/**
|
|
205
|
-
* Retrieves a value from the collection.
|
|
206
|
-
*/
|
|
207
|
-
remove(): T;
|
|
208
|
-
/**
|
|
209
|
-
* Return the size of the collection
|
|
210
|
-
*/
|
|
211
|
-
size(): number;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Interface for object that can be snapshoted
|
|
216
|
-
*
|
|
217
|
-
* TODO: move this to be use in other place
|
|
218
|
-
* TODO: currently input and output is not symmetrical, can they become symmetrical?
|
|
219
|
-
* @alpha
|
|
220
|
-
*/
|
|
221
|
-
export declare interface ISnapshotable<T> {
|
|
222
|
-
asArray(): T[];
|
|
223
|
-
loadFrom(values: T[]): void;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/* Excluded from this release type: waitAcquireAndComplete */
|
|
227
|
-
|
|
228
|
-
export { }
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
|
-
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
|
-
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
4
|
-
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
5
|
-
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
6
|
-
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
7
|
-
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
8
|
-
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
|
-
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
|
-
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
12
|
-
|
|
13
|
-
/* Excluded from this release type: acquireAndComplete */
|
|
14
|
-
|
|
15
|
-
/* Excluded from this release type: ConsensusCallback */
|
|
16
|
-
|
|
17
|
-
/* Excluded from this release type: ConsensusOrderedCollection */
|
|
18
|
-
|
|
19
|
-
/* Excluded from this release type: ConsensusQueue */
|
|
20
|
-
|
|
21
|
-
/* Excluded from this release type: ConsensusQueueFactory */
|
|
22
|
-
|
|
23
|
-
/* Excluded from this release type: ConsensusResult */
|
|
24
|
-
|
|
25
|
-
/* Excluded from this release type: IConsensusOrderedCollection */
|
|
26
|
-
|
|
27
|
-
/* Excluded from this release type: IConsensusOrderedCollectionEvents */
|
|
28
|
-
|
|
29
|
-
/* Excluded from this release type: IConsensusOrderedCollectionFactory */
|
|
30
|
-
|
|
31
|
-
/* Excluded from this release type: IOrderedCollection */
|
|
32
|
-
|
|
33
|
-
/* Excluded from this release type: ISnapshotable */
|
|
34
|
-
|
|
35
|
-
/* Excluded from this release type: SharedObject */
|
|
36
|
-
|
|
37
|
-
/* Excluded from this release type: waitAcquireAndComplete */
|
|
38
|
-
|
|
39
|
-
export { }
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
|
-
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
|
-
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
4
|
-
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
5
|
-
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
6
|
-
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
7
|
-
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
8
|
-
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
|
-
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
|
-
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
12
|
-
|
|
13
|
-
/* Excluded from this release type: acquireAndComplete */
|
|
14
|
-
|
|
15
|
-
/* Excluded from this release type: ConsensusCallback */
|
|
16
|
-
|
|
17
|
-
/* Excluded from this release type: ConsensusOrderedCollection */
|
|
18
|
-
|
|
19
|
-
/* Excluded from this release type: ConsensusQueue */
|
|
20
|
-
|
|
21
|
-
/* Excluded from this release type: ConsensusQueueFactory */
|
|
22
|
-
|
|
23
|
-
/* Excluded from this release type: ConsensusResult */
|
|
24
|
-
|
|
25
|
-
/* Excluded from this release type: IConsensusOrderedCollection */
|
|
26
|
-
|
|
27
|
-
/* Excluded from this release type: IConsensusOrderedCollectionEvents */
|
|
28
|
-
|
|
29
|
-
/* Excluded from this release type: IConsensusOrderedCollectionFactory */
|
|
30
|
-
|
|
31
|
-
/* Excluded from this release type: IOrderedCollection */
|
|
32
|
-
|
|
33
|
-
/* Excluded from this release type: ISnapshotable */
|
|
34
|
-
|
|
35
|
-
/* Excluded from this release type: SharedObject */
|
|
36
|
-
|
|
37
|
-
/* Excluded from this release type: waitAcquireAndComplete */
|
|
38
|
-
|
|
39
|
-
export { }
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
2
|
-
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
3
|
-
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
4
|
-
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
5
|
-
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
6
|
-
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
7
|
-
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
8
|
-
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
|
-
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
|
-
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Helper method to acquire and complete an item
|
|
15
|
-
* Should be used in test code only
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export declare function acquireAndComplete<T>(collection: IConsensusOrderedCollection<T>): Promise<T | undefined>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Callback provided to acquire() and waitAndAcquire() methods.
|
|
22
|
-
* @returns ConsensusResult indicating whether item was completed, or releases back to the queue.
|
|
23
|
-
* @alpha
|
|
24
|
-
*/
|
|
25
|
-
export declare type ConsensusCallback<T> = (value: T) => Promise<ConsensusResult>;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Implementation of a consensus collection shared object
|
|
29
|
-
*
|
|
30
|
-
* Implements the shared object's communication, and the semantics around the
|
|
31
|
-
* release/complete mechanism following acquire.
|
|
32
|
-
*
|
|
33
|
-
* Generally not used directly. A derived type will pass in a backing data type
|
|
34
|
-
* IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.
|
|
35
|
-
* @alpha
|
|
36
|
-
*/
|
|
37
|
-
export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensusOrderedCollectionEvents<T>> implements IConsensusOrderedCollection<T> {
|
|
38
|
-
private readonly data;
|
|
39
|
-
/**
|
|
40
|
-
* The set of values that have been acquired but not yet completed or released
|
|
41
|
-
*/
|
|
42
|
-
private jobTracking;
|
|
43
|
-
/**
|
|
44
|
-
* Constructs a new consensus collection. If the object is non-local an id and service interfaces will
|
|
45
|
-
* be provided
|
|
46
|
-
*/
|
|
47
|
-
protected constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, data: IOrderedCollection<T>);
|
|
48
|
-
/**
|
|
49
|
-
* Add a value to the consensus collection.
|
|
50
|
-
*/
|
|
51
|
-
add(value: T): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Remove a value from the consensus collection. If the collection is empty, returns false.
|
|
54
|
-
* Otherwise calls callback with the value
|
|
55
|
-
*/
|
|
56
|
-
acquire(callback: ConsensusCallback<T>): Promise<boolean>;
|
|
57
|
-
/**
|
|
58
|
-
* Wait for a value to be available and acquire it from the consensus collection
|
|
59
|
-
*/
|
|
60
|
-
waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
|
|
61
|
-
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
62
|
-
protected isActive(): boolean;
|
|
63
|
-
protected complete(acquireId: string): Promise<void>;
|
|
64
|
-
protected completeCore(acquireId: string): void;
|
|
65
|
-
protected release(acquireId: string): void;
|
|
66
|
-
protected releaseCore(acquireId: string): void;
|
|
67
|
-
/**
|
|
68
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
69
|
-
*/
|
|
70
|
-
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
71
|
-
protected onDisconnect(): void;
|
|
72
|
-
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
73
|
-
private submit;
|
|
74
|
-
private addCore;
|
|
75
|
-
private acquireCore;
|
|
76
|
-
private acquireInternal;
|
|
77
|
-
private removeClient;
|
|
78
|
-
private serializeValue;
|
|
79
|
-
private deserializeValue;
|
|
80
|
-
protected applyStashedOp(): void;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Implementation of a consensus stack
|
|
85
|
-
*
|
|
86
|
-
* An derived type of ConsensusOrderedCollection with a queue as the backing data and order.
|
|
87
|
-
* @alpha
|
|
88
|
-
*/
|
|
89
|
-
export declare class ConsensusQueue<T = any> extends ConsensusOrderedCollection<T> {
|
|
90
|
-
/**
|
|
91
|
-
* Create a new consensus queue
|
|
92
|
-
*
|
|
93
|
-
* @param runtime - data store runtime the new consensus queue belongs to
|
|
94
|
-
* @param id - optional name of theconsensus queue
|
|
95
|
-
* @returns newly create consensus queue (but not attached yet)
|
|
96
|
-
*/
|
|
97
|
-
static create<T = any>(runtime: IFluidDataStoreRuntime, id?: string): ConsensusQueue<T>;
|
|
98
|
-
/**
|
|
99
|
-
* Get a factory for ConsensusQueue to register with the data store.
|
|
100
|
-
*
|
|
101
|
-
* @returns a factory that creates and load ConsensusQueue
|
|
102
|
-
*/
|
|
103
|
-
static getFactory(): IChannelFactory;
|
|
104
|
-
/**
|
|
105
|
-
* Constructs a new consensus queue. If the object is non-local an id and service interfaces will
|
|
106
|
-
* be provided
|
|
107
|
-
*/
|
|
108
|
-
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The factory that defines the consensus queue
|
|
113
|
-
*
|
|
114
|
-
* @internal
|
|
115
|
-
*/
|
|
116
|
-
export declare class ConsensusQueueFactory implements IConsensusOrderedCollectionFactory {
|
|
117
|
-
static Type: string;
|
|
118
|
-
static readonly Attributes: IChannelAttributes;
|
|
119
|
-
get type(): string;
|
|
120
|
-
get attributes(): IChannelAttributes;
|
|
121
|
-
/**
|
|
122
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
123
|
-
*/
|
|
124
|
-
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusOrderedCollection>;
|
|
125
|
-
create(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @alpha
|
|
130
|
-
*/
|
|
131
|
-
export declare enum ConsensusResult {
|
|
132
|
-
Release = 0,
|
|
133
|
-
Complete = 1
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Consensus Ordered Collection interface
|
|
138
|
-
*
|
|
139
|
-
* An consensus ordered collection is a distributed data structure, which
|
|
140
|
-
* holds a collection of JSON-able or handles, and has a
|
|
141
|
-
* deterministic add/remove order.
|
|
142
|
-
*
|
|
143
|
-
* @remarks
|
|
144
|
-
* The order the server receive the add/remove operation determines the
|
|
145
|
-
* order those operation are applied to the collection. Different clients
|
|
146
|
-
* issuing `add` or `acquire` operations at the same time will be sequenced.
|
|
147
|
-
* The order dictates which `add` is done first, thus determining the order
|
|
148
|
-
* in which it appears in the collection. It also determines which client
|
|
149
|
-
* will get the first removed item, etc. All operations are asynchronous.
|
|
150
|
-
* A function `waitAndAcquire` is provided to wait for and remove an entry in the collection.
|
|
151
|
-
*
|
|
152
|
-
* As a client acquires an item, it processes it and then returns a value (via callback)
|
|
153
|
-
* indicating whether it has completed processing the item, or whether the item should be
|
|
154
|
-
* released back to the collection for another client to process.
|
|
155
|
-
*
|
|
156
|
-
* All objects added to the collection will be cloned (via JSON).
|
|
157
|
-
* They will not be references to the original input object. Thus changed to
|
|
158
|
-
* the input object will not reflect the object in the collection.
|
|
159
|
-
* @alpha
|
|
160
|
-
*/
|
|
161
|
-
export declare interface IConsensusOrderedCollection<T = any> extends ISharedObject<IConsensusOrderedCollectionEvents<T>> {
|
|
162
|
-
/**
|
|
163
|
-
* Adds a value to the collection
|
|
164
|
-
*/
|
|
165
|
-
add(value: T): Promise<void>;
|
|
166
|
-
/**
|
|
167
|
-
* Retrieves a value from the collection.
|
|
168
|
-
* @returns Returns true (and calls callback with acquired value) if collection was not empty.
|
|
169
|
-
* Otherwise returns false.
|
|
170
|
-
*/
|
|
171
|
-
acquire(callback: ConsensusCallback<T>): Promise<boolean>;
|
|
172
|
-
/**
|
|
173
|
-
* Wait for a value to be available and remove it from the consensus collection
|
|
174
|
-
* Calls callback with retrieved value.
|
|
175
|
-
*/
|
|
176
|
-
waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Events notifying about addition, acquisition, release and completion of items
|
|
181
|
-
* @alpha
|
|
182
|
-
*/
|
|
183
|
-
export declare interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvents {
|
|
184
|
-
/**
|
|
185
|
-
* Event fires when new item is added to the queue or
|
|
186
|
-
* an item previously acquired is returned back to a queue (including client loosing connection)
|
|
187
|
-
* @param newlyAdded - indicates if it's newly added item of previously acquired item
|
|
188
|
-
*/
|
|
189
|
-
(event: "add", listener: (value: T, newlyAdded: boolean) => void): this;
|
|
190
|
-
/**
|
|
191
|
-
* Event fires when a client acquired an item
|
|
192
|
-
* Fires both for locally acquired items, as well as items acquired by remote clients
|
|
193
|
-
*/
|
|
194
|
-
(event: "acquire", listener: (value: T, clientId?: string) => void): this;
|
|
195
|
-
/**
|
|
196
|
-
* "Complete event fires when a client completes an item.
|
|
197
|
-
*/
|
|
198
|
-
(event: "complete", listener: (value: T) => void): this;
|
|
199
|
-
/**
|
|
200
|
-
* Event fires when locally acquired item is being released back to the queue.
|
|
201
|
-
* Please note that release process is asynchronous, so it takes a while for it to happen
|
|
202
|
-
* ("add" event will be fired as result of it)
|
|
203
|
-
* @param intentional - indicates whether release was intentional (result of returning
|
|
204
|
-
* ConsensusResult.Release from callback) or it happened as result of lost connection.
|
|
205
|
-
*/
|
|
206
|
-
(event: "localRelease", listener: (value: T, intentional: boolean) => void): this;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Consensus Ordered Collection channel factory interface
|
|
211
|
-
*
|
|
212
|
-
* Extends the base IChannelFactory to return a more definite type of IConsensusOrderedCollection
|
|
213
|
-
* Use for the runtime to create and load distributed data structure by type name of each channel
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
216
|
-
export declare interface IConsensusOrderedCollectionFactory extends IChannelFactory {
|
|
217
|
-
load(document: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<IConsensusOrderedCollection>;
|
|
218
|
-
create(document: IFluidDataStoreRuntime, id: string): IConsensusOrderedCollection;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Ordered Collection interface
|
|
223
|
-
*
|
|
224
|
-
* Collection of objects that has deterministic add and remove ordering.
|
|
225
|
-
* Object implementing this interface can be used as the data backing
|
|
226
|
-
* for the ConsensusOrderedCollection
|
|
227
|
-
* @alpha
|
|
228
|
-
*/
|
|
229
|
-
export declare interface IOrderedCollection<T = any> extends ISnapshotable<T> {
|
|
230
|
-
/**
|
|
231
|
-
* Adds a value to the collection
|
|
232
|
-
*/
|
|
233
|
-
add(value: T): any;
|
|
234
|
-
/**
|
|
235
|
-
* Retrieves a value from the collection.
|
|
236
|
-
*/
|
|
237
|
-
remove(): T;
|
|
238
|
-
/**
|
|
239
|
-
* Return the size of the collection
|
|
240
|
-
*/
|
|
241
|
-
size(): number;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Interface for object that can be snapshoted
|
|
246
|
-
*
|
|
247
|
-
* TODO: move this to be use in other place
|
|
248
|
-
* TODO: currently input and output is not symmetrical, can they become symmetrical?
|
|
249
|
-
* @alpha
|
|
250
|
-
*/
|
|
251
|
-
export declare interface ISnapshotable<T> {
|
|
252
|
-
asArray(): T[];
|
|
253
|
-
loadFrom(values: T[]): void;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Helper method to acquire and complete an item
|
|
258
|
-
* Should be used in test code only
|
|
259
|
-
* @internal
|
|
260
|
-
*/
|
|
261
|
-
export declare function waitAcquireAndComplete<T>(collection: IConsensusOrderedCollection<T>): Promise<T>;
|
|
262
|
-
|
|
263
|
-
export { }
|