@fluidframework/agent-scheduler 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277
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/.eslintrc.js +8 -10
- package/CHANGELOG.md +124 -0
- package/README.md +39 -3
- package/api-extractor-esm.json +4 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +4 -0
- package/api-report/agent-scheduler.api.md +71 -0
- package/dist/agent-scheduler-alpha.d.ts +127 -0
- package/dist/agent-scheduler-beta.d.ts +30 -0
- package/dist/agent-scheduler-public.d.ts +30 -0
- package/dist/agent-scheduler-untrimmed.d.ts +127 -0
- package/dist/{agent.js → agent.cjs} +4 -1
- package/dist/agent.cjs.map +1 -0
- package/dist/agent.d.ts +25 -10
- package/dist/agent.d.ts.map +1 -1
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/{scheduler.js → scheduler.cjs} +93 -57
- package/dist/scheduler.cjs.map +1 -0
- package/dist/scheduler.d.ts +10 -12
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/{taskSubscription.js → taskSubscription.cjs} +4 -3
- package/dist/taskSubscription.cjs.map +1 -0
- package/dist/taskSubscription.d.ts +7 -2
- package/dist/taskSubscription.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/agent-scheduler-alpha.d.mts +127 -0
- package/lib/agent-scheduler-beta.d.mts +30 -0
- package/lib/agent-scheduler-public.d.mts +30 -0
- package/lib/agent-scheduler-untrimmed.d.mts +127 -0
- package/lib/{agent.d.ts → agent.d.mts} +26 -11
- package/lib/agent.d.mts.map +1 -0
- package/lib/{agent.js → agent.mjs} +4 -1
- package/lib/agent.mjs.map +1 -0
- package/lib/index.d.mts +8 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +8 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{scheduler.d.ts → scheduler.d.mts} +12 -14
- package/lib/scheduler.d.mts.map +1 -0
- package/lib/{scheduler.js → scheduler.mjs} +83 -47
- package/lib/scheduler.mjs.map +1 -0
- package/lib/{taskSubscription.d.ts → taskSubscription.d.mts} +9 -4
- package/lib/taskSubscription.d.mts.map +1 -0
- package/lib/{taskSubscription.js → taskSubscription.mjs} +3 -2
- package/lib/taskSubscription.mjs.map +1 -0
- package/package.json +115 -73
- package/prettier.config.cjs +8 -0
- package/src/agent.ts +63 -45
- package/src/index.ts +2 -2
- package/src/scheduler.ts +469 -405
- package/src/taskSubscription.ts +55 -47
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/dist/agent.js.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/scheduler.js.map +0 -1
- package/dist/taskSubscription.js.map +0 -1
- package/lib/agent.d.ts.map +0 -1
- package/lib/agent.js.map +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
- package/lib/scheduler.d.ts.map +0 -1
- package/lib/scheduler.js.map +0 -1
- package/lib/taskSubscription.d.ts.map +0 -1
- package/lib/taskSubscription.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
package/.eslintrc.js
CHANGED
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
13
|
+
},
|
|
14
|
+
};
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @fluidframework/agent-scheduler
|
|
2
|
+
|
|
3
|
+
## 2.0.0-internal.8.0.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.0.0-internal.7.4.0
|
|
8
|
+
|
|
9
|
+
Dependency updates only.
|
|
10
|
+
|
|
11
|
+
## 2.0.0-internal.7.3.0
|
|
12
|
+
|
|
13
|
+
Dependency updates only.
|
|
14
|
+
|
|
15
|
+
## 2.0.0-internal.7.2.0
|
|
16
|
+
|
|
17
|
+
Dependency updates only.
|
|
18
|
+
|
|
19
|
+
## 2.0.0-internal.7.1.0
|
|
20
|
+
|
|
21
|
+
Dependency updates only.
|
|
22
|
+
|
|
23
|
+
## 2.0.0-internal.7.0.0
|
|
24
|
+
|
|
25
|
+
### Major Changes
|
|
26
|
+
|
|
27
|
+
- test-utils: provideEntryPoint is required [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
28
|
+
|
|
29
|
+
The optional `provideEntryPoint` method has become required on a number of constructors. A value will need to be provided to the following classes:
|
|
30
|
+
|
|
31
|
+
- `BaseContainerRuntimeFactory`
|
|
32
|
+
- `RuntimeFactory`
|
|
33
|
+
- `ContainerRuntime` (constructor and `loadRuntime`)
|
|
34
|
+
- `FluidDataStoreRuntime`
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
For more details, see [Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
|
|
42
|
+
|
|
43
|
+
- Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
44
|
+
|
|
45
|
+
The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
|
|
46
|
+
|
|
47
|
+
## 2.0.0-internal.6.4.0
|
|
48
|
+
|
|
49
|
+
Dependency updates only.
|
|
50
|
+
|
|
51
|
+
## 2.0.0-internal.6.3.0
|
|
52
|
+
|
|
53
|
+
Dependency updates only.
|
|
54
|
+
|
|
55
|
+
## 2.0.0-internal.6.2.0
|
|
56
|
+
|
|
57
|
+
### Minor Changes
|
|
58
|
+
|
|
59
|
+
- Remove use of @fluidframework/common-definitions ([#16638](https://github.com/microsoft/FluidFramework/issues/16638)) [a8c81509c9](https://github.com/microsoft/FluidFramework/commits/a8c81509c9bf09cfb2092ebcf7265205f9eb6dbf)
|
|
60
|
+
|
|
61
|
+
The **@fluidframework/common-definitions** package is being deprecated, so the following interfaces and types are now
|
|
62
|
+
imported from the **@fluidframework/core-interfaces** package:
|
|
63
|
+
|
|
64
|
+
- interface IDisposable
|
|
65
|
+
- interface IErrorEvent
|
|
66
|
+
- interface IErrorEvent
|
|
67
|
+
- interface IEvent
|
|
68
|
+
- interface IEventProvider
|
|
69
|
+
- interface ILoggingError
|
|
70
|
+
- interface ITaggedTelemetryPropertyType
|
|
71
|
+
- interface ITelemetryBaseEvent
|
|
72
|
+
- interface ITelemetryBaseLogger
|
|
73
|
+
- interface ITelemetryErrorEvent
|
|
74
|
+
- interface ITelemetryGenericEvent
|
|
75
|
+
- interface ITelemetryLogger
|
|
76
|
+
- interface ITelemetryPerformanceEvent
|
|
77
|
+
- interface ITelemetryProperties
|
|
78
|
+
- type ExtendEventProvider
|
|
79
|
+
- type IEventThisPlaceHolder
|
|
80
|
+
- type IEventTransformer
|
|
81
|
+
- type ReplaceIEventThisPlaceHolder
|
|
82
|
+
- type ReplaceIEventThisPlaceHolder
|
|
83
|
+
- type TelemetryEventCategory
|
|
84
|
+
- type TelemetryEventPropertyType
|
|
85
|
+
|
|
86
|
+
## 2.0.0-internal.6.1.0
|
|
87
|
+
|
|
88
|
+
Dependency updates only.
|
|
89
|
+
|
|
90
|
+
## 2.0.0-internal.6.0.0
|
|
91
|
+
|
|
92
|
+
### Major Changes
|
|
93
|
+
|
|
94
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
95
|
+
|
|
96
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
97
|
+
|
|
98
|
+
## 2.0.0-internal.5.4.0
|
|
99
|
+
|
|
100
|
+
Dependency updates only.
|
|
101
|
+
|
|
102
|
+
## 2.0.0-internal.5.3.0
|
|
103
|
+
|
|
104
|
+
Dependency updates only.
|
|
105
|
+
|
|
106
|
+
## 2.0.0-internal.5.2.0
|
|
107
|
+
|
|
108
|
+
Dependency updates only.
|
|
109
|
+
|
|
110
|
+
## 2.0.0-internal.5.1.0
|
|
111
|
+
|
|
112
|
+
Dependency updates only.
|
|
113
|
+
|
|
114
|
+
## 2.0.0-internal.5.0.0
|
|
115
|
+
|
|
116
|
+
Dependency updates only.
|
|
117
|
+
|
|
118
|
+
## 2.0.0-internal.4.4.0
|
|
119
|
+
|
|
120
|
+
Dependency updates only.
|
|
121
|
+
|
|
122
|
+
## 2.0.0-internal.4.1.0
|
|
123
|
+
|
|
124
|
+
Dependency updates only.
|
package/README.md
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
# @fluidframework/agent-scheduler
|
|
2
2
|
|
|
3
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore-start -->
|
|
6
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
7
|
+
|
|
8
|
+
## Using Fluid Framework libraries
|
|
9
|
+
|
|
10
|
+
When taking a dependency on a Fluid Framework library, we recommend using a `^` (caret) version range, such as `^1.3.4`.
|
|
11
|
+
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
12
|
+
library consumers should always prefer `^`.
|
|
13
|
+
|
|
14
|
+
Note that when depending on a library version of the form `2.0.0-internal.x.y.z`, called the Fluid internal version scheme,
|
|
15
|
+
you must use a `>= <` dependency range (such as `>=2.0.0-internal.x.y.z <2.0.0-internal.w.0.0` where `w` is `x+1`).
|
|
16
|
+
Standard `^` and `~` ranges will not work as expected.
|
|
17
|
+
See the [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
|
|
18
|
+
package for more information including tools to convert between version schemes.
|
|
19
|
+
|
|
20
|
+
<!-- prettier-ignore-end -->
|
|
21
|
+
|
|
22
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
23
|
+
|
|
3
24
|
## AgentScheduler
|
|
4
25
|
|
|
5
26
|
The `AgentScheduler` is a data object that can be used to assign tasks to unique clients.
|
|
6
27
|
|
|
7
28
|
### Creation
|
|
8
29
|
|
|
9
|
-
To create an `AgentScheduler` as a child instance of your data object, add the factory to your registry and call the static `createChildInstance` function on the factory.
|
|
30
|
+
To create an `AgentScheduler` as a child instance of your data object, add the factory to your registry and call the static `createChildInstance` function on the factory. You can then retrieve and store its handle to access it later:
|
|
10
31
|
|
|
11
32
|
```typescript
|
|
12
33
|
// In your Data Object
|
|
@@ -22,9 +43,24 @@ export const MyDataObjectFactory = new DataObjectFactory(
|
|
|
22
43
|
[],
|
|
23
44
|
{},
|
|
24
45
|
new Map([
|
|
25
|
-
|
|
46
|
+
AgentSchedulerFactory.registryEntry,
|
|
26
47
|
]),
|
|
27
48
|
);
|
|
28
49
|
```
|
|
29
50
|
|
|
30
|
-
|
|
51
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
|
|
52
|
+
|
|
53
|
+
<!-- prettier-ignore-start -->
|
|
54
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
55
|
+
|
|
56
|
+
## Trademark
|
|
57
|
+
|
|
58
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
59
|
+
|
|
60
|
+
Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
61
|
+
|
|
62
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
63
|
+
|
|
64
|
+
<!-- prettier-ignore-end -->
|
|
65
|
+
|
|
66
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
@@ -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
|
+
// @alpha (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
|
+
// @alpha (undocumented)
|
|
33
|
+
export const IAgentScheduler: keyof IProvideAgentScheduler;
|
|
34
|
+
|
|
35
|
+
// @alpha
|
|
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
|
+
// @alpha
|
|
44
|
+
export interface IAgentSchedulerEvents extends IEvent {
|
|
45
|
+
(event: "picked" | "released" | "lost", listener: (taskId: string) => void): any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// @alpha (undocumented)
|
|
49
|
+
export interface IProvideAgentScheduler {
|
|
50
|
+
// (undocumented)
|
|
51
|
+
readonly IAgentScheduler: IAgentScheduler;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// @alpha
|
|
55
|
+
export interface ITaskSubscriptionEvents extends IEvent {
|
|
56
|
+
// (undocumented)
|
|
57
|
+
(event: "gotTask" | "lostTask", listener: () => void): any;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// @alpha
|
|
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,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 { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.cjs","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACU,QAAA,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"]}
|