mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 13:34:33 +00:00
refactor(workflow-core): statically import Worker type from @temporalio/worker to ensure activeWorkers type-safety
This commit is contained in:
@@ -7,9 +7,11 @@ import { LocalExecutor } from './local-executor'
|
|||||||
import { TemporalExecutor } from './temporal-executor'
|
import { TemporalExecutor } from './temporal-executor'
|
||||||
import { TaskQueueAgent, TaskQueueTranscode, getConcurrencyLimit } from './workflow-utils'
|
import { TaskQueueAgent, TaskQueueTranscode, getConcurrencyLimit } from './workflow-utils'
|
||||||
|
|
||||||
|
import type { Worker } from '@temporalio/worker'
|
||||||
|
|
||||||
export class WorkflowService {
|
export class WorkflowService {
|
||||||
private executor: Executor
|
private executor: Executor
|
||||||
private activeWorkers: unknown[] = []
|
private activeWorkers: Worker[] = []
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
||||||
@@ -74,9 +76,7 @@ export class WorkflowService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async shutdownWorkers(): Promise<void> {
|
async shutdownWorkers(): Promise<void> {
|
||||||
await Promise.all(
|
await Promise.all(this.activeWorkers.map((w) => w.shutdown()))
|
||||||
this.activeWorkers.map((w) => (w as { shutdown: () => Promise<void> }).shutdown()),
|
|
||||||
)
|
|
||||||
this.activeWorkers = []
|
this.activeWorkers = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user