@fluidframework/task-manager 2.0.0-rc.2.0.2 → 2.0.0-rc.3.0.1

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/api-report/task-manager.api.md +5 -5
  3. package/dist/interfaces.d.ts +3 -3
  4. package/dist/interfaces.js.map +1 -1
  5. package/dist/legacy.d.ts +17 -0
  6. package/dist/packageVersion.d.ts +1 -1
  7. package/dist/packageVersion.js +1 -1
  8. package/dist/packageVersion.js.map +1 -1
  9. package/dist/public.d.ts +12 -0
  10. package/dist/taskManager.d.ts +4 -3
  11. package/dist/taskManager.d.ts.map +1 -1
  12. package/dist/taskManager.js +22 -22
  13. package/dist/taskManager.js.map +1 -1
  14. package/dist/taskManagerFactory.d.ts +1 -1
  15. package/dist/taskManagerFactory.d.ts.map +1 -1
  16. package/dist/taskManagerFactory.js +1 -1
  17. package/dist/taskManagerFactory.js.map +1 -1
  18. package/internal.d.ts +11 -0
  19. package/legacy.d.ts +11 -0
  20. package/lib/interfaces.d.ts +3 -3
  21. package/lib/interfaces.js.map +1 -1
  22. package/lib/legacy.d.ts +17 -0
  23. package/lib/packageVersion.d.ts +1 -1
  24. package/lib/packageVersion.js +1 -1
  25. package/lib/packageVersion.js.map +1 -1
  26. package/lib/public.d.ts +12 -0
  27. package/lib/taskManager.d.ts +4 -3
  28. package/lib/taskManager.d.ts.map +1 -1
  29. package/lib/taskManager.js +4 -4
  30. package/lib/taskManager.js.map +1 -1
  31. package/lib/taskManagerFactory.d.ts +1 -1
  32. package/lib/taskManagerFactory.d.ts.map +1 -1
  33. package/lib/taskManagerFactory.js +1 -1
  34. package/lib/taskManagerFactory.js.map +1 -1
  35. package/package.json +36 -47
  36. package/src/interfaces.ts +3 -3
  37. package/src/packageVersion.ts +1 -1
  38. package/src/taskManager.ts +11 -13
  39. package/src/taskManagerFactory.ts +4 -3
  40. package/api-extractor-cjs.json +0 -8
  41. package/dist/task-manager-alpha.d.ts +0 -27
  42. package/dist/task-manager-beta.d.ts +0 -29
  43. package/dist/task-manager-public.d.ts +0 -29
  44. package/dist/task-manager-untrimmed.d.ts +0 -335
  45. package/lib/task-manager-alpha.d.ts +0 -27
  46. package/lib/task-manager-beta.d.ts +0 -29
  47. package/lib/task-manager-public.d.ts +0 -29
  48. package/lib/task-manager-untrimmed.d.ts +0 -335
  49. package/lib/test/dirname.cjs +0 -16
  50. package/lib/test/dirname.cjs.map +0 -1
  51. package/lib/test/taskManager.fuzz.spec.js +0 -203
  52. package/lib/test/taskManager.fuzz.spec.js.map +0 -1
  53. package/lib/test/taskManager.spec.js +0 -845
  54. package/lib/test/taskManager.spec.js.map +0 -1
  55. package/lib/test/types/validateTaskManagerPrevious.generated.js +0 -12
  56. package/lib/test/types/validateTaskManagerPrevious.generated.js.map +0 -1
  57. /package/{dist → lib}/tsdoc-metadata.json +0 -0
@@ -1,335 +0,0 @@
1
- /**
2
- * Contains a distributed data structure, {@link ITaskManager}, to track the queues of clients that want to
3
- * exclusively run tasks.
4
- *
5
- * @packageDocumentation
6
- */
7
-
8
- import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
- import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
- import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
- import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
- import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
- import { ISharedObject } from '@fluidframework/shared-object-base';
15
- import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
- import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
18
-
19
- /**
20
- * A distributed data structure that tracks queues of clients that want to exclusively run a task.
21
- *
22
- * @example Creation
23
- *
24
- * To create a {@link TaskManager}, call the static create method:
25
- *
26
- * ```typescript
27
- * const taskManager = TaskManager.create(this.runtime, id);
28
- * ```
29
- *
30
- * @example Usage
31
- *
32
- * To volunteer for a task, use the {@link ITaskManager.volunteerForTask} method.
33
- * This returns a Promise that will resolve once the client has acquired exclusive rights to run the task,
34
- * or reject if the client is removed from the queue without acquiring the rights.
35
- *
36
- * ```typescript
37
- * taskManager.volunteerForTask("NameOfTask")
38
- * .then(() => { doTheTask(); })
39
- * .catch((err) => { console.error(err); });
40
- * ```
41
- *
42
- * Alternatively, you can indefinitely volunteer for a task with the synchronous {@link ITaskManager.subscribeToTask}
43
- * method. This method does not return a value, therefore you need to rely on eventing to know when you have acquired
44
- * the rights to run the task (see below).
45
- *
46
- * ```typescript
47
- * taskManager.subscribeToTask("NameOfTask");
48
- * ```
49
- *
50
- * To check if the local client is currently subscribed to a task, use the {@link ITaskManager.subscribed} method.
51
- *
52
- * ```typescript
53
- * if (taskManager.subscribed("NameOfTask")) {
54
- * console.log("This client is currently subscribed to the task.");
55
- * }
56
- * ```
57
- *
58
- * To release the rights to the task, use the {@link ITaskManager.abandon} method.
59
- * The next client in the queue will then get the rights to run the task.
60
- *
61
- * ```typescript
62
- * taskManager.abandon("NameOfTask");
63
- * ```
64
- *
65
- * To inspect your state in the queue, you can use the {@link ITaskManager.queued} and {@link ITaskManager.assigned}
66
- * methods.
67
- *
68
- * ```typescript
69
- * if (taskManager.queued("NameOfTask")) {
70
- * console.log("This client is somewhere in the queue, potentially even having the task assignment.");
71
- * }
72
- *
73
- * if (taskManager.assigned("NameOfTask")) {
74
- * console.log("This client currently has the rights to run the task");
75
- * }
76
- * ```
77
- *
78
- * To signal to other connected clients that a task is completed, use the {@link ITaskManager.complete} method.
79
- * This will release all clients from the queue and emit the "completed" event.
80
- *
81
- * ```typescript
82
- * taskManager.complete("NameOfTask");
83
- * ```
84
- *
85
- * @example Eventing
86
- *
87
- * `ITaskManager` will emit events when a task is assigned to the client, when the task assignment is lost,
88
- * and when a task was completed by another client.
89
- *
90
- * ```typescript
91
- * taskManager.on("assigned", (taskId: string) => {
92
- * console.log(`Client was assigned task: ${taskId}`);
93
- * });
94
- *
95
- * taskManager.on("lost", (taskId: string) => {
96
- * console.log(`Client released task: ${taskId}`);
97
- * });
98
- *
99
- * taskManager.on("completed", (taskId: string) => {
100
- * console.log(`Another client completed task: ${taskId}`);
101
- * });
102
- * ```
103
- *
104
- * These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as
105
- * when using {@link ITaskManager.subscribeToTask}.
106
- *
107
- * See {@link ITaskManagerEvents} for more details.
108
- * @internal
109
- */
110
- export declare interface ITaskManager extends ISharedObject<ITaskManagerEvents> {
111
- /**
112
- * Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and
113
- * `false` if the task was completed by another client. It rejects if the local client abandoned the task or
114
- * disconnected while in queue.
115
- * @param taskId - Identifier for the task
116
- */
117
- volunteerForTask(taskId: string): Promise<boolean>;
118
- /**
119
- * Continuously volunteer for the task. Watch the "assigned" event to determine if the task is assigned.
120
- * The local client will automatically re-enter the queue if it disconnects.
121
- * @param taskId - Identifier for the task
122
- */
123
- subscribeToTask(taskId: string): void;
124
- /**
125
- * Exit the queue, releasing the task if currently assigned.
126
- * @param taskId - Identifier for the task
127
- */
128
- abandon(taskId: string): void;
129
- /**
130
- * Check whether this client is the current assignee for the task and there is no outstanding abandon op that
131
- * would abandon the assignment.
132
- * @param taskId - Identifier for the task
133
- */
134
- assigned(taskId: string): boolean;
135
- /**
136
- * Check whether this client is either the current assignee, in queue, or we expect they will be in queue after
137
- * outstanding ops have been ack'd.
138
- * @param taskId - Identifier for the task
139
- */
140
- queued(taskId: string): boolean;
141
- /**
142
- * Check whether this client is currently subscribed to the task.
143
- * @param taskId - Identifier for the task
144
- */
145
- subscribed(taskId: string): boolean;
146
- /**
147
- * Marks a task as completed and releases all clients from its queue.
148
- * @param taskId - Identifier for the task
149
- */
150
- complete(taskId: string): void;
151
- /**
152
- * Check whether this client can currently volunteer for a task.
153
- */
154
- canVolunteer(): boolean;
155
- }
156
-
157
- /**
158
- * Events emitted by {@link TaskManager}.
159
- * @internal
160
- */
161
- export declare interface ITaskManagerEvents extends ISharedObjectEvents {
162
- /**
163
- * Fires when a task has been exclusively assigned to the client.
164
- *
165
- * @remarks Does not account for known pending ops, but instead only reflects the current state.
166
- *
167
- * @eventProperty
168
- */
169
- (event: "assigned", listener: TaskEventListener): any;
170
- /**
171
- * Fires when a task the client is queued for is completed.
172
- *
173
- * @eventProperty
174
- */
175
- (event: "completed", listener: TaskEventListener): any;
176
- /**
177
- * Fires when the task assignment is lost by the local client.
178
- *
179
- * @remarks This could be due to the client disconnecting or by manually calling {@link ITaskManager.abandon}.
180
- *
181
- * @eventProperty
182
- */
183
- (event: "lost", listener: TaskEventListener): any;
184
- }
185
-
186
- /**
187
- * Describes the event listener format for {@link ITaskManagerEvents} events.
188
- *
189
- * @param taskId - The unique identifier of the related task.
190
- * @internal
191
- */
192
- export declare type TaskEventListener = (taskId: string) => void;
193
-
194
- /**
195
- * {@inheritDoc ITaskManager}
196
- *
197
- * @sealed
198
- * @internal
199
- */
200
- export declare class TaskManager extends SharedObject<ITaskManagerEvents> implements ITaskManager {
201
- /**
202
- * Create a new TaskManager
203
- *
204
- * @param runtime - data store runtime the new task queue belongs to
205
- * @param id - optional name of the task queue
206
- * @returns newly create task queue (but not attached yet)
207
- */
208
- static create(runtime: IFluidDataStoreRuntime, id?: string): TaskManager;
209
- /**
210
- * Get a factory for TaskManager to register with the data store.
211
- *
212
- * @returns a factory that creates and load TaskManager
213
- */
214
- static getFactory(): IChannelFactory;
215
- /**
216
- * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the
217
- * queue, even if we know we've submitted an op that should eventually modify the queue.
218
- */
219
- private readonly taskQueues;
220
- private readonly opWatcher;
221
- private readonly queueWatcher;
222
- private readonly abandonWatcher;
223
- private readonly connectionWatcher;
224
- private readonly completedWatcher;
225
- private messageId;
226
- /**
227
- * Tracks the most recent pending op for a given task
228
- */
229
- private readonly latestPendingOps;
230
- /**
231
- * Tracks tasks that are this client is currently subscribed to.
232
- */
233
- private readonly subscribedTasks;
234
- /**
235
- * Map to track tasks that have pending complete ops.
236
- */
237
- private readonly pendingCompletedTasks;
238
- /**
239
- * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.
240
- */
241
- private get clientId();
242
- /**
243
- * Returns a ReadOnlyInfo object to determine current read/write permissions.
244
- */
245
- private get readOnlyInfo();
246
- /**
247
- * Constructs a new task manager. If the object is non-local an id and service interfaces will
248
- * be provided
249
- *
250
- * @param runtime - data store runtime the task queue belongs to
251
- * @param id - optional name of the task queue
252
- */
253
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
254
- private submitVolunteerOp;
255
- private submitAbandonOp;
256
- private submitCompleteOp;
257
- /**
258
- * {@inheritDoc ITaskManager.volunteerForTask}
259
- */
260
- volunteerForTask(taskId: string): Promise<boolean>;
261
- /**
262
- * {@inheritDoc ITaskManager.subscribeToTask}
263
- */
264
- subscribeToTask(taskId: string): void;
265
- /**
266
- * {@inheritDoc ITaskManager.abandon}
267
- */
268
- abandon(taskId: string): void;
269
- /**
270
- * {@inheritDoc ITaskManager.assigned}
271
- */
272
- assigned(taskId: string): boolean;
273
- /**
274
- * {@inheritDoc ITaskManager.queued}
275
- */
276
- queued(taskId: string): boolean;
277
- /**
278
- * {@inheritDoc ITaskManager.subscribed}
279
- */
280
- subscribed(taskId: string): boolean;
281
- /**
282
- * {@inheritDoc ITaskManager.complete}
283
- */
284
- complete(taskId: string): void;
285
- /**
286
- * {@inheritDoc ITaskManager.canVolunteer}
287
- */
288
- canVolunteer(): boolean;
289
- /**
290
- * Create a summary for the task manager
291
- *
292
- * @returns the summary of the current state of the task manager
293
- */
294
- protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
295
- /**
296
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
297
- */
298
- protected loadCore(storage: IChannelStorageService): Promise<void>;
299
- /***/
300
- protected initializeLocalCore(): void;
301
- /**
302
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
303
- */
304
- protected onDisconnect(): void;
305
- /**
306
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
307
- */
308
- protected onConnect(): void;
309
- /**
310
- * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the
311
- * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.
312
- */
313
- protected reSubmitCore(): void;
314
- /**
315
- * Process a task manager operation
316
- *
317
- * @param message - the message to prepare
318
- * @param local - whether the message was sent by the local client
319
- * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
320
- * For messages from a remote client, this will be undefined.
321
- */
322
- protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
323
- private addClientToQueue;
324
- private removeClientFromQueue;
325
- private removeClientFromAllQueues;
326
- /**
327
- * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when
328
- * transitioning from detached to attached and this.runtime.clientId is defined.
329
- */
330
- private replacePlaceholderInAllQueues;
331
- private scrubClientsNotInQuorum;
332
- protected applyStashedOp(content: any): void;
333
- }
334
-
335
- export { }
@@ -1,27 +0,0 @@
1
- /**
2
- * Contains a distributed data structure, {@link ITaskManager}, to track the queues of clients that want to
3
- * exclusively run tasks.
4
- *
5
- * @packageDocumentation
6
- */
7
-
8
- import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
- import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
- import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
- import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
- import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
- import { ISharedObject } from '@fluidframework/shared-object-base';
15
- import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
- import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
18
-
19
- /* Excluded from this release type: ITaskManager */
20
-
21
- /* Excluded from this release type: ITaskManagerEvents */
22
-
23
- /* Excluded from this release type: TaskEventListener */
24
-
25
- /* Excluded from this release type: TaskManager */
26
-
27
- export { }
@@ -1,29 +0,0 @@
1
- /**
2
- * Contains a distributed data structure, {@link ITaskManager}, to track the queues of clients that want to
3
- * exclusively run tasks.
4
- *
5
- * @packageDocumentation
6
- */
7
-
8
- import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
- import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
- import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
- import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
- import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
- import { ISharedObject } from '@fluidframework/shared-object-base';
15
- import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
- import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
18
-
19
- /* Excluded from this release type: ITaskManager */
20
-
21
- /* Excluded from this release type: ITaskManagerEvents */
22
-
23
- /* Excluded from this release type: SharedObject */
24
-
25
- /* Excluded from this release type: TaskEventListener */
26
-
27
- /* Excluded from this release type: TaskManager */
28
-
29
- export { }
@@ -1,29 +0,0 @@
1
- /**
2
- * Contains a distributed data structure, {@link ITaskManager}, to track the queues of clients that want to
3
- * exclusively run tasks.
4
- *
5
- * @packageDocumentation
6
- */
7
-
8
- import { IChannelAttributes } from '@fluidframework/datastore-definitions';
9
- import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
- import { IChannelStorageService } from '@fluidframework/datastore-definitions';
11
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
- import { IFluidSerializer } from '@fluidframework/shared-object-base';
13
- import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
14
- import { ISharedObject } from '@fluidframework/shared-object-base';
15
- import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
16
- import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { SharedObject } from '@fluidframework/shared-object-base';
18
-
19
- /* Excluded from this release type: ITaskManager */
20
-
21
- /* Excluded from this release type: ITaskManagerEvents */
22
-
23
- /* Excluded from this release type: SharedObject */
24
-
25
- /* Excluded from this release type: TaskEventListener */
26
-
27
- /* Excluded from this release type: TaskManager */
28
-
29
- export { }