@fluidframework/agent-scheduler 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

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 (71) hide show
  1. package/.eslintrc.js +8 -10
  2. package/CHANGELOG.md +124 -0
  3. package/README.md +39 -3
  4. package/api-extractor-lint.json +4 -0
  5. package/api-extractor.json +4 -0
  6. package/api-report/agent-scheduler.api.md +71 -0
  7. package/dist/agent-scheduler-alpha.d.ts +127 -0
  8. package/dist/agent-scheduler-beta.d.ts +30 -0
  9. package/dist/agent-scheduler-public.d.ts +30 -0
  10. package/dist/agent-scheduler-untrimmed.d.ts +127 -0
  11. package/dist/{agent.js → agent.cjs} +4 -1
  12. package/dist/agent.cjs.map +1 -0
  13. package/dist/agent.d.ts +25 -10
  14. package/dist/agent.d.ts.map +1 -1
  15. package/dist/index.cjs +14 -0
  16. package/dist/index.cjs.map +1 -0
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/{scheduler.js → scheduler.cjs} +93 -57
  20. package/dist/scheduler.cjs.map +1 -0
  21. package/dist/scheduler.d.ts +10 -12
  22. package/dist/scheduler.d.ts.map +1 -1
  23. package/dist/{taskSubscription.js → taskSubscription.cjs} +4 -3
  24. package/dist/taskSubscription.cjs.map +1 -0
  25. package/dist/taskSubscription.d.ts +7 -2
  26. package/dist/taskSubscription.d.ts.map +1 -1
  27. package/dist/tsdoc-metadata.json +11 -0
  28. package/lib/agent-scheduler-alpha.d.mts +127 -0
  29. package/lib/agent-scheduler-beta.d.mts +30 -0
  30. package/lib/agent-scheduler-public.d.mts +30 -0
  31. package/lib/agent-scheduler-untrimmed.d.mts +127 -0
  32. package/lib/{agent.d.ts → agent.d.mts} +25 -10
  33. package/lib/agent.d.mts.map +1 -0
  34. package/lib/{agent.js → agent.mjs} +4 -1
  35. package/lib/agent.mjs.map +1 -0
  36. package/lib/index.d.mts +8 -0
  37. package/lib/index.d.mts.map +1 -0
  38. package/lib/index.mjs +8 -0
  39. package/lib/index.mjs.map +1 -0
  40. package/lib/{scheduler.d.ts → scheduler.d.mts} +11 -13
  41. package/lib/scheduler.d.mts.map +1 -0
  42. package/lib/{scheduler.js → scheduler.mjs} +83 -47
  43. package/lib/scheduler.mjs.map +1 -0
  44. package/lib/{taskSubscription.d.ts → taskSubscription.d.mts} +8 -3
  45. package/lib/taskSubscription.d.mts.map +1 -0
  46. package/lib/{taskSubscription.js → taskSubscription.mjs} +3 -2
  47. package/lib/taskSubscription.mjs.map +1 -0
  48. package/package.json +77 -73
  49. package/prettier.config.cjs +8 -0
  50. package/src/agent.ts +63 -45
  51. package/src/index.ts +2 -2
  52. package/src/scheduler.ts +469 -405
  53. package/src/taskSubscription.ts +55 -47
  54. package/tsc-multi.test.json +4 -0
  55. package/tsconfig.json +11 -13
  56. package/dist/agent.js.map +0 -1
  57. package/dist/index.js +0 -22
  58. package/dist/index.js.map +0 -1
  59. package/dist/scheduler.js.map +0 -1
  60. package/dist/taskSubscription.js.map +0 -1
  61. package/lib/agent.d.ts.map +0 -1
  62. package/lib/agent.js.map +0 -1
  63. package/lib/index.d.ts +0 -8
  64. package/lib/index.d.ts.map +0 -1
  65. package/lib/index.js +0 -8
  66. package/lib/index.js.map +0 -1
  67. package/lib/scheduler.d.ts.map +0 -1
  68. package/lib/scheduler.js.map +0 -1
  69. package/lib/taskSubscription.d.ts.map +0 -1
  70. package/lib/taskSubscription.js.map +0 -1
  71. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.38.3"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,127 @@
1
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
2
+ import { IEvent } from '@fluidframework/core-interfaces';
3
+ import { IEventProvider } from '@fluidframework/core-interfaces';
4
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
5
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
6
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
7
+ import { NamedFluidDataStoreRegistryEntry } from '@fluidframework/runtime-definitions';
8
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
9
+
10
+ /**
11
+ * @alpha
12
+ */
13
+ export declare class AgentSchedulerFactory implements IFluidDataStoreFactory {
14
+ static readonly type = "_scheduler";
15
+ readonly type = "_scheduler";
16
+ get IFluidDataStoreFactory(): this;
17
+ static get registryEntry(): NamedFluidDataStoreRegistryEntry;
18
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
19
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
20
+ }
21
+
22
+ /**
23
+ * @alpha
24
+ */
25
+ export declare const IAgentScheduler: keyof IProvideAgentScheduler;
26
+
27
+ /**
28
+ * Agent scheduler distributes a set of tasks/variables across connected clients.
29
+ * @alpha
30
+ */
31
+ export declare interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
32
+ /**
33
+ * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
34
+ * a new agent to run but does not have the capability to run the agent inside the host.
35
+ * Client can call pick() later if the capability changes.
36
+ *
37
+ * This method should only be called once per task. Duplicate calls will be rejected.
38
+ */
39
+ register(...taskUrls: string[]): Promise<void>;
40
+ /**
41
+ * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
42
+ * Resolves when the tasks are assigned to one of the connected clients.
43
+ *
44
+ * This method should only be called once per task. Duplicate calls will be rejected.
45
+ *
46
+ * @param worker - callback to run when task is picked up.
47
+ */
48
+ pick(taskId: string, worker: () => Promise<void>): Promise<void>;
49
+ /**
50
+ * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
51
+ *
52
+ * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
53
+ * App can call pickedTasks() to get the picked list first.
54
+ */
55
+ release(...taskUrls: string[]): Promise<void>;
56
+ /**
57
+ * Returns a list of all tasks running on this client
58
+ */
59
+ pickedTasks(): string[];
60
+ }
61
+
62
+ /**
63
+ * Events emitted by {@link (IAgentScheduler:interface)}.
64
+ * @alpha
65
+ */
66
+ export declare interface IAgentSchedulerEvents extends IEvent {
67
+ /**
68
+ * Event when ownership of task changes
69
+ * @param event - name of the event:
70
+ *
71
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
72
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
73
+ * automatically, unless release() is called
74
+ *
75
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
76
+ * re-acquire the task, unless pick() is called.
77
+ *
78
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
79
+ * Task will be picked up again by some connected client (this client will try as well,
80
+ * unless release() is called)
81
+ *
82
+ * @param listener - callback notified when change happened for particular key
83
+ */
84
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
85
+ }
86
+
87
+ /**
88
+ * @alpha
89
+ */
90
+ export declare interface IProvideAgentScheduler {
91
+ readonly IAgentScheduler: IAgentScheduler;
92
+ }
93
+
94
+ /**
95
+ * Events emitted by {@link TaskSubscription}.
96
+ * @alpha
97
+ */
98
+ export declare interface ITaskSubscriptionEvents extends IEvent {
99
+ (event: "gotTask" | "lostTask", listener: () => void): any;
100
+ }
101
+
102
+ /**
103
+ * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.
104
+ * @alpha
105
+ */
106
+ export declare class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
107
+ private readonly agentScheduler;
108
+ readonly taskId: string;
109
+ private subscribed;
110
+ /**
111
+ * @param agentScheduler - The AgentScheduler that will be subscribed against
112
+ * @param taskId - The string ID of the task to subscribe against
113
+ */
114
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
115
+ /**
116
+ * Check if currently holding ownership of the task.
117
+ * @returns true if currently the task owner, false otherwise.
118
+ */
119
+ haveTask(): boolean;
120
+ /**
121
+ * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.
122
+ * This is safe to call multiple times across multiple TaskSubscriptions.
123
+ */
124
+ volunteer(): void;
125
+ }
126
+
127
+ export { }
@@ -0,0 +1,30 @@
1
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
2
+ import { IEvent } from '@fluidframework/core-interfaces';
3
+ import { IEventProvider } from '@fluidframework/core-interfaces';
4
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
5
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
6
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
7
+ import { NamedFluidDataStoreRegistryEntry } from '@fluidframework/runtime-definitions';
8
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
9
+
10
+ /* Excluded from this release type: AgentSchedulerFactory */
11
+
12
+ /* Excluded from this release type: FluidDataStoreRuntime */
13
+
14
+ /* Excluded from this release type: IAgentScheduler */
15
+
16
+ /* Excluded from this release type: IAgentSchedulerEvents */
17
+
18
+ /* Excluded from this release type: IFluidDataStoreContext */
19
+
20
+ /* Excluded from this release type: IFluidDataStoreFactory */
21
+
22
+ /* Excluded from this release type: IProvideAgentScheduler */
23
+
24
+ /* Excluded from this release type: ITaskSubscriptionEvents */
25
+
26
+ /* Excluded from this release type: NamedFluidDataStoreRegistryEntry */
27
+
28
+ /* Excluded from this release type: TaskSubscription */
29
+
30
+ export { }
@@ -0,0 +1,30 @@
1
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
2
+ import { IEvent } from '@fluidframework/core-interfaces';
3
+ import { IEventProvider } from '@fluidframework/core-interfaces';
4
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
5
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
6
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
7
+ import { NamedFluidDataStoreRegistryEntry } from '@fluidframework/runtime-definitions';
8
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
9
+
10
+ /* Excluded from this release type: AgentSchedulerFactory */
11
+
12
+ /* Excluded from this release type: FluidDataStoreRuntime */
13
+
14
+ /* Excluded from this release type: IAgentScheduler */
15
+
16
+ /* Excluded from this release type: IAgentSchedulerEvents */
17
+
18
+ /* Excluded from this release type: IFluidDataStoreContext */
19
+
20
+ /* Excluded from this release type: IFluidDataStoreFactory */
21
+
22
+ /* Excluded from this release type: IProvideAgentScheduler */
23
+
24
+ /* Excluded from this release type: ITaskSubscriptionEvents */
25
+
26
+ /* Excluded from this release type: NamedFluidDataStoreRegistryEntry */
27
+
28
+ /* Excluded from this release type: TaskSubscription */
29
+
30
+ export { }
@@ -0,0 +1,127 @@
1
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
2
+ import { IEvent } from '@fluidframework/core-interfaces';
3
+ import { IEventProvider } from '@fluidframework/core-interfaces';
4
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
5
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
6
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
7
+ import { NamedFluidDataStoreRegistryEntry } from '@fluidframework/runtime-definitions';
8
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
9
+
10
+ /**
11
+ * @alpha
12
+ */
13
+ export declare class AgentSchedulerFactory implements IFluidDataStoreFactory {
14
+ static readonly type = "_scheduler";
15
+ readonly type = "_scheduler";
16
+ get IFluidDataStoreFactory(): this;
17
+ static get registryEntry(): NamedFluidDataStoreRegistryEntry;
18
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
19
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
20
+ }
21
+
22
+ /**
23
+ * @alpha
24
+ */
25
+ export declare const IAgentScheduler: keyof IProvideAgentScheduler;
26
+
27
+ /**
28
+ * Agent scheduler distributes a set of tasks/variables across connected clients.
29
+ * @alpha
30
+ */
31
+ export declare interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
32
+ /**
33
+ * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
34
+ * a new agent to run but does not have the capability to run the agent inside the host.
35
+ * Client can call pick() later if the capability changes.
36
+ *
37
+ * This method should only be called once per task. Duplicate calls will be rejected.
38
+ */
39
+ register(...taskUrls: string[]): Promise<void>;
40
+ /**
41
+ * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
42
+ * Resolves when the tasks are assigned to one of the connected clients.
43
+ *
44
+ * This method should only be called once per task. Duplicate calls will be rejected.
45
+ *
46
+ * @param worker - callback to run when task is picked up.
47
+ */
48
+ pick(taskId: string, worker: () => Promise<void>): Promise<void>;
49
+ /**
50
+ * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
51
+ *
52
+ * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
53
+ * App can call pickedTasks() to get the picked list first.
54
+ */
55
+ release(...taskUrls: string[]): Promise<void>;
56
+ /**
57
+ * Returns a list of all tasks running on this client
58
+ */
59
+ pickedTasks(): string[];
60
+ }
61
+
62
+ /**
63
+ * Events emitted by {@link (IAgentScheduler:interface)}.
64
+ * @alpha
65
+ */
66
+ export declare interface IAgentSchedulerEvents extends IEvent {
67
+ /**
68
+ * Event when ownership of task changes
69
+ * @param event - name of the event:
70
+ *
71
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
72
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
73
+ * automatically, unless release() is called
74
+ *
75
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
76
+ * re-acquire the task, unless pick() is called.
77
+ *
78
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
79
+ * Task will be picked up again by some connected client (this client will try as well,
80
+ * unless release() is called)
81
+ *
82
+ * @param listener - callback notified when change happened for particular key
83
+ */
84
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
85
+ }
86
+
87
+ /**
88
+ * @alpha
89
+ */
90
+ export declare interface IProvideAgentScheduler {
91
+ readonly IAgentScheduler: IAgentScheduler;
92
+ }
93
+
94
+ /**
95
+ * Events emitted by {@link TaskSubscription}.
96
+ * @alpha
97
+ */
98
+ export declare interface ITaskSubscriptionEvents extends IEvent {
99
+ (event: "gotTask" | "lostTask", listener: () => void): any;
100
+ }
101
+
102
+ /**
103
+ * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.
104
+ * @alpha
105
+ */
106
+ export declare class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
107
+ private readonly agentScheduler;
108
+ readonly taskId: string;
109
+ private subscribed;
110
+ /**
111
+ * @param agentScheduler - The AgentScheduler that will be subscribed against
112
+ * @param taskId - The string ID of the task to subscribe against
113
+ */
114
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
115
+ /**
116
+ * Check if currently holding ownership of the task.
117
+ * @returns true if currently the task owner, false otherwise.
118
+ */
119
+ haveTask(): boolean;
120
+ /**
121
+ * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.
122
+ * This is safe to call multiple times across multiple TaskSubscriptions.
123
+ */
124
+ volunteer(): void;
125
+ }
126
+
127
+ export { }
@@ -2,31 +2,46 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
5
+ import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
6
+ /**
7
+ * @alpha
8
+ */
6
9
  export declare const IAgentScheduler: keyof IProvideAgentScheduler;
10
+ /**
11
+ * @alpha
12
+ */
7
13
  export interface IProvideAgentScheduler {
8
14
  readonly IAgentScheduler: IAgentScheduler;
9
15
  }
16
+ /**
17
+ * Events emitted by {@link (IAgentScheduler:interface)}.
18
+ * @alpha
19
+ */
10
20
  export interface IAgentSchedulerEvents extends IEvent {
11
21
  /**
12
22
  * Event when ownership of task changes
13
23
  * @param event - name of the event:
14
- * "picked" - the task has been assigned to this client, in response to pick() being called
15
- * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
16
- * automatically, unless release() is called
17
- * "released" - the task was successfully released back to the pool. Client will not attempt to
18
- * re-acquire the task, unless pick() is called.
19
- * "lost" - task is lost due to disconnect or data store / container being attached.
20
- * Task will be picked up again by some connected client (this client will try as well,
21
- * unless release() is called)
24
+ *
25
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
26
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
27
+ * automatically, unless release() is called
28
+ *
29
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
30
+ * re-acquire the task, unless pick() is called.
31
+ *
32
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
33
+ * Task will be picked up again by some connected client (this client will try as well,
34
+ * unless release() is called)
35
+ *
22
36
  * @param listener - callback notified when change happened for particular key
23
37
  */
24
38
  (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
25
39
  }
26
40
  /**
27
41
  * Agent scheduler distributes a set of tasks/variables across connected clients.
42
+ * @alpha
28
43
  */
29
- export interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents> {
44
+ export interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
30
45
  /**
31
46
  * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
32
47
  * a new agent to run but does not have the capability to run the agent inside the host.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC;AAExF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,sBAA0C,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,MAAM;IACpD;;;;;;;;;;;;;;;;OAgBG;IACH,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,OAAE;CAC5E;AAED;;;GAGG;AACH,MAAM,WAAW,eAChB,SAAQ,sBAAsB,EAC7B,cAAc,CAAC,qBAAqB,CAAC,EACrC,cAAc;IACf;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,OAAO,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;OAEG;IACH,WAAW,IAAI,MAAM,EAAE,CAAC;CACxB"}
@@ -2,5 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * @alpha
7
+ */
5
8
  export const IAgentScheduler = "IAgentScheduler";
6
- //# sourceMappingURL=agent.js.map
9
+ //# sourceMappingURL=agent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.mjs","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiC,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\n\n/**\n * @alpha\n */\nexport const IAgentScheduler: keyof IProvideAgentScheduler = \"IAgentScheduler\";\n\n/**\n * @alpha\n */\nexport interface IProvideAgentScheduler {\n\treadonly IAgentScheduler: IAgentScheduler;\n}\n\n/**\n * Events emitted by {@link (IAgentScheduler:interface)}.\n * @alpha\n */\nexport interface IAgentSchedulerEvents extends IEvent {\n\t/**\n\t * Event when ownership of task changes\n\t * @param event - name of the event:\n\t *\n\t * - \"picked\" - the task has been assigned to this client, in response to pick() being called\n\t * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)\n\t * automatically, unless release() is called\n\t *\n\t * - \"released\" - the task was successfully released back to the pool. Client will not attempt to\n\t * re-acquire the task, unless pick() is called.\n\t *\n\t * - \"lost\" - task is lost due to disconnect or data store / container being attached.\n\t * Task will be picked up again by some connected client (this client will try as well,\n\t * unless release() is called)\n\t *\n\t * @param listener - callback notified when change happened for particular key\n\t */\n\t(event: \"picked\" | \"released\" | \"lost\", listener: (taskId: string) => void);\n}\n\n/**\n * Agent scheduler distributes a set of tasks/variables across connected clients.\n * @alpha\n */\nexport interface IAgentScheduler\n\textends IProvideAgentScheduler,\n\t\tIEventProvider<IAgentSchedulerEvents>,\n\t\tIFluidLoadable {\n\t/**\n\t * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants\n\t * a new agent to run but does not have the capability to run the agent inside the host.\n\t * Client can call pick() later if the capability changes.\n\t *\n\t * This method should only be called once per task. Duplicate calls will be rejected.\n\t */\n\tregister(...taskUrls: string[]): Promise<void>;\n\n\t/**\n\t * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.\n\t * Resolves when the tasks are assigned to one of the connected clients.\n\t *\n\t * This method should only be called once per task. Duplicate calls will be rejected.\n\t *\n\t * @param worker - callback to run when task is picked up.\n\t */\n\tpick(taskId: string, worker: () => Promise<void>): Promise<void>;\n\n\t/**\n\t * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.\n\t *\n\t * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.\n\t * App can call pickedTasks() to get the picked list first.\n\t */\n\trelease(...taskUrls: string[]): Promise<void>;\n\n\t/**\n\t * Returns a list of all tasks running on this client\n\t */\n\tpickedTasks(): string[];\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { IAgentScheduler, IAgentSchedulerEvents, IProvideAgentScheduler } from "./agent.mjs";
6
+ export { AgentSchedulerFactory } from "./scheduler.mjs";
7
+ export { ITaskSubscriptionEvents, TaskSubscription } from "./taskSubscription.mjs";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE;OAClE,EAAE,qBAAqB,EAAE;OACzB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE"}
package/lib/index.mjs ADDED
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { IAgentScheduler } from "./agent.mjs";
6
+ export { AgentSchedulerFactory } from "./scheduler.mjs";
7
+ export { TaskSubscription } from "./taskSubscription.mjs";
8
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,eAAe,EAAiD;OAClE,EAAE,qBAAqB,EAAE;OACzB,EAA2B,gBAAgB,EAAE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { IAgentScheduler, IAgentSchedulerEvents, IProvideAgentScheduler } from \"./agent\";\nexport { AgentSchedulerFactory } from \"./scheduler\";\nexport { ITaskSubscriptionEvents, TaskSubscription } from \"./taskSubscription\";\n"]}
@@ -2,19 +2,20 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { TypedEventEmitter } from "@fluidframework/common-utils";
6
- import { IFluidHandle, IRequest } from "@fluidframework/core-interfaces";
7
- import { FluidDataStoreRuntime, ISharedObjectRegistry } from "@fluidframework/datastore";
5
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
+ import { IFluidHandle } from "@fluidframework/core-interfaces";
7
+ import { FluidDataStoreRuntime } from "@fluidframework/datastore";
8
8
  import { ConsensusRegisterCollection } from "@fluidframework/register-collection";
9
9
  import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
10
10
  import { IFluidDataStoreContext, IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
11
- import { IAgentScheduler, IAgentSchedulerEvents } from "./agent";
11
+ import { IAgentScheduler, IAgentSchedulerEvents } from "./agent.mjs";
12
12
  export declare class AgentScheduler extends TypedEventEmitter<IAgentSchedulerEvents> implements IAgentScheduler {
13
13
  private readonly runtime;
14
14
  private readonly context;
15
15
  private readonly consensusRegisterCollection;
16
16
  static load(runtime: IFluidDataStoreRuntime, context: IFluidDataStoreContext, existing: boolean): Promise<AgentScheduler>;
17
17
  get IAgentScheduler(): this;
18
+ get IFluidLoadable(): this;
18
19
  private get clientId();
19
20
  private readonly registeredTasks;
20
21
  private readonly locallyRunnableTasks;
@@ -23,7 +24,7 @@ export declare class AgentScheduler extends TypedEventEmitter<IAgentSchedulerEve
23
24
  constructor(runtime: IFluidDataStoreRuntime, context: IFluidDataStoreContext, consensusRegisterCollection: ConsensusRegisterCollection<string | null>);
24
25
  get handle(): IFluidHandle<this>;
25
26
  register(...taskUrls: string[]): Promise<void>;
26
- pick(taskId: string, worker: () => Promise<void>): Promise<void>;
27
+ pick(taskUrl: string, worker: () => Promise<void>): Promise<void>;
27
28
  release(...taskUrls: string[]): Promise<void>;
28
29
  pickedTasks(): string[];
29
30
  private registerCore;
@@ -39,18 +40,15 @@ export declare class AgentScheduler extends TypedEventEmitter<IAgentSchedulerEve
39
40
  private clearRunningTasks;
40
41
  private sendErrorEvent;
41
42
  }
42
- declare class AgentSchedulerRuntime extends FluidDataStoreRuntime {
43
- private readonly agentSchedulerP;
44
- constructor(dataStoreContext: IFluidDataStoreContext, sharedObjectRegistry: ISharedObjectRegistry, existing: boolean);
45
- request(request: IRequest): Promise<import("@fluidframework/core-interfaces").IResponse>;
46
- }
43
+ /**
44
+ * @alpha
45
+ */
47
46
  export declare class AgentSchedulerFactory implements IFluidDataStoreFactory {
48
47
  static readonly type = "_scheduler";
49
48
  readonly type = "_scheduler";
50
49
  get IFluidDataStoreFactory(): this;
51
50
  static get registryEntry(): NamedFluidDataStoreRegistryEntry;
52
- static createChildInstance(parentContext: IFluidDataStoreContext): Promise<AgentScheduler>;
53
- instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<AgentSchedulerRuntime>;
51
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
52
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
54
53
  }
55
- export {};
56
54
  //# sourceMappingURL=scheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B;OAEzD,EAAe,YAAY,EAAY,MAAM,iCAAiC;OAC9E,EACN,qBAAqB,EAGrB,MAAM,2BAA2B;OAG3B,EAAE,2BAA2B,EAAE,MAAM,qCAAqC;OAC1E,EAAE,sBAAsB,EAAmB,MAAM,uCAAuC;OACxF,EACN,sBAAsB,EACtB,sBAAsB,EACtB,gCAAgC,EAChC,MAAM,qCAAqC;OAGrC,EAAE,eAAe,EAAE,qBAAqB,EAAE;AA4BjD,qBAAa,cACZ,SAAQ,iBAAiB,CAAC,qBAAqB,CAC/C,YAAW,eAAe;IAgEzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,2BAA2B;WAhEzB,IAAI,CACvB,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,OAAO;IAyBlB,IAAW,eAAe,SAEzB;IACD,IAAW,cAAc,SAExB;IAED,OAAO,KAAK,QAAQ,GAOnB;IAMD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAKrD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA0C;IAI/E,OAAO,CAAC,YAAY,CAAqB;IAEzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAG3B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,2BAA2B,EAAE,2BAA2B,CAAC,MAAM,GAAG,IAAI,CAAC;IAQzF,IAAW,MAAM,uBAEhB;IAEY,QAAQ,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBjE,OAAO,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnD,WAAW,IAAI,MAAM,EAAE;YAIhB,YAAY;YAkBZ,WAAW;YAYX,UAAU;IASxB,OAAO,CAAC,eAAe;YAIT,SAAS;IAIvB,OAAO,CAAC,UAAU;IAiFlB,OAAO,CAAC,iBAAiB;YAcX,gBAAgB;IAuB9B,OAAO,CAAC,QAAQ;IAehB,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,cAAc;CAGtB;AA6BD;;GAEG;AACH,qBAAa,qBAAsB,YAAW,sBAAsB;IACnE,gBAAuB,IAAI,gBAAgB;IAC3C,SAAgB,IAAI,gBAA8B;IAElD,IAAW,sBAAsB,SAEhC;IAED,WAAkB,aAAa,IAAI,gCAAgC,CAElE;WAEmB,mBAAmB,CACtC,aAAa,EAAE,sBAAsB,GACnC,OAAO,CAAC,eAAe,CAAC;IAcd,oBAAoB,CAChC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,CAAC;CASjC"}