@temporalio/worker
Version:
Temporal.io SDK Worker sub-package
44 lines (43 loc) • 1.86 kB
TypeScript
import vm from 'node:vm';
import { Workflow, WorkflowCreateOptions, WorkflowCreator } from './interface';
import { WorkflowBundleWithSourceMapAndFilename } from './workflow-worker-thread/input';
import { BaseVMWorkflow } from './vm-shared';
/**
* A WorkflowCreator that creates VMWorkflows in the current isolate
*/
export declare class VMWorkflowCreator implements WorkflowCreator {
protected readonly workflowBundle: WorkflowBundleWithSourceMapAndFilename;
protected readonly isolateExecutionTimeoutMs: number;
protected readonly registeredActivityNames: Set<string>;
private static unhandledRejectionHandlerHasBeenSet;
static workflowByRunId: Map<string, VMWorkflow>;
script?: vm.Script;
constructor(script: vm.Script, workflowBundle: WorkflowBundleWithSourceMapAndFilename, isolateExecutionTimeoutMs: number, registeredActivityNames: Set<string>);
/**
* Create a workflow with given options
*/
createWorkflow(options: WorkflowCreateOptions): Promise<Workflow>;
protected getContext(): vm.Context;
/**
* Inject global objects as well as console.[log|...] into a vm context.
*
* Overridable for test purposes.
*/
protected injectGlobals(context: vm.Context): void;
/**
* Create a new instance, pre-compile scripts from given code.
*
* This method is generic to support subclassing.
*/
static create<T extends typeof VMWorkflowCreator>(this: T, workflowBundle: WorkflowBundleWithSourceMapAndFilename, isolateExecutionTimeoutMs: number, registeredActivityNames: Set<string>): Promise<InstanceType<T>>;
/**
* Cleanup the pre-compiled script
*/
destroy(): Promise<void>;
}
/**
* A Workflow implementation using Node.js' built-in `vm` module
*/
export declare class VMWorkflow extends BaseVMWorkflow {
dispose(): Promise<void>;
}