@fluidframework/task-manager 2.0.0-internal.4.2.0 → 2.0.0-internal.4.3.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/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { ITaskManager, ITaskManagerEvents } from "./interfaces";
5
+ /**
6
+ * Contains a distributed data structure, {@link ITaskManager}, to track the queues of clients that want to
7
+ * exclusively run tasks.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { ITaskManager, ITaskManagerEvents, TaskEventListener } from "./interfaces";
6
12
  export { TaskManager } from "./taskManager";
7
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,6CAA4C;AAAnC,0GAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Contains a distributed data structure, {@link ITaskManager}, to track the queues of clients that want to\n * exclusively run tasks.\n *\n * @packageDocumentation\n */\n\nexport { ITaskManager, ITaskManagerEvents, TaskEventListener } from \"./interfaces\";\nexport { TaskManager } from \"./taskManager\";\n"]}
@@ -3,18 +3,128 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
6
+ /**
7
+ * Describes the event listener format for {@link ITaskManagerEvents} events.
8
+ *
9
+ * @param taskId - The unique identifier of the related task.
10
+ */
11
+ export declare type TaskEventListener = (taskId: string) => void;
6
12
  /**
7
13
  * Events emitted by {@link TaskManager}.
8
14
  */
9
15
  export interface ITaskManagerEvents extends ISharedObjectEvents {
10
16
  /**
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.
17
+ * Fires when a task has been exclusively assigned to the client.
18
+ *
19
+ * @remarks Does not account for known pending ops, but instead only reflects the current state.
20
+ *
21
+ * @eventProperty
22
+ */
23
+ (event: "assigned", listener: TaskEventListener): any;
24
+ /**
25
+ * Fires when a task the client is queued for is completed.
26
+ *
27
+ * @eventProperty
28
+ */
29
+ (event: "completed", listener: TaskEventListener): any;
30
+ /**
31
+ * Fires when the task assignment is lost by the local client.
32
+ *
33
+ * @remarks This could be due to the client disconnecting or by manually calling {@link ITaskManager.abandon}.
34
+ *
35
+ * @eventProperty
13
36
  */
14
- (event: "assigned" | "completed" | "lost", listener: (taskId: string) => void): any;
37
+ (event: "lost", listener: TaskEventListener): any;
15
38
  }
16
39
  /**
17
- * Task manager interface
40
+ * A distributed data structure that tracks queues of clients that want to exclusively run a task.
41
+ *
42
+ * @example Creation
43
+ *
44
+ * To create a {@link TaskManager}, call the static create method:
45
+ *
46
+ * ```typescript
47
+ * const taskManager = TaskManager.create(this.runtime, id);
48
+ * ```
49
+ *
50
+ * @example Usage
51
+ *
52
+ * To volunteer for a task, use the {@link ITaskManager.volunteerForTask} method.
53
+ * This returns a Promise that will resolve once the client has acquired exclusive rights to run the task,
54
+ * or reject if the client is removed from the queue without acquiring the rights.
55
+ *
56
+ * ```typescript
57
+ * taskManager.volunteerForTask("NameOfTask")
58
+ * .then(() => { doTheTask(); })
59
+ * .catch((err) => { console.error(err); });
60
+ * ```
61
+ *
62
+ * Alternatively, you can indefinitely volunteer for a task with the synchronous {@link ITaskManager.subscribeToTask}
63
+ * method. This method does not return a value, therefore you need to rely on eventing to know when you have acquired
64
+ * the rights to run the task (see below).
65
+ *
66
+ * ```typescript
67
+ * taskManager.subscribeToTask("NameOfTask");
68
+ * ```
69
+ *
70
+ * To check if the local client is currently subscribed to a task, use the {@link ITaskManager.subscribed} method.
71
+ *
72
+ * ```typescript
73
+ * if (taskManager.subscribed("NameOfTask")) {
74
+ * console.log("This client is currently subscribed to the task.");
75
+ * }
76
+ * ```
77
+ *
78
+ * To release the rights to the task, use the {@link ITaskManager.abandon} method.
79
+ * The next client in the queue will then get the rights to run the task.
80
+ *
81
+ * ```typescript
82
+ * taskManager.abandon("NameOfTask");
83
+ * ```
84
+ *
85
+ * To inspect your state in the queue, you can use the {@link ITaskManager.queued} and {@link ITaskManager.assigned}
86
+ * methods.
87
+ *
88
+ * ```typescript
89
+ * if (taskManager.queued("NameOfTask")) {
90
+ * console.log("This client is somewhere in the queue, potentially even having the task assignment.");
91
+ * }
92
+ *
93
+ * if (taskManager.assigned("NameOfTask")) {
94
+ * console.log("This client currently has the rights to run the task");
95
+ * }
96
+ * ```
97
+ *
98
+ * To signal to other connected clients that a task is completed, use the {@link ITaskManager.complete} method.
99
+ * This will release all clients from the queue and emit the "completed" event.
100
+ *
101
+ * ```typescript
102
+ * taskManager.complete("NameOfTask");
103
+ * ```
104
+ *
105
+ * @example Eventing
106
+ *
107
+ * `ITaskManager` will emit events when a task is assigned to the client, when the task assignment is lost,
108
+ * and when a task was completed by another client.
109
+ *
110
+ * ```typescript
111
+ * taskManager.on("assigned", (taskId: string) => {
112
+ * console.log(`Client was assigned task: ${taskId}`);
113
+ * });
114
+ *
115
+ * taskManager.on("lost", (taskId: string) => {
116
+ * console.log(`Client released task: ${taskId}`);
117
+ * });
118
+ *
119
+ * taskManager.on("completed", (taskId: string) => {
120
+ * console.log(`Another client completed task: ${taskId}`);
121
+ * });
122
+ * ```
123
+ *
124
+ * These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as
125
+ * when using {@link ITaskManager.subscribeToTask}.
126
+ *
127
+ * See {@link ITaskManagerEvents} for more details.
18
128
  */
19
129
  export interface ITaskManager extends ISharedObject<ITaskManagerEvents> {
20
130
  /**
@@ -1 +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;IAC9D;;;OAGG;IACH,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,OAAE;CAC/E;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,aAAa,CAAC,kBAAkB,CAAC;IACtE;;;;;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;IA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C,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;CACxB"}
@@ -1 +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\t/**\n\t * Notifies when the local client has reached the front of the queue, left the queue, or a task was completed.\n\t * Does not account for known pending ops, but instead only reflects the current state.\n\t */\n\t(event: \"assigned\" | \"completed\" | \"lost\", listener: (taskId: string) => void);\n}\n\n/**\n * Task manager interface\n */\nexport interface ITaskManager extends ISharedObject<ITaskManagerEvents> {\n\t/**\n\t * Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and\n\t * `false` if the task was completed by another client. It rejects if the local client abandoned the task or\n\t * disconnected while in queue.\n\t * @param taskId - Identifier for the task\n\t */\n\tvolunteerForTask(taskId: string): Promise<boolean>;\n\n\t/**\n\t * Continuously volunteer for the task. Watch the \"assigned\" event to determine if the task is assigned.\n\t * The local client will automatically re-enter the queue if it disconnects.\n\t * @param taskId - Identifier for the task\n\t */\n\tsubscribeToTask(taskId: string): void;\n\n\t/**\n\t * Exit the queue, releasing the task if currently assigned.\n\t * @param taskId - Identifier for the task\n\t */\n\tabandon(taskId: string): void;\n\n\t/**\n\t * Check whether this client is the current assignee for the task and there is no outstanding abandon op that\n\t * would abandon the assignment.\n\t * @param taskId - Identifier for the task\n\t */\n\tassigned(taskId: string): boolean;\n\n\t/**\n\t * Check whether this client is either the current assignee, in queue, or we expect they will be in queue after\n\t * outstanding ops have been ack'd.\n\t * @param taskId - Identifier for the task\n\t */\n\tqueued(taskId: string): boolean;\n\n\t/**\n\t * Check whether this client is currently subscribed to the task.\n\t * @param taskId - Identifier for the task\n\t */\n\tsubscribed(taskId: string): boolean;\n\n\t/**\n\t * Marks a task as completed and releases all clients from its queue.\n\t * @param taskId - Identifier for the task\n\t */\n\tcomplete(taskId: string): void;\n\n\t/**\n\t * Check whether this client can currently volunteer for a task.\n\t */\n\tcanVolunteer(): boolean;\n}\n"]}
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 * Describes the event listener format for {@link ITaskManagerEvents} events.\n *\n * @param taskId - The unique identifier of the related task.\n */\nexport type TaskEventListener = (taskId: string) => void;\n\n/**\n * Events emitted by {@link TaskManager}.\n */\nexport interface ITaskManagerEvents extends ISharedObjectEvents {\n\t/**\n\t * Fires when a task has been exclusively assigned to the client.\n\t *\n\t * @remarks Does not account for known pending ops, but instead only reflects the current state.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"assigned\", listener: TaskEventListener);\n\n\t/**\n\t * Fires when a task the client is queued for is completed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"completed\", listener: TaskEventListener);\n\n\t/**\n\t * Fires when the task assignment is lost by the local client.\n\t *\n\t * @remarks This could be due to the client disconnecting or by manually calling {@link ITaskManager.abandon}.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"lost\", listener: TaskEventListener);\n}\n\n/**\n * A distributed data structure that tracks queues of clients that want to exclusively run a task.\n *\n * @example Creation\n *\n * To create a {@link TaskManager}, call the static create method:\n *\n * ```typescript\n * const taskManager = TaskManager.create(this.runtime, id);\n * ```\n *\n * @example Usage\n *\n * To volunteer for a task, use the {@link ITaskManager.volunteerForTask} method.\n * This returns a Promise that will resolve once the client has acquired exclusive rights to run the task,\n * or reject if the client is removed from the queue without acquiring the rights.\n *\n * ```typescript\n * taskManager.volunteerForTask(\"NameOfTask\")\n * .then(() => { doTheTask(); })\n * .catch((err) => { console.error(err); });\n * ```\n *\n * Alternatively, you can indefinitely volunteer for a task with the synchronous {@link ITaskManager.subscribeToTask}\n * method. This method does not return a value, therefore you need to rely on eventing to know when you have acquired\n * the rights to run the task (see below).\n *\n * ```typescript\n * taskManager.subscribeToTask(\"NameOfTask\");\n * ```\n *\n * To check if the local client is currently subscribed to a task, use the {@link ITaskManager.subscribed} method.\n *\n * ```typescript\n * if (taskManager.subscribed(\"NameOfTask\")) {\n * console.log(\"This client is currently subscribed to the task.\");\n * }\n * ```\n *\n * To release the rights to the task, use the {@link ITaskManager.abandon} method.\n * The next client in the queue will then get the rights to run the task.\n *\n * ```typescript\n * taskManager.abandon(\"NameOfTask\");\n * ```\n *\n * To inspect your state in the queue, you can use the {@link ITaskManager.queued} and {@link ITaskManager.assigned}\n * methods.\n *\n * ```typescript\n * if (taskManager.queued(\"NameOfTask\")) {\n * console.log(\"This client is somewhere in the queue, potentially even having the task assignment.\");\n * }\n *\n * if (taskManager.assigned(\"NameOfTask\")) {\n * console.log(\"This client currently has the rights to run the task\");\n * }\n * ```\n *\n * To signal to other connected clients that a task is completed, use the {@link ITaskManager.complete} method.\n * This will release all clients from the queue and emit the \"completed\" event.\n *\n * ```typescript\n * taskManager.complete(\"NameOfTask\");\n * ```\n *\n * @example Eventing\n *\n * `ITaskManager` will emit events when a task is assigned to the client, when the task assignment is lost,\n * and when a task was completed by another client.\n *\n * ```typescript\n * taskManager.on(\"assigned\", (taskId: string) => {\n * console.log(`Client was assigned task: ${taskId}`);\n * });\n *\n * taskManager.on(\"lost\", (taskId: string) => {\n * console.log(`Client released task: ${taskId}`);\n * });\n *\n * taskManager.on(\"completed\", (taskId: string) => {\n * console.log(`Another client completed task: ${taskId}`);\n * });\n * ```\n *\n * These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as\n * when using {@link ITaskManager.subscribeToTask}.\n *\n * See {@link ITaskManagerEvents} for more details.\n */\nexport interface ITaskManager extends ISharedObject<ITaskManagerEvents> {\n\t/**\n\t * Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and\n\t * `false` if the task was completed by another client. It rejects if the local client abandoned the task or\n\t * disconnected while in queue.\n\t * @param taskId - Identifier for the task\n\t */\n\tvolunteerForTask(taskId: string): Promise<boolean>;\n\n\t/**\n\t * Continuously volunteer for the task. Watch the \"assigned\" event to determine if the task is assigned.\n\t * The local client will automatically re-enter the queue if it disconnects.\n\t * @param taskId - Identifier for the task\n\t */\n\tsubscribeToTask(taskId: string): void;\n\n\t/**\n\t * Exit the queue, releasing the task if currently assigned.\n\t * @param taskId - Identifier for the task\n\t */\n\tabandon(taskId: string): void;\n\n\t/**\n\t * Check whether this client is the current assignee for the task and there is no outstanding abandon op that\n\t * would abandon the assignment.\n\t * @param taskId - Identifier for the task\n\t */\n\tassigned(taskId: string): boolean;\n\n\t/**\n\t * Check whether this client is either the current assignee, in queue, or we expect they will be in queue after\n\t * outstanding ops have been ack'd.\n\t * @param taskId - Identifier for the task\n\t */\n\tqueued(taskId: string): boolean;\n\n\t/**\n\t * Check whether this client is currently subscribed to the task.\n\t * @param taskId - Identifier for the task\n\t */\n\tsubscribed(taskId: string): boolean;\n\n\t/**\n\t * Marks a task as completed and releases all clients from its queue.\n\t * @param taskId - Identifier for the task\n\t */\n\tcomplete(taskId: string): void;\n\n\t/**\n\t * Check whether this client can currently volunteer for a task.\n\t */\n\tcanVolunteer(): boolean;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/task-manager";
8
- export declare const pkgVersion = "2.0.0-internal.4.2.0";
8
+ export declare const pkgVersion = "2.0.0-internal.4.3.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/task-manager";
11
- exports.pkgVersion = "2.0.0-internal.4.2.0";
11
+ exports.pkgVersion = "2.0.0-internal.4.3.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +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.4.2.0\";\n"]}
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.4.3.0\";\n"]}
@@ -8,92 +8,9 @@ import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
8
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
9
  import { ITaskManager, ITaskManagerEvents } from "./interfaces";
10
10
  /**
11
- * The TaskManager distributed data structure tracks queues of clients that want to exclusively run a task.
11
+ * {@inheritDoc ITaskManager}
12
12
  *
13
- * @remarks
14
- *
15
- * ### Creation
16
- *
17
- * To create a `TaskManager`, call the static create method:
18
- *
19
- * ```typescript
20
- * const taskManager = TaskManager.create(this.runtime, id);
21
- * ```
22
- *
23
- * ### Usage
24
- *
25
- * To volunteer for a task, use the `volunteerForTask()` method. This returns a Promise that will resolve once the
26
- * client has acquired exclusive rights to run the task, or reject if the client is removed from the queue without
27
- * acquiring the rights.
28
- *
29
- * ```typescript
30
- * taskManager.volunteerForTask("NameOfTask")
31
- * .then(() => { doTheTask(); })
32
- * .catch((err) => { console.error(err); });
33
- * ```
34
- *
35
- * Alternatively, you can indefinitely volunteer for a task with the synchronous `subscribeToTask()` method. This
36
- * method does not return a value, therefore you need to rely on eventing to know when you have acquired the rights
37
- * to run the task (see below).
38
- *
39
- * ```typescript
40
- * taskManager.subscribeToTask("NameOfTask");
41
- * ```
42
- *
43
- * To check if the local client is currently subscribed to a task, use the `subscribed()` method.
44
- * ```typescript
45
- * if (taskManager.subscribed("NameOfTask")) {
46
- * console.log("This client is currently subscribed to the task.");
47
- * }
48
- * ```
49
- *
50
- * To release the rights to the task, use the `abandon()` method. The next client in the queue will then get the
51
- * rights to run the task.
52
- *
53
- * ```typescript
54
- * taskManager.abandon("NameOfTask");
55
- * ```
56
- *
57
- * To inspect your state in the queue, you can use the `queued()` and `assigned()` methods.
58
- *
59
- * ```typescript
60
- * if (taskManager.queued("NameOfTask")) {
61
- * console.log("This client is somewhere in the queue, potentially even having the task assignment.");
62
- * }
63
- *
64
- * if (taskManager.assigned("NameOfTask")) {
65
- * console.log("This client currently has the rights to run the task");
66
- * }
67
- * ```
68
- *
69
- * To signal to other connected clients that a task is completed, use the `complete()` method. This will release all
70
- * clients from the queue and emit the "completed" event.
71
- *
72
- * ```typescript
73
- * taskManager.complete("NameOfTask");
74
- * ```
75
- *
76
- * ### Eventing
77
- *
78
- * `TaskManager` is an `EventEmitter`, and will emit events when a task is assigned to the client, when the task
79
- * assignment is lost, and when a task was completed by another client.
80
- *
81
- * ```typescript
82
- * taskManager.on("assigned", (taskId: string) => {
83
- * console.log(`Client was assigned task: ${taskId}`);
84
- * });
85
- *
86
- * taskManager.on("lost", (taskId: string) => {
87
- * console.log(`Client released task: ${taskId}`);
88
- * });
89
- *
90
- * taskManager.on("completed", (taskId: string) => {
91
- * console.log(`Another client completed task: ${taskId}`);
92
- * });
93
- * ```
94
- *
95
- * These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as
96
- * when using the `subscribeToTask()` method.
13
+ * @sealed
97
14
  */
98
15
  export declare class TaskManager extends SharedObject<ITaskManagerEvents> implements ITaskManager {
99
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAqChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,qBAAa,WAAY,SAAQ,YAAY,CAAC,kBAAkB,CAAE,YAAW,YAAY;IACxF;;;;;;OAM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AY,IAAI,OAAO;IAQ9B;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAuB5E;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxE;;OAEG;IACH,SAAS,CAAC,mBAAmB;IAE7B;;;OAGG;IACH,SAAS,CAAC,YAAY;IAItB;;;OAGG;IACH,SAAS,CAAC,SAAS;IAKnB;;;;OAIG;IACH,SAAS,CAAC,YAAY;IAEtB;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO;IAyBzB,OAAO,CAAC,gBAAgB;IA4BxB,OAAO,CAAC,qBAAqB;IAsB7B,OAAO,CAAC,yBAAyB;IAMjC;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAerC,OAAO,CAAC,uBAAuB;IAiBxB,cAAc;CAGrB"}
@@ -17,92 +17,9 @@ const snapshotFileName = "header";
17
17
  */
18
18
  const placeholderClientId = "placeholder";
19
19
  /**
20
- * The TaskManager distributed data structure tracks queues of clients that want to exclusively run a task.
20
+ * {@inheritDoc ITaskManager}
21
21
  *
22
- * @remarks
23
- *
24
- * ### Creation
25
- *
26
- * To create a `TaskManager`, call the static create method:
27
- *
28
- * ```typescript
29
- * const taskManager = TaskManager.create(this.runtime, id);
30
- * ```
31
- *
32
- * ### Usage
33
- *
34
- * To volunteer for a task, use the `volunteerForTask()` method. This returns a Promise that will resolve once the
35
- * client has acquired exclusive rights to run the task, or reject if the client is removed from the queue without
36
- * acquiring the rights.
37
- *
38
- * ```typescript
39
- * taskManager.volunteerForTask("NameOfTask")
40
- * .then(() => { doTheTask(); })
41
- * .catch((err) => { console.error(err); });
42
- * ```
43
- *
44
- * Alternatively, you can indefinitely volunteer for a task with the synchronous `subscribeToTask()` method. This
45
- * method does not return a value, therefore you need to rely on eventing to know when you have acquired the rights
46
- * to run the task (see below).
47
- *
48
- * ```typescript
49
- * taskManager.subscribeToTask("NameOfTask");
50
- * ```
51
- *
52
- * To check if the local client is currently subscribed to a task, use the `subscribed()` method.
53
- * ```typescript
54
- * if (taskManager.subscribed("NameOfTask")) {
55
- * console.log("This client is currently subscribed to the task.");
56
- * }
57
- * ```
58
- *
59
- * To release the rights to the task, use the `abandon()` method. The next client in the queue will then get the
60
- * rights to run the task.
61
- *
62
- * ```typescript
63
- * taskManager.abandon("NameOfTask");
64
- * ```
65
- *
66
- * To inspect your state in the queue, you can use the `queued()` and `assigned()` 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 `complete()` method. This will release all
79
- * clients from the queue and emit the "completed" event.
80
- *
81
- * ```typescript
82
- * taskManager.complete("NameOfTask");
83
- * ```
84
- *
85
- * ### Eventing
86
- *
87
- * `TaskManager` is an `EventEmitter`, and will emit events when a task is assigned to the client, when the task
88
- * assignment is lost, 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 the `subscribeToTask()` method.
22
+ * @sealed
106
23
  */
107
24
  class TaskManager extends shared_object_base_1.SharedObject {
108
25
  /**
@@ -707,7 +624,7 @@ class TaskManager extends shared_object_base_1.SharedObject {
707
624
  }
708
625
  }
709
626
  applyStashedOp() {
710
- throw new Error("not implemented");
627
+ // do nothing...
711
628
  }
712
629
  }
713
630
  exports.TaskManager = TaskManager;