Skip to main content

Class: TemporalWorkerManagerService

Defined in: src/services/temporal-worker.service.ts:52

Temporal Worker Manager Service

Manages the lifecycle of Temporal workers including:

  • Worker initialization and configuration (single or multiple workers)
  • Activity discovery and registration
  • Worker health monitoring
  • Graceful shutdown handling with timeout protection
  • Support for multiple task queues
  • Proper process signal handling (SIGTERM/SIGINT)

Implements​

  • OnModuleInit
  • OnModuleDestroy
  • OnApplicationBootstrap
  • BeforeApplicationShutdown

Constructors​

Constructor​

new TemporalWorkerManagerService(discoveryService, options, injectedConnection): TemporalWorkerManagerService

Defined in: src/services/temporal-worker.service.ts:73

Parameters​

discoveryService​

TemporalDiscoveryService

options​

TemporalOptions

injectedConnection​

NativeConnection | null

Returns​

TemporalWorkerManagerService

Methods​

beforeApplicationShutdown()​

beforeApplicationShutdown(signal?): Promise<void>

Defined in: src/services/temporal-worker.service.ts:198

BeforeApplicationShutdown lifecycle hook Initiates graceful shutdown before the application fully shuts down This ensures workers have time to complete in-flight tasks

Parameters​

signal?​

string

Returns​

Promise<void>

Implementation of​

BeforeApplicationShutdown.beforeApplicationShutdown


getAllWorkers()​

getAllWorkers(): MultipleWorkersInfo

Defined in: src/services/temporal-worker.service.ts:377

Get all workers information

Returns​

MultipleWorkersInfo


getConnection()​

getConnection(): NativeConnection | null

Defined in: src/services/temporal-worker.service.ts:582

Get the native connection for creating custom workers

Returns​

NativeConnection | null

NativeConnection instance or null


getHealthStatus()​

getHealthStatus(): WorkerHealthStatus

Defined in: src/services/temporal-worker.service.ts:962

Get worker health status

Returns​

WorkerHealthStatus


getRegisteredActivities()​

getRegisteredActivities(): Record<string, Function>

Defined in: src/services/temporal-worker.service.ts:891

Get registered activities

Returns​

Record<string, Function>


getStats()​

getStats(): WorkerStats

Defined in: src/services/temporal-worker.service.ts:981

Get worker statistics

Returns​

WorkerStats


getWorker()​

getWorker(taskQueue): Worker | null

Defined in: src/services/temporal-worker.service.ts:369

Get a specific worker by task queue

Parameters​

taskQueue​

string

Returns​

Worker | null


getWorkerStatus()​

getWorkerStatus(): WorkerStatus

Defined in: src/services/temporal-worker.service.ts:870

Get worker status

Returns​

WorkerStatus


getWorkerStatusByTaskQueue()​

getWorkerStatusByTaskQueue(taskQueue): WorkerStatus | null

Defined in: src/services/temporal-worker.service.ts:397

Get worker status for a specific task queue

Parameters​

taskQueue​

string

Returns​

WorkerStatus | null


isWorkerAvailable()​

isWorkerAvailable(): boolean

Defined in: src/services/temporal-worker.service.ts:948

Check if worker is available

Returns​

boolean


isWorkerRunning()​

isWorkerRunning(): boolean

Defined in: src/services/temporal-worker.service.ts:955

Check if worker is running

Returns​

boolean


onApplicationBootstrap()​

onApplicationBootstrap(): Promise<void>

Defined in: src/services/temporal-worker.service.ts:153

Returns​

Promise<void>

Implementation of​

OnApplicationBootstrap.onApplicationBootstrap


onModuleDestroy()​

onModuleDestroy(): Promise<void>

Defined in: src/services/temporal-worker.service.ts:223

Returns​

Promise<void>

Implementation of​

OnModuleDestroy.onModuleDestroy


onModuleInit()​

onModuleInit(): Promise<void>

Defined in: src/services/temporal-worker.service.ts:106

Returns​

Promise<void>

Implementation of​

OnModuleInit.onModuleInit


registerActivitiesFromDiscovery()​

registerActivitiesFromDiscovery(): Promise<ActivityRegistrationResult>

Defined in: src/services/temporal-worker.service.ts:902

Register activities from discovery service

Returns​

Promise<ActivityRegistrationResult>


registerWorker()​

registerWorker(workerDef): Promise<CreateWorkerResult>

Defined in: src/services/temporal-worker.service.ts:332

Register and create a new worker dynamically at runtime

Parameters​

workerDef​

WorkerDefinition

Returns​

Promise<CreateWorkerResult>


restartWorker()​

restartWorker(): Promise<WorkerRestartResult>

Defined in: src/services/temporal-worker.service.ts:839

Restart the worker

Returns​

Promise<WorkerRestartResult>


shutdown()​

shutdown(): Promise<void>

Defined in: src/services/temporal-worker.service.ts:832

Shutdown the worker (alias for shutdownWorker)

Returns​

Promise<void>


startWorker()​

startWorker(): Promise<void>

Defined in: src/services/temporal-worker.service.ts:661

Start the worker

Returns​

Promise<void>


startWorkerByTaskQueue()​

startWorkerByTaskQueue(taskQueue): Promise<void>

Defined in: src/services/temporal-worker.service.ts:405

Start a specific worker by task queue

Parameters​

taskQueue​

string

Returns​

Promise<void>


stopWorker()​

stopWorker(): Promise<void>

Defined in: src/services/temporal-worker.service.ts:809

Stop the worker gracefully

Returns​

Promise<void>


stopWorkerByTaskQueue()​

stopWorkerByTaskQueue(taskQueue): Promise<void>

Defined in: src/services/temporal-worker.service.ts:441

Stop a specific worker by task queue

Parameters​

taskQueue​

string

Returns​

Promise<void>