@fluidframework/task-manager 2.0.0-internal.2.2.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.
Files changed (54) hide show
  1. package/.eslintrc.js +14 -0
  2. package/.mocharc.js +12 -0
  3. package/LICENSE +21 -0
  4. package/README.md +36 -0
  5. package/api-extractor.json +4 -0
  6. package/dist/index.d.ts +7 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +10 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/interfaces.d.ts +65 -0
  11. package/dist/interfaces.d.ts.map +1 -0
  12. package/dist/interfaces.js +7 -0
  13. package/dist/interfaces.js.map +1 -0
  14. package/dist/packageVersion.d.ts +9 -0
  15. package/dist/packageVersion.d.ts.map +1 -0
  16. package/dist/packageVersion.js +12 -0
  17. package/dist/packageVersion.js.map +1 -0
  18. package/dist/taskManager.d.ts +242 -0
  19. package/dist/taskManager.d.ts.map +1 -0
  20. package/dist/taskManager.js +715 -0
  21. package/dist/taskManager.js.map +1 -0
  22. package/dist/taskManagerFactory.d.ts +21 -0
  23. package/dist/taskManagerFactory.d.ts.map +1 -0
  24. package/dist/taskManagerFactory.js +41 -0
  25. package/dist/taskManagerFactory.js.map +1 -0
  26. package/lib/index.d.ts +7 -0
  27. package/lib/index.d.ts.map +1 -0
  28. package/lib/index.js +6 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/interfaces.d.ts +65 -0
  31. package/lib/interfaces.d.ts.map +1 -0
  32. package/lib/interfaces.js +6 -0
  33. package/lib/interfaces.js.map +1 -0
  34. package/lib/packageVersion.d.ts +9 -0
  35. package/lib/packageVersion.d.ts.map +1 -0
  36. package/lib/packageVersion.js +9 -0
  37. package/lib/packageVersion.js.map +1 -0
  38. package/lib/taskManager.d.ts +242 -0
  39. package/lib/taskManager.d.ts.map +1 -0
  40. package/lib/taskManager.js +711 -0
  41. package/lib/taskManager.js.map +1 -0
  42. package/lib/taskManagerFactory.d.ts +21 -0
  43. package/lib/taskManagerFactory.d.ts.map +1 -0
  44. package/lib/taskManagerFactory.js +37 -0
  45. package/lib/taskManagerFactory.js.map +1 -0
  46. package/package.json +116 -0
  47. package/prettier.config.cjs +8 -0
  48. package/src/index.ts +7 -0
  49. package/src/interfaces.ts +74 -0
  50. package/src/packageVersion.ts +9 -0
  51. package/src/taskManager.ts +832 -0
  52. package/src/taskManagerFactory.ts +54 -0
  53. package/tsconfig.esnext.json +7 -0
  54. package/tsconfig.json +14 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ "extends": [
8
+ require.resolve("@fluidframework/eslint-config-fluid"),
9
+ "prettier"
10
+ ],
11
+ "parserOptions": {
12
+ "project": ["./tsconfig.json", "./src/test/tsconfig.json"]
13
+ },
14
+ }
package/.mocharc.js ADDED
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
9
+
10
+ const packageDir = __dirname;
11
+ const config = getFluidTestMochaConfig(packageDir);
12
+ module.exports = config;
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Microsoft Corporation and contributors. All rights reserved.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @fluidframework/task-manager
2
+
3
+ <!-- AUTO-GENERATED-CONTENT:START (README_SIMPLE:scripts=FALSE) -->
4
+ <!-- This section is automatically generated.
5
+ To update it, edit docs/md-magic.config.js then run 'npm run build:md-magic' in the docs folder. -->
6
+
7
+ ## Installation
8
+
9
+ To get started, install the package by running the following command:
10
+
11
+ ```bash
12
+ npm i @fluidframework/task-manager
13
+ ```
14
+
15
+ ## API Documentation
16
+
17
+ API documentation for **@fluidframework/task-manager** is available at <https://fluidframework.com/docs/apis/task-manager>.
18
+
19
+ ## Contribution Guidelines
20
+
21
+ Please refer to our [Github Wiki](https://github.com/microsoft/FluidFramework/wiki/Contributing) for an overview of our contribution guidelines.
22
+
23
+ ## Help
24
+
25
+ Not finding what you're looking for in this README?
26
+ Check out our [Github Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
27
+
28
+ Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
29
+ Thank you!
30
+
31
+ ## Trademark
32
+
33
+ This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
34
+ Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
35
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
36
+ <!-- AUTO-GENERATED-CONTENT:END -->
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "@fluidframework/build-common/api-extractor-common-report.json"
4
+ }
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { ITaskManager, ITaskManagerEvents } from "./interfaces";
6
+ export { TaskManager } from "./taskManager";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TaskManager = void 0;
8
+ var taskManager_1 = require("./taskManager");
9
+ Object.defineProperty(exports, "TaskManager", { enumerable: true, get: function () { return taskManager_1.TaskManager; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6CAA4C;AAAnC,0GAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ITaskManager, ITaskManagerEvents } from \"./interfaces\";\nexport { TaskManager } from \"./taskManager\";\n"]}
@@ -0,0 +1,65 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
6
+ /**
7
+ * Events emitted by {@link TaskManager}.
8
+ */
9
+ export interface ITaskManagerEvents extends ISharedObjectEvents {
10
+ /**
11
+ * Notifies when the local client has reached the front of the queue, left the queue, or a task was completed.
12
+ * Does not account for known pending ops, but instead only reflects the current state.
13
+ */
14
+ (event: "assigned" | "completed" | "lost", listener: (taskId: string) => void): any;
15
+ }
16
+ /**
17
+ * Task manager interface
18
+ */
19
+ export interface ITaskManager extends ISharedObject<ITaskManagerEvents> {
20
+ /**
21
+ * Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and
22
+ * `false` if the task was completed by another client. It rejects if the local client abandoned the task or
23
+ * disconnected while in queue.
24
+ * @param taskId - Identifier for the task
25
+ */
26
+ volunteerForTask(taskId: string): Promise<boolean>;
27
+ /**
28
+ * Continuously volunteer for the task. Watch the "assigned" event to determine if the task is assigned.
29
+ * The local client will automatically re-enter the queue if it disconnects.
30
+ * @param taskId - Identifier for the task
31
+ */
32
+ subscribeToTask(taskId: string): void;
33
+ /**
34
+ * Exit the queue, releasing the task if currently assigned.
35
+ * @param taskId - Identifier for the task
36
+ */
37
+ abandon(taskId: string): void;
38
+ /**
39
+ * Check whether this client is the current assignee for the task and there is no outstanding abandon op that
40
+ * would abandon the assignment.
41
+ * @param taskId - Identifier for the task
42
+ */
43
+ assigned(taskId: string): boolean;
44
+ /**
45
+ * Check whether this client is either the current assignee, in queue, or we expect they will be in queue after
46
+ * outstanding ops have been ack'd.
47
+ * @param taskId - Identifier for the task
48
+ */
49
+ queued(taskId: string): boolean;
50
+ /**
51
+ * Check whether this client is currently subscribed to the task.
52
+ * @param taskId - Identifier for the task
53
+ */
54
+ subscribed(taskId: string): boolean;
55
+ /**
56
+ * Marks a task as completed and releases all clients from its queue.
57
+ * @param taskId - Identifier for the task
58
+ */
59
+ complete(taskId: string): void;
60
+ /**
61
+ * Check whether this client can currently volunteer for a task.
62
+ */
63
+ canVolunteer(): boolean;
64
+ }
65
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC3D;;;OAGG;IACH,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,OAAE;CAClF;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,aAAa,CAAC,kBAAkB,CAAC;IACnE;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnD;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhC;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC;CAC3B"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events emitted by {@link TaskManager}.\n */\nexport interface ITaskManagerEvents extends ISharedObjectEvents {\n /**\n * Notifies when the local client has reached the front of the queue, left the queue, or a task was completed.\n * Does not account for known pending ops, but instead only reflects the current state.\n */\n (event: \"assigned\" | \"completed\" | \"lost\", listener: (taskId: string) => void);\n}\n\n/**\n * Task manager interface\n */\nexport interface ITaskManager extends ISharedObject<ITaskManagerEvents> {\n /**\n * Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and\n * `false` if the task was completed by another client. It rejects if the local client abandoned the task or\n * disconnected while in queue.\n * @param taskId - Identifier for the task\n */\n volunteerForTask(taskId: string): Promise<boolean>;\n\n /**\n * Continuously volunteer for the task. Watch the \"assigned\" event to determine if the task is assigned.\n * The local client will automatically re-enter the queue if it disconnects.\n * @param taskId - Identifier for the task\n */\n subscribeToTask(taskId: string): void;\n\n /**\n * Exit the queue, releasing the task if currently assigned.\n * @param taskId - Identifier for the task\n */\n abandon(taskId: string): void;\n\n /**\n * Check whether this client is the current assignee for the task and there is no outstanding abandon op that\n * would abandon the assignment.\n * @param taskId - Identifier for the task\n */\n assigned(taskId: string): boolean;\n\n /**\n * Check whether this client is either the current assignee, in queue, or we expect they will be in queue after\n * outstanding ops have been ack'd.\n * @param taskId - Identifier for the task\n */\n queued(taskId: string): boolean;\n\n /**\n * Check whether this client is currently subscribed to the task.\n * @param taskId - Identifier for the task\n */\n subscribed(taskId: string): boolean;\n\n /**\n * Marks a task as completed and releases all clients from its queue.\n * @param taskId - Identifier for the task\n */\n complete(taskId: string): void;\n\n /**\n * Check whether this client can currently volunteer for a task.\n */\n canVolunteer(): boolean;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
+ */
7
+ export declare const pkgName = "@fluidframework/task-manager";
8
+ export declare const pkgVersion = "2.0.0-internal.2.2.0";
9
+ //# sourceMappingURL=packageVersion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.pkgVersion = exports.pkgName = void 0;
10
+ exports.pkgName = "@fluidframework/task-manager";
11
+ exports.pkgVersion = "2.0.0-internal.2.2.0";
12
+ //# sourceMappingURL=packageVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/task-manager\";\nexport const pkgVersion = \"2.0.0-internal.2.2.0\";\n"]}
@@ -0,0 +1,242 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
+ import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory } from "@fluidframework/datastore-definitions";
7
+ import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
+ import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
+ import { ITaskManager, ITaskManagerEvents } from "./interfaces";
10
+ /**
11
+ * The TaskManager distributed data structure tracks queues of clients that want to exclusively run a task.
12
+ *
13
+ * @remarks
14
+ *
15
+ * For an in-depth overview, see [TaskManager](https://fluidframework.com/docs/data-structures/task-manager/).
16
+ *
17
+ * ### Creation
18
+ *
19
+ * To create a `TaskManager`, call the static create method:
20
+ *
21
+ * ```typescript
22
+ * const taskManager = TaskManager.create(this.runtime, id);
23
+ * ```
24
+ *
25
+ * ### Usage
26
+ *
27
+ * To volunteer for a task, use the `volunteerForTask()` method. This returns a Promise that will resolve once the
28
+ * client has acquired exclusive rights to run the task, or reject if the client is removed from the queue without
29
+ * acquiring the rights.
30
+ *
31
+ * ```typescript
32
+ * taskManager.volunteerForTask("NameOfTask")
33
+ * .then(() => { doTheTask(); })
34
+ * .catch((err) => { console.error(err); });
35
+ * ```
36
+ *
37
+ * Alternatively, you can indefinitely volunteer for a task with the synchronous `subscribeToTask()` method. This
38
+ * method does not return a value, therefore you need to rely on eventing to know when you have acquired the rights
39
+ * to run the task (see below).
40
+ *
41
+ * ```typescript
42
+ * taskManager.subscribeToTask("NameOfTask");
43
+ * ```
44
+ *
45
+ * To check if the local client is currently subscribed to a task, use the `subscribed()` method.
46
+ * ```typescript
47
+ * if (taskManager.subscribed("NameOfTask")) {
48
+ * console.log("This client is currently subscribed to the task.");
49
+ * }
50
+ * ```
51
+ *
52
+ * To release the rights to the task, use the `abandon()` method. The next client in the queue will then get the
53
+ * rights to run the task.
54
+ *
55
+ * ```typescript
56
+ * taskManager.abandon("NameOfTask");
57
+ * ```
58
+ *
59
+ * To inspect your state in the queue, you can use the `queued()` and `assigned()` methods.
60
+ *
61
+ * ```typescript
62
+ * if (taskManager.queued("NameOfTask")) {
63
+ * console.log("This client is somewhere in the queue, potentially even having the task assignment.");
64
+ * }
65
+ *
66
+ * if (taskManager.assigned("NameOfTask")) {
67
+ * console.log("This client currently has the rights to run the task");
68
+ * }
69
+ * ```
70
+ *
71
+ * To signal to other connected clients that a task is completed, use the `complete()` method. This will release all
72
+ * clients from the queue and emit the "completed" event.
73
+ *
74
+ * ```typescript
75
+ * taskManager.complete("NameOfTask");
76
+ * ```
77
+ *
78
+ * ### Eventing
79
+ *
80
+ * `TaskManager` is an `EventEmitter`, and will emit events when a task is assigned to the client, when the task
81
+ * assignment is lost, and when a task was completed by another client.
82
+ *
83
+ * ```typescript
84
+ * taskManager.on("assigned", (taskId: string) => {
85
+ * console.log(`Client was assigned task: ${taskId}`);
86
+ * });
87
+ *
88
+ * taskManager.on("lost", (taskId: string) => {
89
+ * console.log(`Client released task: ${taskId}`);
90
+ * });
91
+ *
92
+ * taskManager.on("completed", (taskId: string) => {
93
+ * console.log(`Another client completed task: ${taskId}`);
94
+ * });
95
+ * ```
96
+ *
97
+ * These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as
98
+ * when using the `subscribeToTask()` method.
99
+ */
100
+ export declare class TaskManager extends SharedObject<ITaskManagerEvents> implements ITaskManager {
101
+ /**
102
+ * Create a new TaskManager
103
+ *
104
+ * @param runtime - data store runtime the new task queue belongs to
105
+ * @param id - optional name of the task queue
106
+ * @returns newly create task queue (but not attached yet)
107
+ */
108
+ static create(runtime: IFluidDataStoreRuntime, id?: string): TaskManager;
109
+ /**
110
+ * Get a factory for TaskManager to register with the data store.
111
+ *
112
+ * @returns a factory that creates and load TaskManager
113
+ */
114
+ static getFactory(): IChannelFactory;
115
+ /**
116
+ * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the
117
+ * queue, even if we know we've submitted an op that should eventually modify the queue.
118
+ */
119
+ private readonly taskQueues;
120
+ private readonly opWatcher;
121
+ private readonly queueWatcher;
122
+ private readonly abandonWatcher;
123
+ private readonly connectionWatcher;
124
+ private readonly completedWatcher;
125
+ private messageId;
126
+ /**
127
+ * Tracks the most recent pending op for a given task
128
+ */
129
+ private readonly latestPendingOps;
130
+ /**
131
+ * Tracks tasks that are this client is currently subscribed to.
132
+ */
133
+ private readonly subscribedTasks;
134
+ /**
135
+ * Map to track tasks that have pending complete ops.
136
+ */
137
+ private readonly pendingCompletedTasks;
138
+ /**
139
+ * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.
140
+ */
141
+ private get clientId();
142
+ /**
143
+ * Returns a ReadOnlyInfo object to determine current read/write permissions.
144
+ */
145
+ private get readOnlyInfo();
146
+ /**
147
+ * Constructs a new task manager. If the object is non-local an id and service interfaces will
148
+ * be provided
149
+ *
150
+ * @param runtime - data store runtime the task queue belongs to
151
+ * @param id - optional name of the task queue
152
+ */
153
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
154
+ private submitVolunteerOp;
155
+ private submitAbandonOp;
156
+ private submitCompleteOp;
157
+ /**
158
+ * {@inheritDoc ITaskManager.volunteerForTask}
159
+ */
160
+ volunteerForTask(taskId: string): Promise<boolean>;
161
+ /**
162
+ * {@inheritDoc ITaskManager.subscribeToTask}
163
+ */
164
+ subscribeToTask(taskId: string): void;
165
+ /**
166
+ * {@inheritDoc ITaskManager.abandon}
167
+ */
168
+ abandon(taskId: string): void;
169
+ /**
170
+ * {@inheritDoc ITaskManager.assigned}
171
+ */
172
+ assigned(taskId: string): boolean;
173
+ /**
174
+ * {@inheritDoc ITaskManager.queued}
175
+ */
176
+ queued(taskId: string): boolean;
177
+ /**
178
+ * {@inheritDoc ITaskManager.subscribed}
179
+ */
180
+ subscribed(taskId: string): boolean;
181
+ /**
182
+ * {@inheritDoc ITaskManager.complete}
183
+ */
184
+ complete(taskId: string): void;
185
+ /**
186
+ * {@inheritDoc ITaskManager.canVolunteer}
187
+ */
188
+ canVolunteer(): boolean;
189
+ /**
190
+ * Create a summary for the task manager
191
+ *
192
+ * @returns the summary of the current state of the task manager
193
+ * @internal
194
+ */
195
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
196
+ /**
197
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
198
+ * @internal
199
+ */
200
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
201
+ /**
202
+ * @internal
203
+ */
204
+ protected initializeLocalCore(): void;
205
+ /**
206
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
207
+ * @internal
208
+ */
209
+ protected onDisconnect(): void;
210
+ /**
211
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
212
+ * @internal
213
+ */
214
+ protected onConnect(): void;
215
+ /**
216
+ * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the
217
+ * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.
218
+ * @internal
219
+ */
220
+ protected reSubmitCore(): void;
221
+ /**
222
+ * Process a task manager operation
223
+ *
224
+ * @param message - the message to prepare
225
+ * @param local - whether the message was sent by the local client
226
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
227
+ * For messages from a remote client, this will be undefined.
228
+ * @internal
229
+ */
230
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
231
+ private addClientToQueue;
232
+ private removeClientFromQueue;
233
+ private removeClientFromAllQueues;
234
+ /**
235
+ * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when
236
+ * transitioning from detached to attached and this.runtime.clientId is defined.
237
+ */
238
+ private replacePlaceholderInAllQueues;
239
+ private scrubClientsNotInQuorum;
240
+ applyStashedOp(): void;
241
+ }
242
+ //# sourceMappingURL=taskManager.d.ts.map
@@ -0,0 +1 @@
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