@fluidframework/agent-scheduler 2.0.0-internal.3.0.1 → 2.0.0-internal.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMzE,OAAO,EACH,qBAAqB,EACrB,iBAAiB,GAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAA6B,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAOlF,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAGlC,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,GAAG,IAAI,EAAE,aAAa,CAAC;AAElD,MAAM,OAAO,GAAG,KAAK,EAAW,GAAe,EAAE,GAAW,EAAc,EAAE;IACxE,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAI,GAAG,CAAC,CAAC;IACnC,IAAI,UAAU,KAAK,SAAS,EAAE;QAC1B,OAAO,UAAU,CAAC;KACrB;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,CAAC,OAAsB,EAAE,EAAE;YACvC,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE;gBACrB,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;gBACjC,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAI,OAAO,CAAC,GAAG,CAAC,CAAC;gBACtC,IAAI,KAAK,KAAK,SAAS,EAAE;oBACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CA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EAAE,UAAU,CAAC,CAAC;QAC3C,SAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,IAAI,EAAE,kCAAkC,CAAC,CAAC;QAE3F,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;;AA7BsB,0BAAI,GAAG,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n FluidObject,\n IFluidHandle,\n IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport {\n FluidDataStoreRuntime,\n FluidObjectHandle,\n ISharedObjectRegistry,\n} from \"@fluidframework/datastore\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { ISharedMap, IValueChanged, SharedMap } from \"@fluidframework/map\";\nimport { ConsensusRegisterCollection } from \"@fluidframework/register-collection\";\nimport { IFluidDataStoreRuntime, IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n IFluidDataStoreContext,\n IFluidDataStoreFactory,\n NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { IAgentScheduler, IAgentSchedulerEvents } from \"./agent\";\n\n// Note: making sure this ID is unique and does not collide with storage provided clientID\nconst UnattachedClientId = `${uuid()}_unattached`;\n\nconst mapWait = async <T = any>(map: ISharedMap, key: string): Promise<T> => {\n const maybeValue = map.get<T>(key);\n if (maybeValue !== undefined) {\n return maybeValue;\n }\n\n return new Promise((resolve) => {\n const handler = (changed: IValueChanged) => {\n if (changed.key === key) {\n map.off(\"valueChanged\", handler);\n const value = map.get<T>(changed.key);\n if (value === undefined) {\n throw new Error(\"Unexpected valueChanged result\");\n }\n resolve(value);\n }\n };\n map.on(\"valueChanged\", handler);\n });\n};\n\nconst schedulerId = \"scheduler\";\n\nexport class AgentScheduler extends TypedEventEmitter<IAgentSchedulerEvents> implements IAgentScheduler {\n public static async load(runtime: IFluidDataStoreRuntime, context: IFluidDataStoreContext, existing: boolean) {\n let root: ISharedMap;\n let consensusRegisterCollection: ConsensusRegisterCollection<string | null>;\n if (!existing) {\n root = SharedMap.create(runtime, \"root\");\n root.bindToContext();\n consensusRegisterCollection = ConsensusRegisterCollection.create(runtime);\n consensusRegisterCollection.bindToContext();\n root.set(schedulerId, consensusRegisterCollection.handle);\n } else {\n root = await runtime.getChannel(\"root\") as ISharedMap;\n const handle = await mapWait<IFluidHandle<ConsensusRegisterCollection<string | null>>>(root, schedulerId);\n assert(handle !== undefined, 0x116 /* \"Missing handle on scheduler load\" */);\n consensusRegisterCollection = await handle.get();\n }\n const agentScheduler = new AgentScheduler(runtime, context, consensusRegisterCollection);\n agentScheduler.initialize();\n\n return agentScheduler;\n }\n\n public get IAgentScheduler() { return this; }\n public get IFluidLoadable() { return this; }\n\n private get clientId(): string {\n if (this.runtime.attachState === AttachState.Detached) {\n return UnattachedClientId;\n }\n const clientId = this.runtime.clientId;\n assert(!!clientId, 0x117 /* \"Trying to get missing clientId!\" */);\n return clientId;\n }\n\n // Set of tasks registered by this client.\n // Has no relationship with lists below.\n // The only requirement here - a task can be registered by a client only once.\n // Other clients can pick these tasks.\n private readonly registeredTasks = new Set<string>();\n\n // List of all tasks client is capable of running (essentially expressed desire to run)\n // Client will proactively attempt to pick them up these tasks if they are not assigned to other clients.\n // This is a strict superset of tasks running in the client.\n private readonly locallyRunnableTasks = new Map<string, () => Promise<void>>();\n\n // Set of registered tasks client is currently running.\n // It's subset of this.locallyRunnableTasks\n private runningTasks = new Set<string>();\n\n private readonly _handle: IFluidHandle<this>;\n\n constructor(\n private readonly runtime: IFluidDataStoreRuntime,\n private readonly context: IFluidDataStoreContext,\n private readonly consensusRegisterCollection: ConsensusRegisterCollection<string | null>,\n ) {\n super();\n this._handle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n }\n\n public get handle() {\n return this._handle;\n }\n\n public async register(...taskUrls: string[]): Promise<void> {\n for (const taskUrl of taskUrls) {\n if (this.registeredTasks.has(taskUrl)) {\n throw new Error(`${taskUrl} is already registered`);\n }\n }\n const unregisteredTasks: string[] = [];\n for (const taskUrl of taskUrls) {\n this.registeredTasks.add(taskUrl);\n // Only register for a new task.\n const currentClient = this.getTaskClientId(taskUrl);\n if (currentClient === undefined) {\n unregisteredTasks.push(taskUrl);\n }\n }\n return this.registerCore(unregisteredTasks);\n }\n\n public async pick(taskId: string, worker: () => Promise<void>): Promise<void> {\n if (this.locallyRunnableTasks.has(taskId)) {\n throw new Error(`${taskId} is already attempted`);\n }\n this.locallyRunnableTasks.set(taskId, worker);\n\n // We have a policy to disallow non-interactive clients from taking tasks. Callers of pick() can\n // either perform this check proactively and call conditionally, or catch the error (in which case\n // they can know they will not get the task).\n assert(this.context.deltaManager.clientDetails.capabilities.interactive,\n 0x118 /* \"Bad client interactive check\" */);\n\n // Check the current status and express interest if it's a new one (undefined) or currently unpicked (null).\n if (this.isActive()) {\n const currentClient = this.getTaskClientId(taskId);\n if (currentClient === undefined || currentClient === null) {\n await this.writeCore(taskId, this.clientId);\n }\n }\n }\n\n public async release(...taskUrls: string[]): Promise<void> {\n const active = this.isActive();\n for (const taskUrl of taskUrls) {\n if (!this.locallyRunnableTasks.has(taskUrl)) {\n throw new Error(`${taskUrl} was never registered`);\n }\n // Note - the assumption is - we are connected.\n // If not - all tasks should have been dropped already on disconnect / attachment\n assert(active, 0x119 /* \"This agent became inactive while releasing\" */);\n if (this.getTaskClientId(taskUrl) !== this.clientId) {\n throw new Error(`${taskUrl} was never picked`);\n }\n }\n return this.releaseCore([...taskUrls]);\n }\n\n public pickedTasks(): string[] {\n return Array.from(this.runningTasks.values());\n }\n\n private async registerCore(taskUrls: string[]): Promise<void> {\n if (taskUrls.length > 0) {\n const registersP: Promise<void>[] = [];\n for (const taskUrl of taskUrls) {\n registersP.push(this.writeCore(taskUrl, null));\n }\n await Promise.all(registersP);\n\n // The registers should have up to date results now. Check the status.\n for (const taskUrl of taskUrls) {\n const taskStatus = this.getTaskClientId(taskUrl);\n\n // Task should be either registered (null) or picked up.\n assert(taskStatus !== undefined, 0x11a /* `Unsuccessful registration` */);\n }\n }\n }\n\n private async releaseCore(taskUrls: string[]) {\n if (taskUrls.length > 0) {\n const releasesP: Promise<void>[] = [];\n for (const taskUrl of taskUrls) {\n // Remove from local map so that it can be picked later.\n this.locallyRunnableTasks.delete(taskUrl);\n releasesP.push(this.writeCore(taskUrl, null));\n }\n await Promise.all(releasesP);\n }\n }\n\n private async clearTasks(taskUrls: string[]) {\n assert(this.isActive(), 0x11b /* \"Trying to clear tasks on inactive agent\" */);\n const clearP: Promise<void>[] = [];\n for (const taskUrl of taskUrls) {\n clearP.push(this.writeCore(taskUrl, null));\n }\n await Promise.all(clearP);\n }\n\n private getTaskClientId(url: string): string | null | undefined {\n return this.consensusRegisterCollection.read(url);\n }\n\n private async writeCore(key: string, clientId: string | null): Promise<void> {\n await this.consensusRegisterCollection.write(key, clientId);\n }\n\n private initialize() {\n const quorum = this.runtime.getQuorum();\n // A client left the quorum. Iterate and clear tasks held by that client.\n // Ideally a leader should do this cleanup. But it's complicated when a leader itself leaves.\n // Probably okay for now to have every client try to do this.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n quorum.on(\"removeMember\", async (clientId: string) => {\n assert(this.runtime.objectsRoutingContext.isAttached, 0x11c /* \"Detached object routing context\" */);\n // Cleanup only if connected. If not, cleanup will happen in initializeCore() that runs on connection.\n if (this.isActive()) {\n const tasks: Promise<any>[] = [];\n const leftTasks: string[] = [];\n for (const taskUrl of this.consensusRegisterCollection.keys()) {\n if (this.getTaskClientId(taskUrl) === clientId) {\n if (this.locallyRunnableTasks.has(taskUrl)) {\n tasks.push(this.writeCore(taskUrl, this.clientId));\n } else {\n leftTasks.push(taskUrl);\n }\n }\n }\n tasks.push(this.clearTasks(leftTasks));\n await Promise.all(tasks).catch((error) => {\n this.sendErrorEvent(\"AgentScheduler_RemoveMemberError\", error);\n });\n }\n });\n\n // Listeners for new/released tasks. All clients will try to grab at the same time.\n // May be we want a randomized timer (Something like raft) to reduce chattiness?\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.consensusRegisterCollection.on(\"atomicChanged\", async (key: string, currentClient: string | null) => {\n // Check if this client was chosen.\n if (this.isActive() && currentClient === this.clientId) {\n this.onNewTaskAssigned(key);\n } else {\n // The call below mutates the consensusRegisterCollection in\n // its event handler, which is not safe.\n // We need to force this to be part of a different batch of ops by\n // scheduling a microtask in order to work around the current validations.\n // This is not recommended and should be avoided.\n await Promise.resolve().then(async () => {\n await this.onTaskReassigned(key, currentClient);\n });\n }\n });\n\n if (this.isActive()) {\n this.initializeCore();\n }\n\n this.runtime.on(\"connected\", () => {\n if (this.isActive()) {\n this.initializeCore();\n }\n });\n\n if (this.runtime.attachState === AttachState.Detached) {\n this.runtime.waitAttached().then(() => {\n this.clearRunningTasks();\n }).catch((error) => {\n this.sendErrorEvent(\"AgentScheduler_clearRunningTasks\", error);\n });\n }\n\n this.runtime.on(\"disconnected\", () => {\n if (this.runtime.attachState !== AttachState.Detached) {\n this.clearRunningTasks();\n }\n });\n }\n\n private onNewTaskAssigned(key: string) {\n assert(!this.runningTasks.has(key), 0x11d /* \"task is already running\" */);\n this.runningTasks.add(key);\n const worker = this.locallyRunnableTasks.get(key);\n if (worker === undefined) {\n this.sendErrorEvent(\"AgentScheduler_UnwantedChange\", undefined, key);\n } else {\n this.emit(\"picked\", key);\n worker().catch((error) => {\n this.sendErrorEvent(\"AgentScheduler_FailedWork\", error, key);\n });\n }\n }\n\n private async onTaskReassigned(key: string, currentClient: string | null) {\n if (this.runningTasks.has(key)) {\n this.runningTasks.delete(key);\n this.emit(\"released\", key);\n }\n assert(currentClient !== undefined, 0x11e /* \"client is undefined\" */);\n if (this.isActive()) {\n // attempt to pick up task if we are connected.\n // If not, initializeCore() will do it when connected\n if (currentClient === null) {\n if (this.locallyRunnableTasks.has(key)) {\n await this.writeCore(key, this.clientId);\n }\n }\n // Check if the op came from dropped client\n // This could happen when \"old\" ops are submitted on reconnection.\n // They carry \"old\" ref seq number, but if write is not contested, it will get accepted\n else if (this.runtime.getQuorum().getMember(currentClient) === undefined) {\n await this.writeCore(key, null);\n }\n }\n }\n\n private isActive() {\n // Scheduler should be active in detached container.\n if (this.runtime.attachState === AttachState.Detached) {\n return true;\n }\n if (!this.runtime.connected) {\n return false;\n }\n\n // Note: we are not checking for this.context.deltaManager.clientDetails.capabilities.interactive\n // here. Instead we assert in pick() if a non-interactive client tries to pick.\n\n return this.context.deltaManager.active;\n }\n\n private initializeCore() {\n // Nobody released the tasks held by last client in previous session.\n // Check to see if this client needs to do this.\n const clearCandidates: string[] = [];\n const tasks: Promise<any>[] = [];\n\n for (const [taskUrl] of this.locallyRunnableTasks) {\n if (!this.getTaskClientId(taskUrl)) {\n tasks.push(this.writeCore(taskUrl, this.clientId));\n }\n }\n\n for (const taskUrl of this.consensusRegisterCollection.keys()) {\n const currentClient = this.getTaskClientId(taskUrl);\n if (currentClient && this.runtime.getQuorum().getMember(currentClient) === undefined) {\n clearCandidates.push(taskUrl);\n }\n }\n\n tasks.push(this.clearTasks(clearCandidates));\n\n Promise.all(tasks).catch((error) => {\n this.sendErrorEvent(\"AgentScheduler_InitError\", error);\n });\n }\n\n private clearRunningTasks() {\n const tasks = this.runningTasks;\n this.runningTasks = new Set<string>();\n\n if (this.isActive()) {\n // Clear all tasks with UnattachedClientId (if was unattached) and reapply for tasks with new clientId\n // If we are simply disconnected, then proper cleanup will be done on connection.\n this.initializeCore();\n }\n\n for (const task of tasks) {\n this.emit(\"lost\", task);\n }\n }\n\n private sendErrorEvent(eventName: string, error: any, key?: string) {\n this.runtime.logger.sendErrorEvent({ eventName, key }, error);\n }\n}\n\nclass AgentSchedulerRuntime extends FluidDataStoreRuntime {\n constructor(\n dataStoreContext: IFluidDataStoreContext,\n sharedObjectRegistry: ISharedObjectRegistry,\n existing: boolean,\n ) {\n super(\n dataStoreContext,\n sharedObjectRegistry,\n existing,\n async () => AgentScheduler.load(this, dataStoreContext, existing));\n }\n public async request(request: IRequest) {\n const response = await super.request(request);\n if (response.status === 404) {\n if (request.url === \"\" || request.url === \"/\") {\n const agentScheduler = await this.entryPoint?.get();\n assert(agentScheduler !== undefined,\n 0x466 /* entryPoint for AgentSchedulerRuntime should have been initialized by now */);\n\n return { status: 200, mimeType: \"fluid/object\", value: agentScheduler };\n }\n }\n return response;\n }\n}\n\nexport class AgentSchedulerFactory implements IFluidDataStoreFactory {\n public static readonly type = \"_scheduler\";\n public readonly type = AgentSchedulerFactory.type;\n\n public get IFluidDataStoreFactory() { return this; }\n\n public static get registryEntry(): NamedFluidDataStoreRegistryEntry {\n return [this.type, Promise.resolve(new AgentSchedulerFactory())];\n }\n\n public static async createChildInstance(parentContext: IFluidDataStoreContext): Promise<AgentScheduler> {\n const packagePath = [...parentContext.packagePath, AgentSchedulerFactory.type];\n const dataStore = await parentContext.containerRuntime.createDataStore(packagePath);\n const entryPoint: FluidObject<IAgentScheduler> | undefined = await dataStore.entryPoint?.get();\n\n // AgentSchedulerRuntime always puts an AgentScheduler object in the data store's entryPoint, but double-check\n // while we plumb entryPoints correctly everywhere, so we can be sure the cast below is fine.\n assert(entryPoint?.IAgentScheduler !== undefined,\n 0x467 /* The data store's entryPoint is not an AgentScheduler! */);\n return entryPoint as unknown as AgentScheduler;\n }\n\n public async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n const mapFactory = SharedMap.getFactory();\n const consensusRegisterCollectionFactory = ConsensusRegisterCollection.getFactory();\n const dataTypes = new Map<string, IChannelFactory>();\n dataTypes.set(mapFactory.type, mapFactory);\n dataTypes.set(consensusRegisterCollectionFactory.type, consensusRegisterCollectionFactory);\n\n return new AgentSchedulerRuntime(context, dataTypes, existing);\n }\n}\n"]}
1
+ {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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F,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;QAC1C,MAAM,kCAAkC,GAAG,2BAA2B,CAAC,UAAU,EAAE,CAAC;QACpF,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QACrD,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC3C,SAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,IAAI,EAAE,kCAAkC,CAAC,CAAC;QAE3F,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChE,CAAC;;AApCsB,0BAAI,GAAG,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { FluidObject, IFluidHandle, IRequest } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport {\n\tFluidDataStoreRuntime,\n\tFluidObjectHandle,\n\tISharedObjectRegistry,\n} from \"@fluidframework/datastore\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { ISharedMap, IValueChanged, SharedMap } from \"@fluidframework/map\";\nimport { ConsensusRegisterCollection } from \"@fluidframework/register-collection\";\nimport { IFluidDataStoreRuntime, IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { IAgentScheduler, IAgentSchedulerEvents } from \"./agent\";\n\n// Note: making sure this ID is unique and does not collide with storage provided clientID\nconst UnattachedClientId = `${uuid()}_unattached`;\n\nconst mapWait = async <T = any>(map: ISharedMap, key: string): Promise<T> => {\n\tconst maybeValue = map.get<T>(key);\n\tif (maybeValue !== undefined) {\n\t\treturn maybeValue;\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tconst handler = (changed: IValueChanged) => {\n\t\t\tif (changed.key === key) {\n\t\t\t\tmap.off(\"valueChanged\", handler);\n\t\t\t\tconst value = map.get<T>(changed.key);\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tthrow new Error(\"Unexpected valueChanged result\");\n\t\t\t\t}\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t};\n\t\tmap.on(\"valueChanged\", handler);\n\t});\n};\n\nconst schedulerId = \"scheduler\";\n\nexport class AgentScheduler\n\textends TypedEventEmitter<IAgentSchedulerEvents>\n\timplements IAgentScheduler\n{\n\tpublic static async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t) {\n\t\tlet root: ISharedMap;\n\t\tlet consensusRegisterCollection: ConsensusRegisterCollection<string | null>;\n\t\tif (!existing) {\n\t\t\troot = SharedMap.create(runtime, \"root\");\n\t\t\troot.bindToContext();\n\t\t\tconsensusRegisterCollection = ConsensusRegisterCollection.create(runtime);\n\t\t\tconsensusRegisterCollection.bindToContext();\n\t\t\troot.set(schedulerId, consensusRegisterCollection.handle);\n\t\t} else {\n\t\t\troot = (await runtime.getChannel(\"root\")) as ISharedMap;\n\t\t\tconst handle = await mapWait<IFluidHandle<ConsensusRegisterCollection<string | null>>>(\n\t\t\t\troot,\n\t\t\t\tschedulerId,\n\t\t\t);\n\t\t\tassert(handle !== undefined, 0x116 /* \"Missing handle on scheduler load\" */);\n\t\t\tconsensusRegisterCollection = await handle.get();\n\t\t}\n\t\tconst agentScheduler = new AgentScheduler(runtime, context, consensusRegisterCollection);\n\t\tagentScheduler.initialize();\n\n\t\treturn agentScheduler;\n\t}\n\n\tpublic get IAgentScheduler() {\n\t\treturn this;\n\t}\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tprivate get clientId(): string {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn UnattachedClientId;\n\t\t}\n\t\tconst clientId = this.runtime.clientId;\n\t\tassert(!!clientId, 0x117 /* \"Trying to get missing clientId!\" */);\n\t\treturn clientId;\n\t}\n\n\t// Set of tasks registered by this client.\n\t// Has no relationship with lists below.\n\t// The only requirement here - a task can be registered by a client only once.\n\t// Other clients can pick these tasks.\n\tprivate readonly registeredTasks = new Set<string>();\n\n\t// List of all tasks client is capable of running (essentially expressed desire to run)\n\t// Client will proactively attempt to pick them up these tasks if they are not assigned to other clients.\n\t// This is a strict superset of tasks running in the client.\n\tprivate readonly locallyRunnableTasks = new Map<string, () => Promise<void>>();\n\n\t// Set of registered tasks client is currently running.\n\t// It's subset of this.locallyRunnableTasks\n\tprivate runningTasks = new Set<string>();\n\n\tprivate readonly _handle: IFluidHandle<this>;\n\n\tconstructor(\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly context: IFluidDataStoreContext,\n\t\tprivate readonly consensusRegisterCollection: ConsensusRegisterCollection<string | null>,\n\t) {\n\t\tsuper();\n\t\tthis._handle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\t}\n\n\tpublic get handle() {\n\t\treturn this._handle;\n\t}\n\n\tpublic async register(...taskUrls: string[]): Promise<void> {\n\t\tfor (const taskUrl of taskUrls) {\n\t\t\tif (this.registeredTasks.has(taskUrl)) {\n\t\t\t\tthrow new UsageError(`Task is already registered`, {\n\t\t\t\t\ttaskUrl: { tag: TelemetryDataTag.CodeArtifact, value: taskUrl },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tconst unregisteredTasks: string[] = [];\n\t\tfor (const taskUrl of taskUrls) {\n\t\t\tthis.registeredTasks.add(taskUrl);\n\t\t\t// Only register for a new task.\n\t\t\tconst currentClient = this.getTaskClientId(taskUrl);\n\t\t\tif (currentClient === undefined) {\n\t\t\t\tunregisteredTasks.push(taskUrl);\n\t\t\t}\n\t\t}\n\t\treturn this.registerCore(unregisteredTasks);\n\t}\n\n\tpublic async pick(taskId: string, worker: () => Promise<void>): Promise<void> {\n\t\tif (this.locallyRunnableTasks.has(taskId)) {\n\t\t\tthrow new UsageError(`Task is already attempted`, {\n\t\t\t\ttaskUrl: { tag: TelemetryDataTag.CodeArtifact, value: taskId },\n\t\t\t});\n\t\t}\n\t\tthis.locallyRunnableTasks.set(taskId, worker);\n\n\t\t// We have a policy to disallow non-interactive clients from taking tasks. Callers of pick() can\n\t\t// either perform this check proactively and call conditionally, or catch the error (in which case\n\t\t// they can know they will not get the task).\n\t\tassert(\n\t\t\tthis.context.deltaManager.clientDetails.capabilities.interactive,\n\t\t\t0x118 /* \"Bad client interactive check\" */,\n\t\t);\n\n\t\t// Check the current status and express interest if it's a new one (undefined) or currently unpicked (null).\n\t\tif (this.isActive()) {\n\t\t\tconst currentClient = this.getTaskClientId(taskId);\n\t\t\tif (currentClient === undefined || currentClient === null) {\n\t\t\t\tawait this.writeCore(taskId, this.clientId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async release(...taskUrls: string[]): Promise<void> {\n\t\tconst active = this.isActive();\n\t\tfor (const taskUrl of taskUrls) {\n\t\t\tif (!this.locallyRunnableTasks.has(taskUrl)) {\n\t\t\t\tthrow new UsageError(`Task was never registered`, {\n\t\t\t\t\ttaskUrl: { tag: TelemetryDataTag.CodeArtifact, value: taskUrl },\n\t\t\t\t});\n\t\t\t}\n\t\t\t// Note - the assumption is - we are connected.\n\t\t\t// If not - all tasks should have been dropped already on disconnect / attachment\n\t\t\tassert(active, 0x119 /* \"This agent became inactive while releasing\" */);\n\t\t\tif (this.getTaskClientId(taskUrl) !== this.clientId) {\n\t\t\t\tthrow new UsageError(`Task was never picked`, {\n\t\t\t\t\ttaskUrl: { tag: TelemetryDataTag.CodeArtifact, value: taskUrl },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn this.releaseCore([...taskUrls]);\n\t}\n\n\tpublic pickedTasks(): string[] {\n\t\treturn Array.from(this.runningTasks.values());\n\t}\n\n\tprivate async registerCore(taskUrls: string[]): Promise<void> {\n\t\tif (taskUrls.length > 0) {\n\t\t\tconst registersP: Promise<void>[] = [];\n\t\t\tfor (const taskUrl of taskUrls) {\n\t\t\t\tregistersP.push(this.writeCore(taskUrl, null));\n\t\t\t}\n\t\t\tawait Promise.all(registersP);\n\n\t\t\t// The registers should have up to date results now. Check the status.\n\t\t\tfor (const taskUrl of taskUrls) {\n\t\t\t\tconst taskStatus = this.getTaskClientId(taskUrl);\n\n\t\t\t\t// Task should be either registered (null) or picked up.\n\t\t\t\tassert(taskStatus !== undefined, 0x11a /* `Unsuccessful registration` */);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async releaseCore(taskUrls: string[]) {\n\t\tif (taskUrls.length > 0) {\n\t\t\tconst releasesP: Promise<void>[] = [];\n\t\t\tfor (const taskUrl of taskUrls) {\n\t\t\t\t// Remove from local map so that it can be picked later.\n\t\t\t\tthis.locallyRunnableTasks.delete(taskUrl);\n\t\t\t\treleasesP.push(this.writeCore(taskUrl, null));\n\t\t\t}\n\t\t\tawait Promise.all(releasesP);\n\t\t}\n\t}\n\n\tprivate async clearTasks(taskUrls: string[]) {\n\t\tassert(this.isActive(), 0x11b /* \"Trying to clear tasks on inactive agent\" */);\n\t\tconst clearP: Promise<void>[] = [];\n\t\tfor (const taskUrl of taskUrls) {\n\t\t\tclearP.push(this.writeCore(taskUrl, null));\n\t\t}\n\t\tawait Promise.all(clearP);\n\t}\n\n\tprivate getTaskClientId(url: string): string | null | undefined {\n\t\treturn this.consensusRegisterCollection.read(url);\n\t}\n\n\tprivate async writeCore(key: string, clientId: string | null): Promise<void> {\n\t\tawait this.consensusRegisterCollection.write(key, clientId);\n\t}\n\n\tprivate initialize() {\n\t\tconst quorum = this.runtime.getQuorum();\n\t\t// A client left the quorum. Iterate and clear tasks held by that client.\n\t\t// Ideally a leader should do this cleanup. But it's complicated when a leader itself leaves.\n\t\t// Probably okay for now to have every client try to do this.\n\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\tquorum.on(\"removeMember\", async (clientId: string) => {\n\t\t\tassert(\n\t\t\t\tthis.runtime.objectsRoutingContext.isAttached,\n\t\t\t\t0x11c /* \"Detached object routing context\" */,\n\t\t\t);\n\t\t\t// Cleanup only if connected. If not, cleanup will happen in initializeCore() that runs on connection.\n\t\t\tif (this.isActive()) {\n\t\t\t\tconst tasks: Promise<any>[] = [];\n\t\t\t\tconst leftTasks: string[] = [];\n\t\t\t\tfor (const taskUrl of this.consensusRegisterCollection.keys()) {\n\t\t\t\t\tif (this.getTaskClientId(taskUrl) === clientId) {\n\t\t\t\t\t\tif (this.locallyRunnableTasks.has(taskUrl)) {\n\t\t\t\t\t\t\ttasks.push(this.writeCore(taskUrl, this.clientId));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tleftTasks.push(taskUrl);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttasks.push(this.clearTasks(leftTasks));\n\t\t\t\tawait Promise.all(tasks).catch((error) => {\n\t\t\t\t\tthis.sendErrorEvent(\"AgentScheduler_RemoveMemberError\", error);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// Listeners for new/released tasks. All clients will try to grab at the same time.\n\t\t// May be we want a randomized timer (Something like raft) to reduce chattiness?\n\t\tthis.consensusRegisterCollection.on(\n\t\t\t\"atomicChanged\",\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-misused-promises\n\t\t\tasync (key: string, currentClient: string | null) => {\n\t\t\t\t// Check if this client was chosen.\n\t\t\t\tif (this.isActive() && currentClient === this.clientId) {\n\t\t\t\t\tthis.onNewTaskAssigned(key);\n\t\t\t\t} else {\n\t\t\t\t\t// The call below mutates the consensusRegisterCollection in\n\t\t\t\t\t// its event handler, which is not safe.\n\t\t\t\t\t// We need to force this to be part of a different batch of ops by\n\t\t\t\t\t// scheduling a microtask in order to work around the current validations.\n\t\t\t\t\t// This is not recommended and should be avoided.\n\t\t\t\t\tawait Promise.resolve().then(async () => {\n\t\t\t\t\t\tawait this.onTaskReassigned(key, currentClient);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (this.isActive()) {\n\t\t\tthis.initializeCore();\n\t\t}\n\n\t\tthis.runtime.on(\"connected\", () => {\n\t\t\tif (this.isActive()) {\n\t\t\t\tthis.initializeCore();\n\t\t\t}\n\t\t});\n\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\tthis.runtime\n\t\t\t\t.waitAttached()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.clearRunningTasks();\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.sendErrorEvent(\"AgentScheduler_clearRunningTasks\", error);\n\t\t\t\t});\n\t\t}\n\n\t\tthis.runtime.on(\"disconnected\", () => {\n\t\t\tif (this.runtime.attachState !== AttachState.Detached) {\n\t\t\t\tthis.clearRunningTasks();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate onNewTaskAssigned(key: string) {\n\t\tassert(!this.runningTasks.has(key), 0x11d /* \"task is already running\" */);\n\t\tthis.runningTasks.add(key);\n\t\tconst worker = this.locallyRunnableTasks.get(key);\n\t\tif (worker === undefined) {\n\t\t\tthis.sendErrorEvent(\"AgentScheduler_UnwantedChange\", undefined, key);\n\t\t} else {\n\t\t\tthis.emit(\"picked\", key);\n\t\t\tworker().catch((error) => {\n\t\t\t\tthis.sendErrorEvent(\"AgentScheduler_FailedWork\", error, key);\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async onTaskReassigned(key: string, currentClient: string | null) {\n\t\tif (this.runningTasks.has(key)) {\n\t\t\tthis.runningTasks.delete(key);\n\t\t\tthis.emit(\"released\", key);\n\t\t}\n\t\tassert(currentClient !== undefined, 0x11e /* \"client is undefined\" */);\n\t\tif (this.isActive()) {\n\t\t\t// attempt to pick up task if we are connected.\n\t\t\t// If not, initializeCore() will do it when connected\n\t\t\tif (currentClient === null) {\n\t\t\t\tif (this.locallyRunnableTasks.has(key)) {\n\t\t\t\t\tawait this.writeCore(key, this.clientId);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Check if the op came from dropped client\n\t\t\t// This could happen when \"old\" ops are submitted on reconnection.\n\t\t\t// They carry \"old\" ref seq number, but if write is not contested, it will get accepted\n\t\t\telse if (this.runtime.getQuorum().getMember(currentClient) === undefined) {\n\t\t\t\tawait this.writeCore(key, null);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isActive() {\n\t\t// Scheduler should be active in detached container.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Note: we are not checking for this.context.deltaManager.clientDetails.capabilities.interactive\n\t\t// here. Instead we assert in pick() if a non-interactive client tries to pick.\n\n\t\treturn this.context.deltaManager.active;\n\t}\n\n\tprivate initializeCore() {\n\t\t// Nobody released the tasks held by last client in previous session.\n\t\t// Check to see if this client needs to do this.\n\t\tconst clearCandidates: string[] = [];\n\t\tconst tasks: Promise<any>[] = [];\n\n\t\tfor (const [taskUrl] of this.locallyRunnableTasks) {\n\t\t\tif (!this.getTaskClientId(taskUrl)) {\n\t\t\t\ttasks.push(this.writeCore(taskUrl, this.clientId));\n\t\t\t}\n\t\t}\n\n\t\tfor (const taskUrl of this.consensusRegisterCollection.keys()) {\n\t\t\tconst currentClient = this.getTaskClientId(taskUrl);\n\t\t\tif (currentClient && this.runtime.getQuorum().getMember(currentClient) === undefined) {\n\t\t\t\tclearCandidates.push(taskUrl);\n\t\t\t}\n\t\t}\n\n\t\ttasks.push(this.clearTasks(clearCandidates));\n\n\t\tPromise.all(tasks).catch((error) => {\n\t\t\tthis.sendErrorEvent(\"AgentScheduler_InitError\", error);\n\t\t});\n\t}\n\n\tprivate clearRunningTasks() {\n\t\tconst tasks = this.runningTasks;\n\t\tthis.runningTasks = new Set<string>();\n\n\t\tif (this.isActive()) {\n\t\t\t// Clear all tasks with UnattachedClientId (if was unattached) and reapply for tasks with new clientId\n\t\t\t// If we are simply disconnected, then proper cleanup will be done on connection.\n\t\t\tthis.initializeCore();\n\t\t}\n\n\t\tfor (const task of tasks) {\n\t\t\tthis.emit(\"lost\", task);\n\t\t}\n\t}\n\n\tprivate sendErrorEvent(eventName: string, error: any, key?: string) {\n\t\tthis.runtime.logger.sendErrorEvent({ eventName, key }, error);\n\t}\n}\n\nclass AgentSchedulerRuntime extends FluidDataStoreRuntime {\n\tconstructor(\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tsharedObjectRegistry: ISharedObjectRegistry,\n\t\texisting: boolean,\n\t) {\n\t\tsuper(dataStoreContext, sharedObjectRegistry, existing, async () =>\n\t\t\tAgentScheduler.load(this, dataStoreContext, existing),\n\t\t);\n\t}\n\tpublic async request(request: IRequest) {\n\t\tconst response = await super.request(request);\n\t\tif (response.status === 404) {\n\t\t\tif (request.url === \"\" || request.url === \"/\") {\n\t\t\t\tconst agentScheduler = await this.entryPoint?.get();\n\t\t\t\tassert(\n\t\t\t\t\tagentScheduler !== undefined,\n\t\t\t\t\t0x466 /* entryPoint for AgentSchedulerRuntime should have been initialized by now */,\n\t\t\t\t);\n\n\t\t\t\treturn { status: 200, mimeType: \"fluid/object\", value: agentScheduler };\n\t\t\t}\n\t\t}\n\t\treturn response;\n\t}\n}\n\nexport class AgentSchedulerFactory implements IFluidDataStoreFactory {\n\tpublic static readonly type = \"_scheduler\";\n\tpublic readonly type = AgentSchedulerFactory.type;\n\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\tpublic static get registryEntry(): NamedFluidDataStoreRegistryEntry {\n\t\treturn [this.type, Promise.resolve(new AgentSchedulerFactory())];\n\t}\n\n\tpublic static async createChildInstance(\n\t\tparentContext: IFluidDataStoreContext,\n\t): Promise<AgentScheduler> {\n\t\tconst packagePath = [...parentContext.packagePath, AgentSchedulerFactory.type];\n\t\tconst dataStore = await parentContext.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint: FluidObject<IAgentScheduler> | undefined =\n\t\t\tawait dataStore.entryPoint?.get();\n\n\t\t// AgentSchedulerRuntime always puts an AgentScheduler object in the data store's entryPoint, but double-check\n\t\t// while we plumb entryPoints correctly everywhere, so we can be sure the cast below is fine.\n\t\tassert(\n\t\t\tentryPoint?.IAgentScheduler !== undefined,\n\t\t\t0x467 /* The data store's entryPoint is not an AgentScheduler! */,\n\t\t);\n\t\treturn entryPoint as unknown as AgentScheduler;\n\t}\n\n\tpublic async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n\t\tconst mapFactory = SharedMap.getFactory();\n\t\tconst consensusRegisterCollectionFactory = ConsensusRegisterCollection.getFactory();\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\t\tdataTypes.set(mapFactory.type, mapFactory);\n\t\tdataTypes.set(consensusRegisterCollectionFactory.type, consensusRegisterCollectionFactory);\n\n\t\treturn new AgentSchedulerRuntime(context, dataTypes, existing);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"taskSubscription.d.ts","sourceRoot":"","sources":["../src/taskSubscription.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,uBAAwB,SAAQ,MAAM;IACnD,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CACzD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,uBAAuB,CAAC;IAOhE,OAAO,CAAC,QAAQ,CAAC,cAAc;aAAmC,MAAM,EAAE,MAAM;IAN5F,OAAO,CAAC,UAAU,CAAkB;IAEpC;;;OAGG;gBAC0B,cAAc,EAAE,eAAe,EAAkB,MAAM,EAAE,MAAM;IAmB5F;;;OAGG;IACI,QAAQ;IAIf;;;OAGG;IACI,SAAS;CAUnB"}
1
+ {"version":3,"file":"taskSubscription.d.ts","sourceRoot":"","sources":["../src/taskSubscription.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,uBAAwB,SAAQ,MAAM;IACtD,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CACtD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,uBAAuB,CAAC;IAOnE,OAAO,CAAC,QAAQ,CAAC,cAAc;aAAmC,MAAM,EAAE,MAAM;IAN5F,OAAO,CAAC,UAAU,CAAkB;IAEpC;;;OAGG;gBAC0B,cAAc,EAAE,eAAe,EAAkB,MAAM,EAAE,MAAM;IAmB5F;;;OAGG;IACI,QAAQ;IAIf;;;OAGG;IACI,SAAS;CAUhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"taskSubscription.js","sourceRoot":"","sources":["../src/taskSubscription.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOjE;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAA0C;IAG5E;;;OAGG;IACH,YAA6B,cAA+B,EAAkB,MAAc;QACxF,KAAK,EAAE,CAAC;QADiB,mBAAc,GAAd,cAAc,CAAiB;QAAkB,WAAM,GAAN,MAAM,CAAQ;QANpF,eAAU,GAAY,KAAK,CAAC;QAQhC,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAe,EAAE,EAAE;YAC5C,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE;gBACzB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACxB;QACL,CAAC,CAAC,CAAC;QACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,OAAe,EAAE,EAAE;YAC9C,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE;gBACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACzB;QACL,CAAC,CAAC,CAAC;QACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAe,EAAE,EAAE;YAC1C,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE;gBACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACzB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,uFAAuF;YACvF,gFAAgF;YAChF,0FAA0F;YAC1F,qCAAqC;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YACxE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;SAC1B;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IAgentScheduler } from \"./agent\";\n\nexport interface ITaskSubscriptionEvents extends IEvent {\n (event: \"gotTask\" | \"lostTask\", listener: () => void);\n}\n\n/**\n * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.\n */\nexport class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {\n private subscribed: boolean = false;\n\n /**\n * @param agentScheduler - The AgentScheduler that will be subscribed against\n * @param taskId - The string ID of the task to subscribe against\n */\n constructor(private readonly agentScheduler: IAgentScheduler, public readonly taskId: string) {\n super();\n agentScheduler.on(\"picked\", (_taskId: string) => {\n if (_taskId === this.taskId) {\n this.emit(\"gotTask\");\n }\n });\n agentScheduler.on(\"released\", (_taskId: string) => {\n if (_taskId === this.taskId) {\n this.emit(\"lostTask\");\n }\n });\n agentScheduler.on(\"lost\", (_taskId: string) => {\n if (_taskId === this.taskId) {\n this.emit(\"lostTask\");\n }\n });\n }\n\n /**\n * Check if currently holding ownership of the task.\n * @returns true if currently the task owner, false otherwise.\n */\n public haveTask() {\n return this.agentScheduler.pickedTasks().includes(this.taskId);\n }\n\n /**\n * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.\n * This is safe to call multiple times across multiple TaskSubscriptions.\n */\n public volunteer() {\n if (!this.subscribed) {\n // AgentScheduler throws if the same task is picked twice but we don't care because our\n // worker does nothing. We only care that the AgentScheduler is trying to pick.\n // We also don't care if we throw due to failing the interactive check, because then we'll\n // just appear to never get the task.\n this.agentScheduler.pick(this.taskId, async () => { }).catch(() => { });\n this.subscribed = true;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"taskSubscription.js","sourceRoot":"","sources":["../src/taskSubscription.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOjE;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAA0C;IAG/E;;;OAGG;IACH,YAA6B,cAA+B,EAAkB,MAAc;QAC3F,KAAK,EAAE,CAAC;QADoB,mBAAc,GAAd,cAAc,CAAiB;QAAkB,WAAM,GAAN,MAAM,CAAQ;QANpF,eAAU,GAAY,KAAK,CAAC;QAQnC,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAe,EAAE,EAAE;YAC/C,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE;gBAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACrB;QACF,CAAC,CAAC,CAAC;QACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,OAAe,EAAE,EAAE;YACjD,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE;gBAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACtB;QACF,CAAC,CAAC,CAAC;QACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAe,EAAE,EAAE;YAC7C,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE;gBAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACtB;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,QAAQ;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,uFAAuF;YACvF,gFAAgF;YAChF,0FAA0F;YAC1F,qCAAqC;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACtE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;SACvB;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IAgentScheduler } from \"./agent\";\n\nexport interface ITaskSubscriptionEvents extends IEvent {\n\t(event: \"gotTask\" | \"lostTask\", listener: () => void);\n}\n\n/**\n * TaskSubscription works with an AgentScheduler to make it easier to monitor a specific task ownership.\n */\nexport class TaskSubscription extends TypedEventEmitter<ITaskSubscriptionEvents> {\n\tprivate subscribed: boolean = false;\n\n\t/**\n\t * @param agentScheduler - The AgentScheduler that will be subscribed against\n\t * @param taskId - The string ID of the task to subscribe against\n\t */\n\tconstructor(private readonly agentScheduler: IAgentScheduler, public readonly taskId: string) {\n\t\tsuper();\n\t\tagentScheduler.on(\"picked\", (_taskId: string) => {\n\t\t\tif (_taskId === this.taskId) {\n\t\t\t\tthis.emit(\"gotTask\");\n\t\t\t}\n\t\t});\n\t\tagentScheduler.on(\"released\", (_taskId: string) => {\n\t\t\tif (_taskId === this.taskId) {\n\t\t\t\tthis.emit(\"lostTask\");\n\t\t\t}\n\t\t});\n\t\tagentScheduler.on(\"lost\", (_taskId: string) => {\n\t\t\tif (_taskId === this.taskId) {\n\t\t\t\tthis.emit(\"lostTask\");\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if currently holding ownership of the task.\n\t * @returns true if currently the task owner, false otherwise.\n\t */\n\tpublic haveTask() {\n\t\treturn this.agentScheduler.pickedTasks().includes(this.taskId);\n\t}\n\n\t/**\n\t * Volunteer for the task. By default, the TaskSubscription will only watch the task and not volunteer.\n\t * This is safe to call multiple times across multiple TaskSubscriptions.\n\t */\n\tpublic volunteer() {\n\t\tif (!this.subscribed) {\n\t\t\t// AgentScheduler throws if the same task is picked twice but we don't care because our\n\t\t\t// worker does nothing. We only care that the AgentScheduler is trying to pick.\n\t\t\t// We also don't care if we throw due to failing the interactive check, because then we'll\n\t\t\t// just appear to never get the task.\n\t\t\tthis.agentScheduler.pick(this.taskId, async () => {}).catch(() => {});\n\t\t\tthis.subscribed = true;\n\t\t}\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,102 +1,105 @@
1
1
  {
2
- "name": "@fluidframework/agent-scheduler",
3
- "version": "2.0.0-internal.3.0.1",
4
- "description": "Built in runtime object for distributing agents across instances of a container",
5
- "homepage": "https://fluidframework.com",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/microsoft/FluidFramework.git",
9
- "directory": "packages/runtime/agent-scheduler"
10
- },
11
- "license": "MIT",
12
- "author": "Microsoft and contributors",
13
- "sideEffects": false,
14
- "main": "dist/index.js",
15
- "module": "lib/index.js",
16
- "types": "dist/index.d.ts",
17
- "scripts": {
18
- "build": "concurrently npm:build:compile npm:lint",
19
- "build:compile": "npm run tsc && npm run typetests:gen && npm run build:test && npm run build:esnext",
20
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
21
- "build:full": "npm run build",
22
- "build:full:compile": "npm run build:compile",
23
- "build:test": "tsc --project ./src/test/tsconfig.json",
24
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
25
- "dev": "npm run build:dev -- --watch",
26
- "eslint": "eslint --format stylish src",
27
- "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
28
- "format": "npm run prettier:fix",
29
- "lint": "npm run eslint",
30
- "lint:fix": "npm run eslint:fix",
31
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
32
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
33
- "tsc": "tsc",
34
- "typetests:gen": "flub generate typetests --generate --dir .",
35
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
36
- },
37
- "nyc": {
38
- "all": true,
39
- "cache-dir": "nyc/.cache",
40
- "exclude": [
41
- "src/test/**/*.ts",
42
- "dist/test/**/*.js"
43
- ],
44
- "include": [
45
- "src/**/*.ts",
46
- "dist/**/*.js"
47
- ],
48
- "report-dir": "nyc/report",
49
- "reporter": [
50
- "cobertura",
51
- "html",
52
- "text"
53
- ],
54
- "temp-directory": "nyc/.nyc_output"
55
- },
56
- "dependencies": {
57
- "@fluidframework/common-definitions": "^0.20.1",
58
- "@fluidframework/common-utils": "^1.0.0",
59
- "@fluidframework/container-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
60
- "@fluidframework/core-interfaces": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
61
- "@fluidframework/datastore": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
62
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
63
- "@fluidframework/map": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
64
- "@fluidframework/register-collection": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
65
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
66
- "@fluidframework/runtime-utils": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
67
- "uuid": "^8.3.1"
68
- },
69
- "devDependencies": {
70
- "@fluid-tools/build-cli": "^0.8.0",
71
- "@fluidframework/agent-scheduler-previous": "npm:@fluidframework/agent-scheduler@2.0.0-internal.2.1.1",
72
- "@fluidframework/build-common": "^1.1.0",
73
- "@fluidframework/build-tools": "^0.8.0",
74
- "@fluidframework/eslint-config-fluid": "^2.0.0",
75
- "@rushstack/eslint-config": "^2.5.1",
76
- "@types/mocha": "^9.1.1",
77
- "@types/node": "^14.18.36",
78
- "concurrently": "^6.2.0",
79
- "eslint": "~8.6.0",
80
- "mocha": "^10.0.0",
81
- "nyc": "^15.0.0",
82
- "prettier": "~2.6.2",
83
- "rimraf": "^2.6.2",
84
- "typescript": "~4.5.5"
85
- },
86
- "fluid": {
87
- "browser": {
88
- "umd": {
89
- "files": [
90
- "dist/main.bundle.js"
91
- ],
92
- "library": "main"
93
- }
94
- }
95
- },
96
- "typeValidation": {
97
- "version": "2.0.0-internal.3.0.0",
98
- "baselineRange": ">=2.0.0-internal.2.0.0 <2.0.0-internal.3.0.0",
99
- "baselineVersion": "2.0.0-internal.2.1.1",
100
- "broken": {}
101
- }
2
+ "name": "@fluidframework/agent-scheduler",
3
+ "version": "2.0.0-internal.3.1.0",
4
+ "description": "Built in runtime object for distributing agents across instances of a container",
5
+ "homepage": "https://fluidframework.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/microsoft/FluidFramework.git",
9
+ "directory": "packages/runtime/agent-scheduler"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Microsoft and contributors",
13
+ "sideEffects": false,
14
+ "main": "dist/index.js",
15
+ "module": "lib/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "scripts": {
18
+ "build": "concurrently npm:build:compile npm:lint",
19
+ "build:compile": "npm run tsc && npm run typetests:gen && npm run build:test && npm run build:esnext",
20
+ "build:esnext": "tsc --project ./tsconfig.esnext.json",
21
+ "build:full": "npm run build",
22
+ "build:full:compile": "npm run build:compile",
23
+ "build:test": "tsc --project ./src/test/tsconfig.json",
24
+ "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
25
+ "dev": "npm run build:dev -- --watch",
26
+ "eslint": "eslint --format stylish src",
27
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
28
+ "format": "npm run prettier:fix",
29
+ "lint": "npm run prettier && npm run eslint",
30
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
31
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
32
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
33
+ "tsc": "tsc",
34
+ "typetests:gen": "flub generate typetests --generate --dir .",
35
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
36
+ },
37
+ "nyc": {
38
+ "all": true,
39
+ "cache-dir": "nyc/.cache",
40
+ "exclude": [
41
+ "src/test/**/*.ts",
42
+ "dist/test/**/*.js"
43
+ ],
44
+ "include": [
45
+ "src/**/*.ts",
46
+ "dist/**/*.js"
47
+ ],
48
+ "report-dir": "nyc/report",
49
+ "reporter": [
50
+ "cobertura",
51
+ "html",
52
+ "text"
53
+ ],
54
+ "temp-directory": "nyc/.nyc_output"
55
+ },
56
+ "dependencies": {
57
+ "@fluidframework/common-definitions": "^0.20.1",
58
+ "@fluidframework/common-utils": "^1.0.0",
59
+ "@fluidframework/container-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
60
+ "@fluidframework/container-utils": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
61
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
62
+ "@fluidframework/datastore": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
63
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
64
+ "@fluidframework/map": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
65
+ "@fluidframework/register-collection": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
66
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
67
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
68
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
69
+ "uuid": "^8.3.1"
70
+ },
71
+ "devDependencies": {
72
+ "@fluid-tools/build-cli": "^0.9.0",
73
+ "@fluidframework/agent-scheduler-previous": "npm:@fluidframework/agent-scheduler@2.0.0-internal.3.0.0",
74
+ "@fluidframework/build-common": "^1.1.0",
75
+ "@fluidframework/build-tools": "^0.9.0",
76
+ "@fluidframework/eslint-config-fluid": "^2.0.0",
77
+ "@rushstack/eslint-config": "^2.5.1",
78
+ "@types/mocha": "^9.1.1",
79
+ "@types/node": "^14.18.36",
80
+ "concurrently": "^6.2.0",
81
+ "eslint": "~8.6.0",
82
+ "mocha": "^10.0.0",
83
+ "nyc": "^15.0.0",
84
+ "prettier": "~2.6.2",
85
+ "rimraf": "^2.6.2",
86
+ "typescript": "~4.5.5"
87
+ },
88
+ "fluid": {
89
+ "browser": {
90
+ "umd": {
91
+ "files": [
92
+ "dist/main.bundle.js"
93
+ ],
94
+ "library": "main"
95
+ }
96
+ }
97
+ },
98
+ "typeValidation": {
99
+ "version": "2.0.0-internal.3.1.0",
100
+ "previousVersionStyle": "~previousMinor",
101
+ "baselineRange": ">=2.0.0-internal.3.0.0 <2.0.0-internal.3.1.0",
102
+ "baselineVersion": "2.0.0-internal.3.0.0",
103
+ "broken": {}
104
+ }
102
105
  }
@@ -4,5 +4,5 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- ...require("@fluidframework/build-common/prettier.config.cjs"),
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
8
  };
package/src/agent.ts CHANGED
@@ -9,63 +9,66 @@ import { IFluidLoadable } from "@fluidframework/core-interfaces";
9
9
  export const IAgentScheduler: keyof IProvideAgentScheduler = "IAgentScheduler";
10
10
 
11
11
  export interface IProvideAgentScheduler {
12
- readonly IAgentScheduler: IAgentScheduler;
12
+ readonly IAgentScheduler: IAgentScheduler;
13
13
  }
14
14
 
15
15
  export interface IAgentSchedulerEvents extends IEvent {
16
- /**
17
- * Event when ownership of task changes
18
- * @param event - name of the event:
19
- *
20
- * - "picked" - the task has been assigned to this client, in response to pick() being called
21
- * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
22
- * automatically, unless release() is called
23
- *
24
- * - "released" - the task was successfully released back to the pool. Client will not attempt to
25
- * re-acquire the task, unless pick() is called.
26
- *
27
- * - "lost" - task is lost due to disconnect or data store / container being attached.
28
- * Task will be picked up again by some connected client (this client will try as well,
29
- * unless release() is called)
30
- *
31
- * @param listener - callback notified when change happened for particular key
32
- */
33
- (event: "picked" | "released" | "lost", listener: (taskId: string) => void);
16
+ /**
17
+ * Event when ownership of task changes
18
+ * @param event - name of the event:
19
+ *
20
+ * - "picked" - the task has been assigned to this client, in response to pick() being called
21
+ * If client loses this task (due to disconnect), it will attempt to pick it again (on connection)
22
+ * automatically, unless release() is called
23
+ *
24
+ * - "released" - the task was successfully released back to the pool. Client will not attempt to
25
+ * re-acquire the task, unless pick() is called.
26
+ *
27
+ * - "lost" - task is lost due to disconnect or data store / container being attached.
28
+ * Task will be picked up again by some connected client (this client will try as well,
29
+ * unless release() is called)
30
+ *
31
+ * @param listener - callback notified when change happened for particular key
32
+ */
33
+ (event: "picked" | "released" | "lost", listener: (taskId: string) => void);
34
34
  }
35
35
 
36
36
  /**
37
37
  * Agent scheduler distributes a set of tasks/variables across connected clients.
38
38
  */
39
- export interface IAgentScheduler extends IProvideAgentScheduler, IEventProvider<IAgentSchedulerEvents>, IFluidLoadable {
40
- /**
41
- * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
42
- * a new agent to run but does not have the capability to run the agent inside the host.
43
- * Client can call pick() later if the capability changes.
44
- *
45
- * This method should only be called once per task. Duplicate calls will be rejected.
46
- */
47
- register(...taskUrls: string[]): Promise<void>;
39
+ export interface IAgentScheduler
40
+ extends IProvideAgentScheduler,
41
+ IEventProvider<IAgentSchedulerEvents>,
42
+ IFluidLoadable {
43
+ /**
44
+ * Registers a set of new tasks to distribute amongst connected clients. Only use this if a client wants
45
+ * a new agent to run but does not have the capability to run the agent inside the host.
46
+ * Client can call pick() later if the capability changes.
47
+ *
48
+ * This method should only be called once per task. Duplicate calls will be rejected.
49
+ */
50
+ register(...taskUrls: string[]): Promise<void>;
48
51
 
49
- /**
50
- * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
51
- * Resolves when the tasks are assigned to one of the connected clients.
52
- *
53
- * This method should only be called once per task. Duplicate calls will be rejected.
54
- *
55
- * @param worker - callback to run when task is picked up.
56
- */
57
- pick(taskId: string, worker: () => Promise<void>): Promise<void>;
52
+ /**
53
+ * Attempts to pick a set of tasks. A client will only run the task if it's chosen based on consensus.
54
+ * Resolves when the tasks are assigned to one of the connected clients.
55
+ *
56
+ * This method should only be called once per task. Duplicate calls will be rejected.
57
+ *
58
+ * @param worker - callback to run when task is picked up.
59
+ */
60
+ pick(taskId: string, worker: () => Promise<void>): Promise<void>;
58
61
 
59
- /**
60
- * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
61
- *
62
- * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
63
- * App can call pickedTasks() to get the picked list first.
64
- */
65
- release(...taskUrls: string[]): Promise<void>;
62
+ /**
63
+ * Releases a set of tasks for other clients to grab. Resolves when the tasks are released.
64
+ *
65
+ * Only previously picked tasks are allowed. Releasing non picked tasks will get a rejection.
66
+ * App can call pickedTasks() to get the picked list first.
67
+ */
68
+ release(...taskUrls: string[]): Promise<void>;
66
69
 
67
- /**
68
- * Returns a list of all tasks running on this client
69
- */
70
- pickedTasks(): string[];
70
+ /**
71
+ * Returns a list of all tasks running on this client
72
+ */
73
+ pickedTasks(): string[];
71
74
  }