nestjs-temporal-core
    Preparing search index...

    Class Worker

    The temporal Worker connects to Temporal Server and runs Workflows and Activities.

    Index

    Properties

    options: CompiledWorkerOptions

    Accessors

    • get numInFlightActivations$(): Observable<number>

      An Observable which emits each time the number of in flight activations changes

      Returns Observable<number>

    • get numInFlightActivities$(): Observable<number>

      An Observable which emits each time the number of in flight Activity tasks changes

      Returns Observable<number>

    • get numRunningWorkflowInstances$(): Observable<number>

      An Observable which emits each time the number of cached workflows changes

      Returns Observable<number>

    Methods

    • Get the poll state of this worker

      Returns State

    • Get a status overview of this Worker

      Returns WorkerStatus

    • Start polling on the Task Queue for tasks. Completes after graceful shutdown, once the Worker reaches the 'STOPPED' state.

      Throws on a fatal error or failure to shutdown gracefully.

      Returns Promise<void>

      errors

      To stop polling, call shutdown or send one of Runtime.options.shutdownSignals.

    • Run the Worker until fnOrPromise completes, then shutdown and wait for run to complete.

      Be aware that the Worker may shutdown for reasons other than the completion of the provided promise, e.g. due to the process receiving a SIGINT signal, direct call to Worker.shutdown(), or a critical error that imposes a shutdown of the Worker.

      Throws on fatal Worker errors.

      SDK versions >=1.11.3: If the worker shuts down before the inner promise completes, allow no more than RunUntilOptions.promiseCompletionTimeout for the inner promise to complete, after which a PromiseCompletionTimeoutError is thrown.

      SDK versions >=1.5.0: This method always waits for both worker shutdown and inner fnOrPromise to complete. If one of worker run -or- the inner promise throw an error, that error is rethrown. If both throw an error, a CombinedWorkerRunError with a cause attribute containing both errors.

      SDK versions < 1.5.0: This method would not wait for worker to complete shutdown if the inner fnOrPromise threw an error.

      Type Parameters

      • R

      Parameters

      • fnOrPromise: Promise<R> | (() => Promise<R>)
      • Optionaloptions: RunUntilOptions

      Returns Promise<R>

      the result of fnOrPromise

    • Start shutting down the Worker. The Worker stops polling for new tasks and sends cancellation (via a CancelledFailure with message set to 'WORKER_SHUTDOWN') to running Activities. Note: if the Activity accepts cancellation (i.e. re-throws or allows the CancelledFailure to be thrown out of the Activity function), the Activity Task will be marked as failed, not cancelled. It's helpful for the Activity Task to be marked failed during shutdown because the Server will retry the Activity sooner (than if the Server had to wait for the Activity Task to time out).

      When called, immediately transitions state to 'STOPPING' and asks Core to shut down. Once Core has confirmed that it's shutting down, the Worker enters 'DRAINING' state. It will stay in that state until both task pollers receive a ShutdownError, at which point we'll transition to DRAINED state. Once all currently running Activities and Workflow Tasks have completed, the Worker transitions to 'STOPPED'.

      Returns void

    • Create a new Worker. This method initiates a connection to the server and will throw (asynchronously) on connection failure.

      Parameters

      • options: WorkerOptions

      Returns Promise<Worker>

    • Create a replay Worker, running all histories provided by the passed in iterable.

      Returns an async iterable of results for each history replayed.

      Parameters

      • options: ReplayWorkerOptions
      • histories: ReplayHistoriesIterable

      Returns AsyncIterableIterator<ReplayResult>

    • Create a replay Worker, and run the provided history against it. Will resolve as soon as the history has finished being replayed, or if the workflow produces a nondeterminism error.

      Parameters

      • options: ReplayWorkerOptions
      • history: unknown
      • OptionalworkflowId: string

        If provided, use this as the workflow id during replay. Histories do not contain a workflow id, so it must be provided separately if your workflow depends on it.

      Returns Promise<void>

      DeterminismViolationError if the workflow code is not compatible with the history.

      ReplayError on any other replay related error.