@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
package/src/agent.ts CHANGED
@@ -3,64 +3,82 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
6
+ import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
7
7
 
8
+ /**
9
+ * @alpha
10
+ */
8
11
  export const IAgentScheduler: keyof IProvideAgentScheduler = "IAgentScheduler";
9
12
 
13
+ /**
14
+ * @alpha
15
+ */
10
16
  export interface IProvideAgentScheduler {
11
- readonly IAgentScheduler: IAgentScheduler;
17
+ readonly IAgentScheduler: IAgentScheduler;
12
18
  }
13
19
 
20
+ /**
21
+ * Events emitted by {@link (IAgentScheduler:interface)}.
22
+ * @alpha
23
+ */
14
24
  export interface IAgentSchedulerEvents extends IEvent {
15
- /**
16
- * Event when ownership of task changes
17
- * @param event - name of the event:
18
- * "picked" - the task has been assigned to this client, in response to pick() being called
19
- * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
20
- * automatically, unless release() is called
21
- * "released" - the task was successfully released back to the pool. Client will not attempt to
22
- * re-acquire the task, unless pick() is called.
23
- * "lost" - task is lost due to disconnect or data store / container being attached.
24
- * Task will be picked up again by some connected client (this client will try as well,
25
- * unless release() is called)
26
- * @param listener - callback notified when change happened for particular key
27
- */
28
- (event: "picked" | "released" | "lost", listener: (taskId: string) => void);
25
+ /**
26
+ * Event when ownership of task changes
27
+ * @param event - name of the event:
28
+ *
29
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
30
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
31
+ * automatically, unless release() is called
32
+ *
33
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
34
+ * re-acquire the task, unless pick() is called.
35
+ *
36
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
37
+ * Task will be picked up again by some connected client (this client will try as well,
38
+ * unless release() is called)
39
+ *
40
+ * @param listener - callback notified when change happened for particular key
41
+ */
42
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void);
29
43
  }
30
44
 
31
45
  /**
32
46
  * Agent scheduler distributes a set of tasks/variables across connected clients.
47
+ * @alpha
33
48
  */
34
- export interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents> {
35
- /**
36
- * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
37
- * a new agent to run but does not have the capability to run the agent inside the host.
38
- * Client can call pick() later if the capability changes.
39
- *
40
- * This method should only be called once per task. Duplicate calls will be rejected.
41
- */
42
- register(...taskUrls: string[]): Promise<void>;
49
+ export interface IAgentScheduler
50
+ extends IProvideAgentScheduler,
51
+ IEventProvider<IAgentSchedulerEvents>,
52
+ IFluidLoadable {
53
+ /**
54
+ * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
55
+ * a new agent to run but does not have the capability to run the agent inside the host.
56
+ * Client can call pick() later if the capability changes.
57
+ *
58
+ * This method should only be called once per task. Duplicate calls will be rejected.
59
+ */
60
+ register(...taskUrls: string[]): Promise<void>;
43
61
 
44
- /**
45
- * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
46
- * Resolves when the tasks are assigned to one of the connected clients.
47
- *
48
- * This method should only be called once per task. Duplicate calls will be rejected.
49
- *
50
- * @param worker - callback to run when task is picked up.
51
- */
52
- pick(taskId: string, worker: () => Promise<void>): Promise<void>;
62
+ /**
63
+ * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
64
+ * Resolves when the tasks are assigned to one of the connected clients.
65
+ *
66
+ * This method should only be called once per task. Duplicate calls will be rejected.
67
+ *
68
+ * @param worker - callback to run when task is picked up.
69
+ */
70
+ pick(taskId: string, worker: () => Promise<void>): Promise<void>;
53
71
 
54
- /**
55
- * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
56
- *
57
- * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
58
- * App can call pickedTasks() to get the picked list first.
59
- */
60
- release(...taskUrls: string[]): Promise<void>;
72
+ /**
73
+ * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
74
+ *
75
+ * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
76
+ * App can call pickedTasks() to get the picked list first.
77
+ */
78
+ release(...taskUrls: string[]): Promise<void>;
61
79
 
62
- /**
63
- * Returns a list of all tasks running on this client
64
- */
65
- pickedTasks(): string[];
80
+ /**
81
+ * Returns a list of all tasks running on this client
82
+ */
83
+ pickedTasks(): string[];
66
84
  }
package/src/index.ts CHANGED
@@ -3,6 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export * from "./agent";
6
+ export { IAgentScheduler, IAgentSchedulerEvents, IProvideAgentScheduler } from "./agent";
7
7
  export { AgentSchedulerFactory } from "./scheduler";
8
- export * from "./taskSubscription";
8
+ export { ITaskSubscriptionEvents, TaskSubscription } from "./taskSubscription";