@fluidframework/task-manager 2.0.0-internal.2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +14 -0
- package/.mocharc.js +12 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/api-extractor.json +4 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +65 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +7 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/packageVersion.d.ts +9 -0
- package/dist/packageVersion.d.ts.map +1 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/taskManager.d.ts +242 -0
- package/dist/taskManager.d.ts.map +1 -0
- package/dist/taskManager.js +715 -0
- package/dist/taskManager.js.map +1 -0
- package/dist/taskManagerFactory.d.ts +21 -0
- package/dist/taskManagerFactory.d.ts.map +1 -0
- package/dist/taskManagerFactory.js +41 -0
- package/dist/taskManagerFactory.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces.d.ts +65 -0
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +6 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/lib/taskManager.d.ts +242 -0
- package/lib/taskManager.d.ts.map +1 -0
- package/lib/taskManager.js +711 -0
- package/lib/taskManager.js.map +1 -0
- package/lib/taskManagerFactory.d.ts +21 -0
- package/lib/taskManagerFactory.d.ts.map +1 -0
- package/lib/taskManagerFactory.js +37 -0
- package/lib/taskManagerFactory.js.map +1 -0
- package/package.json +116 -0
- package/prettier.config.cjs +8 -0
- package/src/index.ts +7 -0
- package/src/interfaces.ts +74 -0
- package/src/packageVersion.ts +9 -0
- package/src/taskManager.ts +832 -0
- package/src/taskManagerFactory.ts +54 -0
- package/tsconfig.esnext.json +7 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskManager.js","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAsC;AAEtC,+DAAsD;AACtD,+EAA8F;AAQ9F,+DAA4D;AAC5D,2EAA6G;AAE7G,6DAA0D;AA+B1D,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,MAAa,WAAY,SAAQ,iCAAgC;IAoE7D;;;;;;OAMG;IACH,YAAY,EAAU,EAAE,OAA+B,EAAE,UAA8B;QACnF,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAvDzD;;;WAGG;QACc,eAAU,GAA0B,IAAI,GAAG,EAAE,CAAC;QAE/D,2GAA2G;QAC1F,cAAS,GAAiB,IAAI,qBAAY,EAAE,CAAC;QAC9D,sFAAsF;QACrE,iBAAY,GAAiB,IAAI,qBAAY,EAAE,CAAC;QACjE,qFAAqF;QACpE,mBAAc,GAAiB,IAAI,qBAAY,EAAE,CAAC;QACnE,8EAA8E;QAC7D,sBAAiB,GAAiB,IAAI,qBAAY,EAAE,CAAC;QACtE,qFAAqF;QACpE,qBAAgB,GAAiB,IAAI,qBAAY,EAAE,CAAC;QAE7D,cAAS,GAAW,CAAC,CAAC,CAAC;QAC/B;;WAEG;QACc,qBAAgB,GAA4B,IAAI,GAAG,EAAE,CAAC;QAEvE;;W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,CAAC,KAAK,SAAS,CAAC,CAAC;YACvG,IAAI,WAAW,CAAC,MAAM,KAAK,mBAAmB,CAAC,MAAM,EAAE;gBACnD,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE;oBAClC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;iBAClC;qBAAM;oBACH,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;iBACpD;gBACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;aACjD;SACJ;IACL,CAAC;IAEM,cAAc;QACjB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AA3qBD,kCA2qBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelStorageService,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { createSingleBlobSummary, IFluidSerializer, SharedObject } from \"@fluidframework/shared-object-base\";\nimport { ReadOnlyInfo } from \"@fluidframework/container-definitions\";\nimport { TaskManagerFactory } from \"./taskManagerFactory\";\nimport { ITaskManager, ITaskManagerEvents } from \"./interfaces\";\n\n/**\n * Description of a task manager operation\n */\ntype ITaskManagerOperation =\n ITaskManagerVolunteerOperation |\n ITaskManagerAbandonOperation |\n ITaskManagerCompletedOperation;\n\ninterface ITaskManagerVolunteerOperation {\n type: \"volunteer\";\n taskId: string;\n}\n\ninterface ITaskManagerAbandonOperation {\n type: \"abandon\";\n taskId: string;\n}\n\ninterface ITaskManagerCompletedOperation {\n type: \"complete\";\n taskId: string;\n}\n\ninterface IPendingOp {\n type: \"volunteer\" | \"abandon\" | \"complete\";\n messageId: number;\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * Placeholder clientId for detached scenarios.\n */\nconst placeholderClientId = \"placeholder\";\n\n\n/**\n * The TaskManager distributed data structure tracks queues of clients that want to exclusively run a task.\n *\n * @remarks\n *\n * For an in-depth overview, see [TaskManager](https://fluidframework.com/docs/data-structures/task-manager/).\n *\n * ### Creation\n *\n * To create a `TaskManager`, call the static create method:\n *\n * ```typescript\n * const taskManager = TaskManager.create(this.runtime, id);\n * ```\n *\n * ### Usage\n *\n * To volunteer for a task, use the `volunteerForTask()` method. This returns a Promise that will resolve once the\n * client has acquired exclusive rights to run the task, or reject if the client is removed from the queue without\n * acquiring the rights.\n *\n * ```typescript\n * taskManager.volunteerForTask(\"NameOfTask\")\n * .then(() => { doTheTask(); })\n * .catch((err) => { console.error(err); });\n * ```\n *\n * Alternatively, you can indefinitely volunteer for a task with the synchronous `subscribeToTask()` method. This\n * method does not return a value, therefore you need to rely on eventing to know when you have acquired the rights\n * to run the task (see below).\n *\n * ```typescript\n * taskManager.subscribeToTask(\"NameOfTask\");\n * ```\n *\n * To check if the local client is currently subscribed to a task, use the `subscribed()` method.\n * ```typescript\n * if (taskManager.subscribed(\"NameOfTask\")) {\n * console.log(\"This client is currently subscribed to the task.\");\n * }\n * ```\n *\n * To release the rights to the task, use the `abandon()` method. The next client in the queue will then get the\n * rights to run the task.\n *\n * ```typescript\n * taskManager.abandon(\"NameOfTask\");\n * ```\n *\n * To inspect your state in the queue, you can use the `queued()` and `assigned()` methods.\n *\n * ```typescript\n * if (taskManager.queued(\"NameOfTask\")) {\n * console.log(\"This client is somewhere in the queue, potentially even having the task assignment.\");\n * }\n *\n * if (taskManager.assigned(\"NameOfTask\")) {\n * console.log(\"This client currently has the rights to run the task\");\n * }\n * ```\n *\n * To signal to other connected clients that a task is completed, use the `complete()` method. This will release all\n * clients from the queue and emit the \"completed\" event.\n *\n * ```typescript\n * taskManager.complete(\"NameOfTask\");\n * ```\n *\n * ### Eventing\n *\n * `TaskManager` is an `EventEmitter`, and will emit events when a task is assigned to the client, when the task\n * assignment is lost, and when a task was completed by another client.\n *\n * ```typescript\n * taskManager.on(\"assigned\", (taskId: string) => {\n * console.log(`Client was assigned task: ${taskId}`);\n * });\n *\n * taskManager.on(\"lost\", (taskId: string) => {\n * console.log(`Client released task: ${taskId}`);\n * });\n *\n * taskManager.on(\"completed\", (taskId: string) => {\n * console.log(`Another client completed task: ${taskId}`);\n * });\n * ```\n *\n * These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as\n * when using the `subscribeToTask()` method.\n */\nexport class TaskManager extends SharedObject<ITaskManagerEvents> implements ITaskManager {\n /**\n * Create a new TaskManager\n *\n * @param runtime - data store runtime the new task queue belongs to\n * @param id - optional name of the task queue\n * @returns newly create task queue (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, TaskManagerFactory.Type) as TaskManager;\n }\n\n /**\n * Get a factory for TaskManager to register with the data store.\n *\n * @returns a factory that creates and load TaskManager\n */\n public static getFactory(): IChannelFactory {\n return new TaskManagerFactory();\n }\n\n /**\n * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the\n * queue, even if we know we've submitted an op that should eventually modify the queue.\n */\n private readonly taskQueues: Map<string, string[]> = new Map();\n\n // opWatcher emits for every op on this data store. This is just a repackaging of processCore into events.\n private readonly opWatcher: EventEmitter = new EventEmitter();\n // queueWatcher emits an event whenever the consensus state of the task queues changes\n private readonly queueWatcher: EventEmitter = new EventEmitter();\n // abandonWatcher emits an event whenever the local client calls abandon() on a task.\n private readonly abandonWatcher: EventEmitter = new EventEmitter();\n // connectionWatcher emits an event whenever we get connected or disconnected.\n private readonly connectionWatcher: EventEmitter = new EventEmitter();\n // completedWatcher emits an event whenever the local client receives a completed op.\n private readonly completedWatcher: EventEmitter = new EventEmitter();\n\n private messageId: number = -1;\n /**\n * Tracks the most recent pending op for a given task\n */\n private readonly latestPendingOps: Map<string, IPendingOp> = new Map();\n\n /**\n * Tracks tasks that are this client is currently subscribed to.\n */\n private readonly subscribedTasks: Set<string> = new Set();\n\n /**\n * Map to track tasks that have pending complete ops.\n */\n private readonly pendingCompletedTasks: Map<string, number[]> = new Map();\n\n /**\n * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.\n */\n private get clientId(): string | undefined {\n return this.isAttached() ? this.runtime.clientId : placeholderClientId;\n }\n\n /**\n * Returns a ReadOnlyInfo object to determine current read/write permissions.\n */\n private get readOnlyInfo(): ReadOnlyInfo {\n return this.runtime.deltaManager.readOnlyInfo;\n }\n\n /**\n * Constructs a new task manager. If the object is non-local an id and service interfaces will\n * be provided\n *\n * @param runtime - data store runtime the task queue belongs to\n * @param id - optional name of the task queue\n */\n constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {\n super(id, runtime, attributes, \"fluid_taskManager_\");\n\n this.opWatcher.on(\"volunteer\", (taskId: string, clientId: string, local: boolean, messageId: number) => {\n // We're tracking local ops from this connection. Filter out local ops during \"connecting\"\n // state since these were sent on the prior connection and were already cleared from the latestPendingOps.\n if (runtime.connected && local) {\n const pendingOp = this.latestPendingOps.get(taskId);\n assert(pendingOp !== undefined, 0x07b /* \"Unexpected op\" */);\n // Need to check the id, since it's possible to volunteer and abandon multiple times before the acks\n if (messageId === pendingOp.messageId) {\n assert(pendingOp.type === \"volunteer\", 0x07c /* \"Unexpected op type\" */);\n // Delete the pending, because we no longer have an outstanding op\n this.latestPendingOps.delete(taskId);\n }\n }\n\n this.addClientToQueue(taskId, clientId);\n });\n\n this.opWatcher.on(\"abandon\", (taskId: string, clientId: string, local: boolean, messageId: number) => {\n if (runtime.connected && local) {\n const pendingOp = this.latestPendingOps.get(taskId);\n assert(pendingOp !== undefined, 0x07d /* \"Unexpected op\" */);\n // Need to check the id, since it's possible to abandon and volunteer multiple times before the acks\n if (messageId === pendingOp.messageId) {\n assert(pendingOp.type === \"abandon\", 0x07e /* \"Unexpected op type\" */);\n // Delete the pending, because we no longer have an outstanding op\n this.latestPendingOps.delete(taskId);\n }\n }\n\n this.removeClientFromQueue(taskId, clientId);\n });\n\n this.opWatcher.on(\"complete\", (taskId: string, clientId: string, local: boolean, messageId: number) => {\n if (runtime.connected && local) {\n const pendingOp = this.latestPendingOps.get(taskId);\n assert(pendingOp !== undefined, 0x400 /* Unexpected op */);\n // Need to check the id, since it's possible to complete multiple times before the acks\n if (messageId === pendingOp.messageId) {\n assert(pendingOp.type === \"complete\", 0x401 /* Unexpected op type */);\n // Delete the pending, because we no longer have an outstanding op\n this.latestPendingOps.delete(taskId);\n }\n\n // Remove complete op from this.pendingCompletedTasks\n const pendingIds = this.pendingCompletedTasks.get(taskId);\n assert(pendingIds !== undefined && pendingIds.length > 0, 0x402 /* pendingIds is empty */);\n const removed = pendingIds.shift();\n assert(removed === messageId, 0x403 /* Removed complete op id does not match */);\n }\n\n // For clients in queue, we need to remove them from the queue and raise the proper events.\n if (!local) {\n this.taskQueues.delete(taskId);\n this.completedWatcher.emit(\"completed\", taskId);\n this.emit(\"completed\", taskId);\n }\n });\n\n runtime.getQuorum().on(\"removeMember\", (clientId: string) => {\n this.removeClientFromAllQueues(clientId);\n });\n\n this.queueWatcher.on(\"queueChange\", (taskId: string, oldLockHolder: string, newLockHolder: string) => {\n // If oldLockHolder is placeholderClientId we need to emit the task was lost during the attach process\n if (oldLockHolder === placeholderClientId) {\n this.emit(\"lost\", taskId);\n return;\n }\n\n // Exit early if we are still catching up on reconnect -- we can't be the leader yet anyway.\n if (this.clientId === undefined) {\n return;\n }\n\n if (oldLockHolder !== this.clientId && newLockHolder === this.clientId) {\n this.emit(\"assigned\", taskId);\n } else if (oldLockHolder === this.clientId && newLockHolder !== this.clientId) {\n this.emit(\"lost\", taskId);\n }\n });\n\n this.connectionWatcher.on(\"disconnect\", () => {\n assert(this.clientId !== undefined, 0x1d3 /* \"Missing client id on disconnect\" */);\n\n // We don't modify the taskQueues on disconnect (they still reflect the latest known consensus state).\n // After reconnect these will get cleaned up by observing the clientLeaves.\n // However we do need to recognize that we lost the lock if we had it. Calls to .queued() and\n // .assigned() are also connection-state-aware to be consistent.\n for (const [taskId, clientQueue] of this.taskQueues.entries()) {\n if (this.isAttached() && clientQueue[0] === this.clientId) {\n this.emit(\"lost\", taskId);\n }\n }\n\n // All of our outstanding ops will be for the old clientId even if they get ack'd\n this.latestPendingOps.clear();\n });\n }\n\n private submitVolunteerOp(taskId: string) {\n const op: ITaskManagerVolunteerOperation = {\n type: \"volunteer\",\n taskId,\n };\n const pendingOp: IPendingOp = {\n type: \"volunteer\",\n messageId: ++this.messageId,\n };\n this.submitLocalMessage(op, pendingOp.messageId);\n this.latestPendingOps.set(taskId, pendingOp);\n }\n\n private submitAbandonOp(taskId: string) {\n const op: ITaskManagerAbandonOperation = {\n type: \"abandon\",\n taskId,\n };\n const pendingOp: IPendingOp = {\n type: \"abandon\",\n messageId: ++this.messageId,\n };\n this.submitLocalMessage(op, pendingOp.messageId);\n this.latestPendingOps.set(taskId, pendingOp);\n }\n\n private submitCompleteOp(taskId: string) {\n const op: ITaskManagerCompletedOperation = {\n type: \"complete\",\n taskId,\n };\n const pendingOp: IPendingOp = {\n type: \"complete\",\n messageId: ++this.messageId,\n };\n\n if (this.pendingCompletedTasks.has(taskId)) {\n this.pendingCompletedTasks.get(taskId)?.push(pendingOp.messageId);\n } else {\n this.pendingCompletedTasks.set(taskId, [pendingOp.messageId]);\n }\n\n this.submitLocalMessage(op, pendingOp.messageId);\n this.latestPendingOps.set(taskId, pendingOp);\n }\n\n /**\n * {@inheritDoc ITaskManager.volunteerForTask}\n */\n public async volunteerForTask(taskId: string) {\n // If we have the lock, resolve immediately\n if (this.assigned(taskId)) {\n return true;\n }\n\n if (this.readOnlyInfo.readonly === true) {\n const error = this.readOnlyInfo.permissions === true ?\n new Error(`Attempted to volunteer with read-only permissions: ${taskId}`) :\n new Error(`Attempted to volunteer in read-only state: ${taskId}`);\n throw error;\n }\n\n if (!this.isAttached()) {\n // Simulate auto-ack in detached scenario\n assert(this.clientId !== undefined, 0x472 /* clientId should not be undefined */);\n this.addClientToQueue(taskId, this.clientId);\n return true;\n }\n\n if (!this.connected) {\n throw new Error(`Attempted to volunteer in disconnected state: ${taskId}`);\n }\n\n // This promise works even if we already have an outstanding volunteer op.\n const lockAcquireP = new Promise<boolean>((resolve, reject) => {\n const checkIfAcquiredLock = (eventTaskId: string) => {\n if (eventTaskId !== taskId) {\n return;\n }\n\n // Also check pending ops here because it's possible we are currently in the queue from a previous\n // lock attempt, but have an outstanding abandon AND the outstanding volunteer for this lock attempt.\n // If we reach the head of the queue based on the previous lock attempt, we don't want to resolve.\n if (this.assigned(taskId) && !this.latestPendingOps.has(taskId)) {\n this.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n this.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n this.completedWatcher.off(\"completed\", checkIfCompleted);\n resolve(true);\n }\n };\n\n const checkIfAbandoned = (eventTaskId: string) => {\n if (eventTaskId !== taskId) {\n return;\n }\n\n this.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n this.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n this.completedWatcher.off(\"completed\", checkIfCompleted);\n reject(new Error(`Abandoned before acquiring task assignment: ${taskId}`));\n };\n\n const rejectOnDisconnect = () => {\n this.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n this.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n this.completedWatcher.off(\"completed\", checkIfCompleted);\n reject(new Error(`Disconnected before acquiring task assignment: ${taskId}`));\n };\n\n const checkIfCompleted = (eventTaskId: string) => {\n if (eventTaskId !== taskId) {\n return;\n }\n\n this.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n this.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n this.completedWatcher.off(\"completed\", checkIfCompleted);\n resolve(false);\n };\n\n this.queueWatcher.on(\"queueChange\", checkIfAcquiredLock);\n this.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.on(\"disconnect\", rejectOnDisconnect);\n this.completedWatcher.on(\"completed\", checkIfCompleted);\n });\n\n if (!this.queued(taskId)) {\n this.submitVolunteerOp(taskId);\n }\n return lockAcquireP;\n }\n\n /**\n * {@inheritDoc ITaskManager.subscribeToTask}\n */\n public subscribeToTask(taskId: string) {\n if (this.subscribed(taskId)) {\n return;\n }\n\n if (this.readOnlyInfo.readonly === true && this.readOnlyInfo.permissions === true) {\n throw new Error(`Attempted to subscribe with read-only permissions: ${taskId}`);\n }\n\n const submitVolunteerOp = () => {\n this.submitVolunteerOp(taskId);\n };\n\n const disconnectHandler = () => {\n // Wait to be connected again and then re-submit volunteer op\n this.connectionWatcher.once(\"connect\", submitVolunteerOp);\n };\n\n const checkIfAbandoned = (eventTaskId: string) => {\n if (eventTaskId !== taskId) {\n return;\n }\n\n this.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.off(\"disconnect\", disconnectHandler);\n this.connectionWatcher.off(\"connect\", submitVolunteerOp);\n this.completedWatcher.off(\"completed\", checkIfCompleted);\n\n this.subscribedTasks.delete(taskId);\n };\n\n const checkIfCompleted = (eventTaskId: string) => {\n if (eventTaskId !== taskId) {\n return;\n }\n\n this.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.off(\"disconnect\", disconnectHandler);\n this.connectionWatcher.off(\"connect\", submitVolunteerOp);\n this.completedWatcher.off(\"completed\", checkIfCompleted);\n\n this.subscribedTasks.delete(taskId);\n };\n\n this.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n this.connectionWatcher.on(\"disconnect\", disconnectHandler);\n this.completedWatcher.on(\"completed\", checkIfCompleted);\n\n if (!this.isAttached()) {\n // Simulate auto-ack in detached scenario\n assert(this.clientId !== undefined, 0x473 /* clientId should not be undefined */);\n this.addClientToQueue(taskId, this.clientId);\n // Because we volunteered with placeholderClientId, we need to wait for when we attach and are assigned\n // a real clientId. At that point we should re-enter the queue with a real volunteer op (assuming we are\n // connected).\n this.runtime.once(\"attached\", () => {\n if (this.queued(taskId)) {\n // If we are already queued, then we were able to replace the placeholderClientId with our real\n // clientId and no action is required.\n return;\n } else if (this.connected) {\n submitVolunteerOp();\n } else {\n this.connectionWatcher.once(\"connect\", () => {\n submitVolunteerOp();\n });\n }\n });\n } else if (!this.connected) {\n // If we are disconnected (and attached), wait to be connected and submit volunteer op\n disconnectHandler();\n } else if (!this.assigned(taskId) && !this.queued(taskId)) {\n submitVolunteerOp();\n }\n this.subscribedTasks.add(taskId);\n }\n\n /**\n * {@inheritDoc ITaskManager.abandon}\n */\n public abandon(taskId: string) {\n // Always allow abandon if the client is subscribed to allow clients to unsubscribe while disconnected.\n // Otherwise, we should check to make sure the client is both connected queued for the task before sending an\n // abandon op.\n if (!this.subscribed(taskId) && !this.queued(taskId)) {\n // Nothing to do\n return;\n }\n\n if (!this.isAttached()) {\n // Simulate auto-ack in detached scenario\n assert(this.clientId !== undefined, 0x474 /* clientId is undefined */);\n this.removeClientFromQueue(taskId, this.clientId);\n this.abandonWatcher.emit(\"abandon\", taskId);\n return;\n }\n\n // If we're subscribed but not queued, we don't need to submit an abandon op (probably offline)\n if (this.queued(taskId)) {\n this.submitAbandonOp(taskId);\n }\n this.abandonWatcher.emit(\"abandon\", taskId);\n }\n\n /**\n * {@inheritDoc ITaskManager.assigned}\n */\n public assigned(taskId: string) {\n if (this.isAttached() && !this.connected) {\n return false;\n }\n\n const currentAssignee = this.taskQueues.get(taskId)?.[0];\n return currentAssignee !== undefined\n && currentAssignee === this.clientId\n && !this.latestPendingOps.has(taskId);\n }\n\n /**\n * {@inheritDoc ITaskManager.queued}\n */\n public queued(taskId: string) {\n if (this.isAttached() && !this.connected) {\n return false;\n }\n\n assert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\n const clientQueue = this.taskQueues.get(taskId);\n // If we have no queue for the taskId, then no one has signed up for it.\n return (\n (clientQueue?.includes(this.clientId) ?? false)\n && !this.latestPendingOps.has(taskId)\n )\n || this.latestPendingOps.get(taskId)?.type === \"volunteer\";\n }\n\n /**\n * {@inheritDoc ITaskManager.subscribed}\n */\n public subscribed(taskId: string): boolean {\n return this.subscribedTasks.has(taskId);\n }\n\n /**\n * {@inheritDoc ITaskManager.complete}\n */\n public complete(taskId: string): void {\n if (!this.assigned(taskId)) {\n throw new Error(`Attempted to mark task as complete while not being assigned: ${taskId}`);\n }\n\n // If we are detached we will simulate auto-ack for the complete op. Therefore we only need to send the op if\n // we are attached. Additionally, we don't need to check if we are connected while detached.\n if (this.isAttached()) {\n if (!this.connected) {\n throw new Error(`Attempted to complete task in disconnected state: ${taskId}`);\n }\n this.submitCompleteOp(taskId);\n }\n\n this.taskQueues.delete(taskId);\n this.completedWatcher.emit(\"completed\", taskId);\n this.emit(\"completed\", taskId);\n }\n\n /**\n * {@inheritDoc ITaskManager.canVolunteer}\n */\n public canVolunteer(): boolean {\n // A client can volunteer for a task if it's both connected to the delta stream and in write mode.\n // this.connected reflects that condition, but is unintuitive and may be changed in the future. This API allows\n // us to make changes to this.connected without affecting our guidance on how to check if a client is eligible\n // to volunteer for a task.\n return this.connected;\n }\n\n /**\n * Create a summary for the task manager\n *\n * @returns the summary of the current state of the task manager\n * @internal\n */\n protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n if (this.runtime.clientId !== undefined) {\n // If the runtime has been assigned an actual clientId by now, we can replace the placeholder clientIds\n // and maintain the task assignment.\n this.replacePlaceholderInAllQueues();\n } else {\n // If the runtime has still not been assigned a clientId, we should not summarize with the placeholder\n // clientIds and instead remove them from the queues and require the client to re-volunteer when assigned\n // a new clientId.\n this.removeClientFromAllQueues(placeholderClientId);\n }\n\n // Only include tasks if there are clients in the queue.\n const filteredMap = new Map<string, string[]>();\n this.taskQueues.forEach((queue: string[], taskId: string) => {\n if (queue.length > 0) {\n filteredMap.set(taskId, queue);\n }\n });\n const content = [...filteredMap.entries()];\n return createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n * @internal\n */\n protected async loadCore(storage: IChannelStorageService): Promise<void> {\n const content = await readAndParse<[string, string[]][]>(storage, snapshotFileName);\n content.forEach(([taskId, clientIdQueue]) => {\n this.taskQueues.set(taskId, clientIdQueue);\n });\n this.scrubClientsNotInQuorum();\n }\n\n /**\n * @internal\n */\n protected initializeLocalCore() { }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n * @internal\n */\n protected onDisconnect() {\n this.connectionWatcher.emit(\"disconnect\");\n }\n\n /**\n * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n * @internal\n */\n protected onConnect() {\n this.connectionWatcher.emit(\"connect\");\n }\n\n //\n /**\n * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the\n * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.\n * @internal\n */\n protected reSubmitCore() { }\n\n /**\n * Process a task manager operation\n *\n * @param message - the message to prepare\n * @param local - whether the message was sent by the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @internal\n */\n protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n if (message.type === MessageType.Operation) {\n const op = message.contents as ITaskManagerOperation;\n const messageId = localOpMetadata as number;\n\n switch (op.type) {\n case \"volunteer\":\n this.opWatcher.emit(\"volunteer\", op.taskId, message.clientId, local, messageId);\n break;\n\n case \"abandon\":\n this.opWatcher.emit(\"abandon\", op.taskId, message.clientId, local, messageId);\n break;\n\n case \"complete\":\n this.opWatcher.emit(\"complete\", op.taskId, message.clientId, local, messageId);\n break;\n\n default:\n throw new Error(\"Unknown operation\");\n }\n }\n }\n\n private addClientToQueue(taskId: string, clientId: string) {\n const pendingIds = this.pendingCompletedTasks.get(taskId);\n if (pendingIds !== undefined && pendingIds.length > 0) {\n // Ignore the volunteer op if we know this task is about to be completed\n return;\n }\n\n // Ensure that the clientId exists in the quorum, or it is placeholderClientId (detached scenario)\n if (this.runtime.getQuorum().getMembers().has(clientId) || this.clientId === placeholderClientId) {\n // Create the queue if it doesn't exist, and push the client on the back.\n let clientQueue = this.taskQueues.get(taskId);\n if (clientQueue === undefined) {\n clientQueue = [];\n this.taskQueues.set(taskId, clientQueue);\n }\n\n const oldLockHolder = clientQueue[0];\n clientQueue.push(clientId);\n const newLockHolder = clientQueue[0];\n if (newLockHolder !== oldLockHolder) {\n this.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n }\n\n }\n }\n\n private removeClientFromQueue(taskId: string, clientId: string) {\n const clientQueue = this.taskQueues.get(taskId);\n if (clientQueue === undefined) {\n return;\n }\n\n const oldLockHolder = clientId === placeholderClientId ? placeholderClientId : clientQueue[0];\n const clientIdIndex = clientQueue.indexOf(clientId);\n if (clientIdIndex !== -1) {\n clientQueue.splice(clientIdIndex, 1);\n // Clean up the queue if there are no more clients in it.\n if (clientQueue.length === 0) {\n this.taskQueues.delete(taskId);\n }\n }\n const newLockHolder = clientQueue[0];\n if (newLockHolder !== oldLockHolder) {\n this.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n }\n }\n\n private removeClientFromAllQueues(clientId: string) {\n for (const taskId of this.taskQueues.keys()) {\n this.removeClientFromQueue(taskId, clientId);\n }\n }\n\n /**\n * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when\n * transitioning from detached to attached and this.runtime.clientId is defined.\n */\n private replacePlaceholderInAllQueues() {\n assert(this.runtime.clientId !== undefined, 0x475 /* this.runtime.clientId should be defined */);\n for (const clientQueue of this.taskQueues.values()) {\n const clientIdIndex = clientQueue.indexOf(placeholderClientId);\n if (clientIdIndex !== -1) {\n clientQueue[clientIdIndex] = this.runtime.clientId;\n }\n }\n }\n\n // This seems like it should be unnecessary if we can trust to receive the join/leave messages and\n // also have an accurate snapshot.\n private scrubClientsNotInQuorum() {\n const quorum = this.runtime.getQuorum();\n for (const [taskId, clientQueue] of this.taskQueues) {\n const filteredClientQueue = clientQueue.filter((clientId) => quorum.getMember(clientId) !== undefined);\n if (clientQueue.length !== filteredClientQueue.length) {\n if (filteredClientQueue.length === 0) {\n this.taskQueues.delete(taskId);\n } else {\n this.taskQueues.set(taskId, filteredClientQueue);\n }\n this.queueWatcher.emit(\"queueChange\", taskId);\n }\n }\n }\n\n public applyStashedOp() {\n throw new Error(\"not implemented\");\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
+
import { ITaskManager } from "./interfaces";
|
|
7
|
+
/**
|
|
8
|
+
* The factory that defines the task queue
|
|
9
|
+
*/
|
|
10
|
+
export declare class TaskManagerFactory implements IChannelFactory {
|
|
11
|
+
static readonly Type = "https://graph.microsoft.com/types/task-manager";
|
|
12
|
+
static readonly Attributes: IChannelAttributes;
|
|
13
|
+
get type(): string;
|
|
14
|
+
get attributes(): IChannelAttributes;
|
|
15
|
+
/**
|
|
16
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
17
|
+
*/
|
|
18
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ITaskManager>;
|
|
19
|
+
create(document: IFluidDataStoreRuntime, id: string): ITaskManager;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=taskManagerFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskManagerFactory.d.ts","sourceRoot":"","sources":["../src/taskManagerFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C;;GAEG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACtD,gBAAuB,IAAI,oDAAoD;IAE/E,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAMnD,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY;CAK5E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TaskManagerFactory = void 0;
|
|
8
|
+
const taskManager_1 = require("./taskManager");
|
|
9
|
+
const packageVersion_1 = require("./packageVersion");
|
|
10
|
+
/**
|
|
11
|
+
* The factory that defines the task queue
|
|
12
|
+
*/
|
|
13
|
+
class TaskManagerFactory {
|
|
14
|
+
get type() {
|
|
15
|
+
return TaskManagerFactory.Type;
|
|
16
|
+
}
|
|
17
|
+
get attributes() {
|
|
18
|
+
return TaskManagerFactory.Attributes;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
22
|
+
*/
|
|
23
|
+
async load(runtime, id, services, attributes) {
|
|
24
|
+
const taskQueue = new taskManager_1.TaskManager(id, runtime, attributes);
|
|
25
|
+
await taskQueue.load(services);
|
|
26
|
+
return taskQueue;
|
|
27
|
+
}
|
|
28
|
+
create(document, id) {
|
|
29
|
+
const taskQueue = new taskManager_1.TaskManager(id, document, this.attributes);
|
|
30
|
+
taskQueue.initializeLocal();
|
|
31
|
+
return taskQueue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TaskManagerFactory = TaskManagerFactory;
|
|
35
|
+
TaskManagerFactory.Type = "https://graph.microsoft.com/types/task-manager";
|
|
36
|
+
TaskManagerFactory.Attributes = {
|
|
37
|
+
type: TaskManagerFactory.Type,
|
|
38
|
+
snapshotFormatVersion: "0.1",
|
|
39
|
+
packageVersion: packageVersion_1.pkgVersion,
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=taskManagerFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskManagerFactory.js","sourceRoot":"","sources":["../src/taskManagerFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+CAA4C;AAE5C,qDAA8C;AAE9C;;GAEG;AACH,MAAa,kBAAkB;IAS3B,IAAW,IAAI;QACX,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,kBAAkB,CAAC,UAAU,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACb,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAC9B,MAAM,SAAS,GAAG,IAAI,yBAAW,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3D,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACtD,MAAM,SAAS,GAAG,IAAI,yBAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,SAAS,CAAC,eAAe,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACrB,CAAC;;AAlCL,gDAmCC;AAlC0B,uBAAI,GAAG,gDAAgD,CAAC;AAExD,6BAAU,GAAuB;IACpD,IAAI,EAAE,kBAAkB,CAAC,IAAI;IAC7B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,2BAAU;CAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelServices,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { TaskManager } from \"./taskManager\";\nimport { ITaskManager } from \"./interfaces\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * The factory that defines the task queue\n */\nexport class TaskManagerFactory implements IChannelFactory {\n public static readonly Type = \"https://graph.microsoft.com/types/task-manager\";\n\n public static readonly Attributes: IChannelAttributes = {\n type: TaskManagerFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n public get type() {\n return TaskManagerFactory.Type;\n }\n\n public get attributes() {\n return TaskManagerFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes): Promise<ITaskManager> {\n const taskQueue = new TaskManager(id, runtime, attributes);\n await taskQueue.load(services);\n return taskQueue;\n }\n\n public create(document: IFluidDataStoreRuntime, id: string): ITaskManager {\n const taskQueue = new TaskManager(id, document, this.attributes);\n taskQueue.initializeLocal();\n return taskQueue;\n }\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { ITaskManager, ITaskManagerEvents } from "./interfaces";
|
|
6
|
+
export { TaskManager } from "./taskManager";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ITaskManager, ITaskManagerEvents } from \"./interfaces\";\nexport { TaskManager } from \"./taskManager\";\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
6
|
+
/**
|
|
7
|
+
* Events emitted by {@link TaskManager}.
|
|
8
|
+
*/
|
|
9
|
+
export interface ITaskManagerEvents extends ISharedObjectEvents {
|
|
10
|
+
/**
|
|
11
|
+
* Notifies when the local client has reached the front of the queue, left the queue, or a task was completed.
|
|
12
|
+
* Does not account for known pending ops, but instead only reflects the current state.
|
|
13
|
+
*/
|
|
14
|
+
(event: "assigned" | "completed" | "lost", listener: (taskId: string) => void): any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Task manager interface
|
|
18
|
+
*/
|
|
19
|
+
export interface ITaskManager extends ISharedObject<ITaskManagerEvents> {
|
|
20
|
+
/**
|
|
21
|
+
* Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and
|
|
22
|
+
* `false` if the task was completed by another client. It rejects if the local client abandoned the task or
|
|
23
|
+
* disconnected while in queue.
|
|
24
|
+
* @param taskId - Identifier for the task
|
|
25
|
+
*/
|
|
26
|
+
volunteerForTask(taskId: string): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Continuously volunteer for the task. Watch the "assigned" event to determine if the task is assigned.
|
|
29
|
+
* The local client will automatically re-enter the queue if it disconnects.
|
|
30
|
+
* @param taskId - Identifier for the task
|
|
31
|
+
*/
|
|
32
|
+
subscribeToTask(taskId: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Exit the queue, releasing the task if currently assigned.
|
|
35
|
+
* @param taskId - Identifier for the task
|
|
36
|
+
*/
|
|
37
|
+
abandon(taskId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Check whether this client is the current assignee for the task and there is no outstanding abandon op that
|
|
40
|
+
* would abandon the assignment.
|
|
41
|
+
* @param taskId - Identifier for the task
|
|
42
|
+
*/
|
|
43
|
+
assigned(taskId: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check whether this client is either the current assignee, in queue, or we expect they will be in queue after
|
|
46
|
+
* outstanding ops have been ack'd.
|
|
47
|
+
* @param taskId - Identifier for the task
|
|
48
|
+
*/
|
|
49
|
+
queued(taskId: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Check whether this client is currently subscribed to the task.
|
|
52
|
+
* @param taskId - Identifier for the task
|
|
53
|
+
*/
|
|
54
|
+
subscribed(taskId: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Marks a task as completed and releases all clients from its queue.
|
|
57
|
+
* @param taskId - Identifier for the task
|
|
58
|
+
*/
|
|
59
|
+
complete(taskId: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Check whether this client can currently volunteer for a task.
|
|
62
|
+
*/
|
|
63
|
+
canVolunteer(): boolean;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC3D;;;OAGG;IACH,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,OAAE;CAClF;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,aAAa,CAAC,kBAAkB,CAAC;IACnE;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnD;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhC;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedObject, ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\n\n/**\n * Events emitted by {@link TaskManager}.\n */\nexport interface ITaskManagerEvents extends ISharedObjectEvents {\n /**\n * Notifies when the local client has reached the front of the queue, left the queue, or a task was completed.\n * Does not account for known pending ops, but instead only reflects the current state.\n */\n (event: \"assigned\" | \"completed\" | \"lost\", listener: (taskId: string) => void);\n}\n\n/**\n * Task manager interface\n */\nexport interface ITaskManager extends ISharedObject<ITaskManagerEvents> {\n /**\n * Volunteer for the task. Returns a promise that resolves `true` if the task is assigned to the local client and\n * `false` if the task was completed by another client. It rejects if the local client abandoned the task or\n * disconnected while in queue.\n * @param taskId - Identifier for the task\n */\n volunteerForTask(taskId: string): Promise<boolean>;\n\n /**\n * Continuously volunteer for the task. Watch the \"assigned\" event to determine if the task is assigned.\n * The local client will automatically re-enter the queue if it disconnects.\n * @param taskId - Identifier for the task\n */\n subscribeToTask(taskId: string): void;\n\n /**\n * Exit the queue, releasing the task if currently assigned.\n * @param taskId - Identifier for the task\n */\n abandon(taskId: string): void;\n\n /**\n * Check whether this client is the current assignee for the task and there is no outstanding abandon op that\n * would abandon the assignment.\n * @param taskId - Identifier for the task\n */\n assigned(taskId: string): boolean;\n\n /**\n * Check whether this client is either the current assignee, in queue, or we expect they will be in queue after\n * outstanding ops have been ack'd.\n * @param taskId - Identifier for the task\n */\n queued(taskId: string): boolean;\n\n /**\n * Check whether this client is currently subscribed to the task.\n * @param taskId - Identifier for the task\n */\n subscribed(taskId: string): boolean;\n\n /**\n * Marks a task as completed and releases all clients from its queue.\n * @param taskId - Identifier for the task\n */\n complete(taskId: string): void;\n\n /**\n * Check whether this client can currently volunteer for a task.\n */\n canVolunteer(): boolean;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluidframework/task-manager";
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.2.2.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export const pkgName = "@fluidframework/task-manager";
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.2.2.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/task-manager\";\nexport const pkgVersion = \"2.0.0-internal.2.2.0\";\n"]}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
|
+
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
8
|
+
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
|
|
9
|
+
import { ITaskManager, ITaskManagerEvents } from "./interfaces";
|
|
10
|
+
/**
|
|
11
|
+
* The TaskManager distributed data structure tracks queues of clients that want to exclusively run a task.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
*
|
|
15
|
+
* For an in-depth overview, see [TaskManager](https://fluidframework.com/docs/data-structures/task-manager/).
|
|
16
|
+
*
|
|
17
|
+
* ### Creation
|
|
18
|
+
*
|
|
19
|
+
* To create a `TaskManager`, call the static create method:
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const taskManager = TaskManager.create(this.runtime, id);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ### Usage
|
|
26
|
+
*
|
|
27
|
+
* To volunteer for a task, use the `volunteerForTask()` method. This returns a Promise that will resolve once the
|
|
28
|
+
* client has acquired exclusive rights to run the task, or reject if the client is removed from the queue without
|
|
29
|
+
* acquiring the rights.
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* taskManager.volunteerForTask("NameOfTask")
|
|
33
|
+
* .then(() => { doTheTask(); })
|
|
34
|
+
* .catch((err) => { console.error(err); });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Alternatively, you can indefinitely volunteer for a task with the synchronous `subscribeToTask()` method. This
|
|
38
|
+
* method does not return a value, therefore you need to rely on eventing to know when you have acquired the rights
|
|
39
|
+
* to run the task (see below).
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* taskManager.subscribeToTask("NameOfTask");
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* To check if the local client is currently subscribed to a task, use the `subscribed()` method.
|
|
46
|
+
* ```typescript
|
|
47
|
+
* if (taskManager.subscribed("NameOfTask")) {
|
|
48
|
+
* console.log("This client is currently subscribed to the task.");
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* To release the rights to the task, use the `abandon()` method. The next client in the queue will then get the
|
|
53
|
+
* rights to run the task.
|
|
54
|
+
*
|
|
55
|
+
* ```typescript
|
|
56
|
+
* taskManager.abandon("NameOfTask");
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* To inspect your state in the queue, you can use the `queued()` and `assigned()` methods.
|
|
60
|
+
*
|
|
61
|
+
* ```typescript
|
|
62
|
+
* if (taskManager.queued("NameOfTask")) {
|
|
63
|
+
* console.log("This client is somewhere in the queue, potentially even having the task assignment.");
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* if (taskManager.assigned("NameOfTask")) {
|
|
67
|
+
* console.log("This client currently has the rights to run the task");
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* To signal to other connected clients that a task is completed, use the `complete()` method. This will release all
|
|
72
|
+
* clients from the queue and emit the "completed" event.
|
|
73
|
+
*
|
|
74
|
+
* ```typescript
|
|
75
|
+
* taskManager.complete("NameOfTask");
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* ### Eventing
|
|
79
|
+
*
|
|
80
|
+
* `TaskManager` is an `EventEmitter`, and will emit events when a task is assigned to the client, when the task
|
|
81
|
+
* assignment is lost, and when a task was completed by another client.
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* taskManager.on("assigned", (taskId: string) => {
|
|
85
|
+
* console.log(`Client was assigned task: ${taskId}`);
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* taskManager.on("lost", (taskId: string) => {
|
|
89
|
+
* console.log(`Client released task: ${taskId}`);
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* taskManager.on("completed", (taskId: string) => {
|
|
93
|
+
* console.log(`Another client completed task: ${taskId}`);
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* These can be useful if the logic to volunteer for a task is separated from the logic to perform the task, such as
|
|
98
|
+
* when using the `subscribeToTask()` method.
|
|
99
|
+
*/
|
|
100
|
+
export declare class TaskManager extends SharedObject<ITaskManagerEvents> implements ITaskManager {
|
|
101
|
+
/**
|
|
102
|
+
* Create a new TaskManager
|
|
103
|
+
*
|
|
104
|
+
* @param runtime - data store runtime the new task queue belongs to
|
|
105
|
+
* @param id - optional name of the task queue
|
|
106
|
+
* @returns newly create task queue (but not attached yet)
|
|
107
|
+
*/
|
|
108
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): TaskManager;
|
|
109
|
+
/**
|
|
110
|
+
* Get a factory for TaskManager to register with the data store.
|
|
111
|
+
*
|
|
112
|
+
* @returns a factory that creates and load TaskManager
|
|
113
|
+
*/
|
|
114
|
+
static getFactory(): IChannelFactory;
|
|
115
|
+
/**
|
|
116
|
+
* Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the
|
|
117
|
+
* queue, even if we know we've submitted an op that should eventually modify the queue.
|
|
118
|
+
*/
|
|
119
|
+
private readonly taskQueues;
|
|
120
|
+
private readonly opWatcher;
|
|
121
|
+
private readonly queueWatcher;
|
|
122
|
+
private readonly abandonWatcher;
|
|
123
|
+
private readonly connectionWatcher;
|
|
124
|
+
private readonly completedWatcher;
|
|
125
|
+
private messageId;
|
|
126
|
+
/**
|
|
127
|
+
* Tracks the most recent pending op for a given task
|
|
128
|
+
*/
|
|
129
|
+
private readonly latestPendingOps;
|
|
130
|
+
/**
|
|
131
|
+
* Tracks tasks that are this client is currently subscribed to.
|
|
132
|
+
*/
|
|
133
|
+
private readonly subscribedTasks;
|
|
134
|
+
/**
|
|
135
|
+
* Map to track tasks that have pending complete ops.
|
|
136
|
+
*/
|
|
137
|
+
private readonly pendingCompletedTasks;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.
|
|
140
|
+
*/
|
|
141
|
+
private get clientId();
|
|
142
|
+
/**
|
|
143
|
+
* Returns a ReadOnlyInfo object to determine current read/write permissions.
|
|
144
|
+
*/
|
|
145
|
+
private get readOnlyInfo();
|
|
146
|
+
/**
|
|
147
|
+
* Constructs a new task manager. If the object is non-local an id and service interfaces will
|
|
148
|
+
* be provided
|
|
149
|
+
*
|
|
150
|
+
* @param runtime - data store runtime the task queue belongs to
|
|
151
|
+
* @param id - optional name of the task queue
|
|
152
|
+
*/
|
|
153
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
154
|
+
private submitVolunteerOp;
|
|
155
|
+
private submitAbandonOp;
|
|
156
|
+
private submitCompleteOp;
|
|
157
|
+
/**
|
|
158
|
+
* {@inheritDoc ITaskManager.volunteerForTask}
|
|
159
|
+
*/
|
|
160
|
+
volunteerForTask(taskId: string): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* {@inheritDoc ITaskManager.subscribeToTask}
|
|
163
|
+
*/
|
|
164
|
+
subscribeToTask(taskId: string): void;
|
|
165
|
+
/**
|
|
166
|
+
* {@inheritDoc ITaskManager.abandon}
|
|
167
|
+
*/
|
|
168
|
+
abandon(taskId: string): void;
|
|
169
|
+
/**
|
|
170
|
+
* {@inheritDoc ITaskManager.assigned}
|
|
171
|
+
*/
|
|
172
|
+
assigned(taskId: string): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* {@inheritDoc ITaskManager.queued}
|
|
175
|
+
*/
|
|
176
|
+
queued(taskId: string): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* {@inheritDoc ITaskManager.subscribed}
|
|
179
|
+
*/
|
|
180
|
+
subscribed(taskId: string): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* {@inheritDoc ITaskManager.complete}
|
|
183
|
+
*/
|
|
184
|
+
complete(taskId: string): void;
|
|
185
|
+
/**
|
|
186
|
+
* {@inheritDoc ITaskManager.canVolunteer}
|
|
187
|
+
*/
|
|
188
|
+
canVolunteer(): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Create a summary for the task manager
|
|
191
|
+
*
|
|
192
|
+
* @returns the summary of the current state of the task manager
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
196
|
+
/**
|
|
197
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
protected initializeLocalCore(): void;
|
|
205
|
+
/**
|
|
206
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
protected onDisconnect(): void;
|
|
210
|
+
/**
|
|
211
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
protected onConnect(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the
|
|
217
|
+
* queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
protected reSubmitCore(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Process a task manager operation
|
|
223
|
+
*
|
|
224
|
+
* @param message - the message to prepare
|
|
225
|
+
* @param local - whether the message was sent by the local client
|
|
226
|
+
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
227
|
+
* For messages from a remote client, this will be undefined.
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
231
|
+
private addClientToQueue;
|
|
232
|
+
private removeClientFromQueue;
|
|
233
|
+
private removeClientFromAllQueues;
|
|
234
|
+
/**
|
|
235
|
+
* Will replace all instances of the placeholderClientId with the current clientId. This should only be called when
|
|
236
|
+
* transitioning from detached to attached and this.runtime.clientId is defined.
|
|
237
|
+
*/
|
|
238
|
+
private replacePlaceholderInAllQueues;
|
|
239
|
+
private scrubClientsNotInQuorum;
|
|
240
|
+
applyStashedOp(): void;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=taskManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAA2B,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAG7G,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAsChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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