@fluidframework/agent-scheduler 2.0.0-internal.6.4.0 → 2.0.0-internal.7.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @fluidframework/agent-scheduler
2
2
 
3
+ ## 2.0.0-internal.7.1.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.7.0.0
8
+
9
+ ### Major Changes
10
+
11
+ - test-utils: provideEntryPoint is required [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
12
+
13
+ The optional `provideEntryPoint` method has become required on a number of constructors. A value will need to be provided to the following classes:
14
+
15
+ - `BaseContainerRuntimeFactory`
16
+ - `RuntimeFactory`
17
+ - `ContainerRuntime` (constructor and `loadRuntime`)
18
+ - `FluidDataStoreRuntime`
19
+
20
+ See [testContainerRuntimeFactoryWithDefaultDataStore.ts](https://github.com/microsoft/FluidFramework/tree/main/packages/test/test-utils/src/testContainerRuntimeFactoryWithDefaultDataStore.ts) for an example implemtation of `provideEntryPoint` for ContainerRuntime.
21
+ See [pureDataObjectFactory.ts](https://github.com/microsoft/FluidFramework/tree/main/packages/framework/aqueduct/src/data-object-factories/pureDataObjectFactory.ts#L83) for an example implementation of `provideEntryPoint` for DataStoreRuntime.
22
+
23
+ Subsequently, various `entryPoint` and `getEntryPoint()` endpoints have become required. Please see [containerRuntime.ts](https://github.com/microsoft/FluidFramework/tree/main/packages/runtime/container-runtime/src/containerRuntime.ts) for example implementations of these APIs.
24
+
25
+ For more details, see [Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
26
+
27
+ - Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
28
+
29
+ The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
30
+
3
31
  ## 2.0.0-internal.6.4.0
4
32
 
5
33
  Dependency updates only.
@@ -1,4 +1,4 @@
1
1
  {
2
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"
3
+ "extends": "@fluidframework/build-common/api-extractor-base.json"
4
4
  }
@@ -0,0 +1,71 @@
1
+ ## API Report File for "@fluidframework/agent-scheduler"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { FluidDataStoreRuntime } from '@fluidframework/datastore';
8
+ import { IEvent } from '@fluidframework/core-interfaces';
9
+ import { IEventProvider } from '@fluidframework/core-interfaces';
10
+ import { IFluidDataStoreContext } from '@fluidframework/runtime-definitions';
11
+ import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
12
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
13
+ import { NamedFluidDataStoreRegistryEntry } from '@fluidframework/runtime-definitions';
14
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
15
+
16
+ // @public (undocumented)
17
+ export class AgentSchedulerFactory implements IFluidDataStoreFactory {
18
+ // (undocumented)
19
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
20
+ // (undocumented)
21
+ get IFluidDataStoreFactory(): this;
22
+ // (undocumented)
23
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
24
+ // (undocumented)
25
+ static get registryEntry(): NamedFluidDataStoreRegistryEntry;
26
+ // (undocumented)
27
+ static readonly type = "_scheduler";
28
+ // (undocumented)
29
+ readonly type = "_scheduler";
30
+ }
31
+
32
+ // @public (undocumented)
33
+ export const IAgentScheduler: keyof IProvideAgentScheduler;
34
+
35
+ // @public
36
+ export interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
37
+ pick(taskId: string, worker: () => Promise<void>): Promise<void>;
38
+ pickedTasks(): string[];
39
+ register(...taskUrls: string[]): Promise<void>;
40
+ release(...taskUrls: string[]): Promise<void>;
41
+ }
42
+
43
+ // @public
44
+ export interface IAgentSchedulerEvents extends IEvent {
45
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
46
+ }
47
+
48
+ // @public (undocumented)
49
+ export interface IProvideAgentScheduler {
50
+ // (undocumented)
51
+ readonly IAgentScheduler: IAgentScheduler;
52
+ }
53
+
54
+ // @public
55
+ export interface ITaskSubscriptionEvents extends IEvent {
56
+ // (undocumented)
57
+ (event: "gotTask" | "lostTask", listener: () => void): any;
58
+ }
59
+
60
+ // @public
61
+ export class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
62
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
63
+ haveTask(): boolean;
64
+ // (undocumented)
65
+ readonly taskId: string;
66
+ volunteer(): void;
67
+ }
68
+
69
+ // (No @packageDocumentation comment for this package)
70
+
71
+ ```
@@ -0,0 +1,132 @@
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
+
9
+ /**
10
+ * @public
11
+ */
12
+ export declare class AgentSchedulerFactory implements IFluidDataStoreFactory {
13
+ static readonly type = "_scheduler";
14
+ readonly type = "_scheduler";
15
+ get IFluidDataStoreFactory(): this;
16
+ static get registryEntry(): NamedFluidDataStoreRegistryEntry;
17
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
18
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
19
+ }
20
+
21
+ /**
22
+ * @public
23
+ */
24
+ export declare const IAgentScheduler: keyof IProvideAgentScheduler;
25
+
26
+ /**
27
+ * Agent scheduler distributes a set of tasks/variables across connected clients.
28
+ *
29
+ * @public
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
+ *
65
+ * @public
66
+ */
67
+ export declare interface IAgentSchedulerEvents extends IEvent {
68
+ /**
69
+ * Event when ownership of task changes
70
+ * @param event - name of the event:
71
+ *
72
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
73
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
74
+ * automatically, unless release() is called
75
+ *
76
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
77
+ * re-acquire the task, unless pick() is called.
78
+ *
79
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
80
+ * Task will be picked up again by some connected client (this client will try as well,
81
+ * unless release() is called)
82
+ *
83
+ * @param listener - callback notified when change happened for particular key
84
+ */
85
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
86
+ }
87
+
88
+ /**
89
+ * @public
90
+ */
91
+ export declare interface IProvideAgentScheduler {
92
+ readonly IAgentScheduler: IAgentScheduler;
93
+ }
94
+
95
+ /**
96
+ * Events emitted by {@link TaskSubscription}.
97
+ *
98
+ * @public
99
+ */
100
+ export declare interface ITaskSubscriptionEvents extends IEvent {
101
+ (event: "gotTask" | "lostTask", listener: () => void): any;
102
+ }
103
+
104
+ /**
105
+ * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.
106
+ *
107
+ * @public
108
+ */
109
+ export declare class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
110
+ private readonly agentScheduler;
111
+ readonly taskId: string;
112
+ private subscribed;
113
+ /**
114
+ * @param agentScheduler - The AgentScheduler that will be subscribed against
115
+ * @param taskId - The string ID of the task to subscribe against
116
+ */
117
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
118
+ /**
119
+ * Check if currently holding ownership of the task.
120
+ * @returns true if currently the task owner, false otherwise.
121
+ */
122
+ haveTask(): boolean;
123
+ /**
124
+ * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.
125
+ * This is safe to call multiple times across multiple TaskSubscriptions.
126
+ */
127
+ volunteer(): void;
128
+ }
129
+
130
+ /* Excluded from this release type: TypedEventEmitter */
131
+
132
+ export { }
@@ -0,0 +1,132 @@
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
+
9
+ /**
10
+ * @public
11
+ */
12
+ export declare class AgentSchedulerFactory implements IFluidDataStoreFactory {
13
+ static readonly type = "_scheduler";
14
+ readonly type = "_scheduler";
15
+ get IFluidDataStoreFactory(): this;
16
+ static get registryEntry(): NamedFluidDataStoreRegistryEntry;
17
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
18
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
19
+ }
20
+
21
+ /**
22
+ * @public
23
+ */
24
+ export declare const IAgentScheduler: keyof IProvideAgentScheduler;
25
+
26
+ /**
27
+ * Agent scheduler distributes a set of tasks/variables across connected clients.
28
+ *
29
+ * @public
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
+ *
65
+ * @public
66
+ */
67
+ export declare interface IAgentSchedulerEvents extends IEvent {
68
+ /**
69
+ * Event when ownership of task changes
70
+ * @param event - name of the event:
71
+ *
72
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
73
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
74
+ * automatically, unless release() is called
75
+ *
76
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
77
+ * re-acquire the task, unless pick() is called.
78
+ *
79
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
80
+ * Task will be picked up again by some connected client (this client will try as well,
81
+ * unless release() is called)
82
+ *
83
+ * @param listener - callback notified when change happened for particular key
84
+ */
85
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
86
+ }
87
+
88
+ /**
89
+ * @public
90
+ */
91
+ export declare interface IProvideAgentScheduler {
92
+ readonly IAgentScheduler: IAgentScheduler;
93
+ }
94
+
95
+ /**
96
+ * Events emitted by {@link TaskSubscription}.
97
+ *
98
+ * @public
99
+ */
100
+ export declare interface ITaskSubscriptionEvents extends IEvent {
101
+ (event: "gotTask" | "lostTask", listener: () => void): any;
102
+ }
103
+
104
+ /**
105
+ * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.
106
+ *
107
+ * @public
108
+ */
109
+ export declare class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
110
+ private readonly agentScheduler;
111
+ readonly taskId: string;
112
+ private subscribed;
113
+ /**
114
+ * @param agentScheduler - The AgentScheduler that will be subscribed against
115
+ * @param taskId - The string ID of the task to subscribe against
116
+ */
117
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
118
+ /**
119
+ * Check if currently holding ownership of the task.
120
+ * @returns true if currently the task owner, false otherwise.
121
+ */
122
+ haveTask(): boolean;
123
+ /**
124
+ * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.
125
+ * This is safe to call multiple times across multiple TaskSubscriptions.
126
+ */
127
+ volunteer(): void;
128
+ }
129
+
130
+ /* Excluded from this release type: TypedEventEmitter */
131
+
132
+ export { }
@@ -0,0 +1,132 @@
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
+
9
+ /**
10
+ * @public
11
+ */
12
+ export declare class AgentSchedulerFactory implements IFluidDataStoreFactory {
13
+ static readonly type = "_scheduler";
14
+ readonly type = "_scheduler";
15
+ get IFluidDataStoreFactory(): this;
16
+ static get registryEntry(): NamedFluidDataStoreRegistryEntry;
17
+ static createChildInstance(parentContext: IFluidDataStoreContext): Promise<IAgentScheduler>;
18
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
19
+ }
20
+
21
+ /**
22
+ * @public
23
+ */
24
+ export declare const IAgentScheduler: keyof IProvideAgentScheduler;
25
+
26
+ /**
27
+ * Agent scheduler distributes a set of tasks/variables across connected clients.
28
+ *
29
+ * @public
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
+ *
65
+ * @public
66
+ */
67
+ export declare interface IAgentSchedulerEvents extends IEvent {
68
+ /**
69
+ * Event when ownership of task changes
70
+ * @param event - name of the event:
71
+ *
72
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
73
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
74
+ * automatically, unless release() is called
75
+ *
76
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
77
+ * re-acquire the task, unless pick() is called.
78
+ *
79
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
80
+ * Task will be picked up again by some connected client (this client will try as well,
81
+ * unless release() is called)
82
+ *
83
+ * @param listener - callback notified when change happened for particular key
84
+ */
85
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
86
+ }
87
+
88
+ /**
89
+ * @public
90
+ */
91
+ export declare interface IProvideAgentScheduler {
92
+ readonly IAgentScheduler: IAgentScheduler;
93
+ }
94
+
95
+ /**
96
+ * Events emitted by {@link TaskSubscription}.
97
+ *
98
+ * @public
99
+ */
100
+ export declare interface ITaskSubscriptionEvents extends IEvent {
101
+ (event: "gotTask" | "lostTask", listener: () => void): any;
102
+ }
103
+
104
+ /**
105
+ * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.
106
+ *
107
+ * @public
108
+ */
109
+ export declare class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
110
+ private readonly agentScheduler;
111
+ readonly taskId: string;
112
+ private subscribed;
113
+ /**
114
+ * @param agentScheduler - The AgentScheduler that will be subscribed against
115
+ * @param taskId - The string ID of the task to subscribe against
116
+ */
117
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
118
+ /**
119
+ * Check if currently holding ownership of the task.
120
+ * @returns true if currently the task owner, false otherwise.
121
+ */
122
+ haveTask(): boolean;
123
+ /**
124
+ * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.
125
+ * This is safe to call multiple times across multiple TaskSubscriptions.
126
+ */
127
+ volunteer(): void;
128
+ }
129
+
130
+ /* Excluded from this release type: TypedEventEmitter */
131
+
132
+ export { }
@@ -0,0 +1,131 @@
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
+ * @public
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
+ * @public
24
+ */
25
+ export declare const IAgentScheduler: keyof IProvideAgentScheduler;
26
+
27
+ /**
28
+ * Agent scheduler distributes a set of tasks/variables across connected clients.
29
+ *
30
+ * @public
31
+ */
32
+ export declare interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
33
+ /**
34
+ * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
35
+ * a new agent to run but does not have the capability to run the agent inside the host.
36
+ * Client can call pick() later if the capability changes.
37
+ *
38
+ * This method should only be called once per task. Duplicate calls will be rejected.
39
+ */
40
+ register(...taskUrls: string[]): Promise<void>;
41
+ /**
42
+ * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
43
+ * Resolves when the tasks are assigned to one of the connected clients.
44
+ *
45
+ * This method should only be called once per task. Duplicate calls will be rejected.
46
+ *
47
+ * @param worker - callback to run when task is picked up.
48
+ */
49
+ pick(taskId: string, worker: () => Promise<void>): Promise<void>;
50
+ /**
51
+ * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
52
+ *
53
+ * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
54
+ * App can call pickedTasks() to get the picked list first.
55
+ */
56
+ release(...taskUrls: string[]): Promise<void>;
57
+ /**
58
+ * Returns a list of all tasks running on this client
59
+ */
60
+ pickedTasks(): string[];
61
+ }
62
+
63
+ /**
64
+ * Events emitted by {@link (IAgentScheduler:interface)}.
65
+ *
66
+ * @public
67
+ */
68
+ export declare interface IAgentSchedulerEvents extends IEvent {
69
+ /**
70
+ * Event when ownership of task changes
71
+ * @param event - name of the event:
72
+ *
73
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
74
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
75
+ * automatically, unless release() is called
76
+ *
77
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
78
+ * re-acquire the task, unless pick() is called.
79
+ *
80
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
81
+ * Task will be picked up again by some connected client (this client will try as well,
82
+ * unless release() is called)
83
+ *
84
+ * @param listener - callback notified when change happened for particular key
85
+ */
86
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
87
+ }
88
+
89
+ /**
90
+ * @public
91
+ */
92
+ export declare interface IProvideAgentScheduler {
93
+ readonly IAgentScheduler: IAgentScheduler;
94
+ }
95
+
96
+ /**
97
+ * Events emitted by {@link TaskSubscription}.
98
+ *
99
+ * @public
100
+ */
101
+ export declare interface ITaskSubscriptionEvents extends IEvent {
102
+ (event: "gotTask" | "lostTask", listener: () => void): any;
103
+ }
104
+
105
+ /**
106
+ * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.
107
+ *
108
+ * @public
109
+ */
110
+ export declare class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {
111
+ private readonly agentScheduler;
112
+ readonly taskId: string;
113
+ private subscribed;
114
+ /**
115
+ * @param agentScheduler - The AgentScheduler that will be subscribed against
116
+ * @param taskId - The string ID of the task to subscribe against
117
+ */
118
+ constructor(agentScheduler: IAgentScheduler, taskId: string);
119
+ /**
120
+ * Check if currently holding ownership of the task.
121
+ * @returns true if currently the task owner, false otherwise.
122
+ */
123
+ haveTask(): boolean;
124
+ /**
125
+ * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.
126
+ * This is safe to call multiple times across multiple TaskSubscriptions.
127
+ */
128
+ volunteer(): void;
129
+ }
130
+
131
+ export { }
package/dist/agent.d.ts CHANGED
@@ -3,10 +3,21 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
6
+ /**
7
+ * @public
8
+ */
6
9
  export declare const IAgentScheduler: keyof IProvideAgentScheduler;
10
+ /**
11
+ * @public
12
+ */
7
13
  export interface IProvideAgentScheduler {
8
14
  readonly IAgentScheduler: IAgentScheduler;
9
15
  }
16
+ /**
17
+ * Events emitted by {@link (IAgentScheduler:interface)}.
18
+ *
19
+ * @public
20
+ */
10
21
  export interface IAgentSchedulerEvents extends IEvent {
11
22
  /**
12
23
  * Event when ownership of task changes
@@ -29,6 +40,8 @@ export interface IAgentSchedulerEvents extends IEvent {
29
40
  }
30
41
  /**
31
42
  * Agent scheduler distributes a set of tasks/variables across connected clients.
43
+ *
44
+ * @public
32
45
  */
33
46
  export interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
34
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEzF,eAAO,MAAM,eAAe,EAAE,MAAM,sBAA0C,CAAC;AAE/E,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC1C;AAED,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;;GAEG;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"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEzF;;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;;;;GAIG;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;;;;GAIG;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"}