feat: Ensure async workflow executions have access to shared container (#8157)

* feat: Ensure async workflow executions have access to shared container

* fix: Register workflow worker on application start
This commit is contained in:
Stevche Radevski
2024-07-17 12:17:48 +02:00
committed by GitHub
parent 1acfdc4ffe
commit 26d600b6db
15 changed files with 140 additions and 38 deletions

View File

@@ -29,6 +29,8 @@ export class RedisDistributedTransactionStorage
private workflowOrchestratorService_: WorkflowOrchestratorService
private redisClient: Redis
private redisWorkerConnection: Redis
private queueName: string
private queue: Queue
private worker: Worker
@@ -47,12 +49,24 @@ export class RedisDistributedTransactionStorage
}) {
this.workflowExecutionService_ = workflowExecutionService
this.logger_ = logger
this.redisClient = redisConnection
this.redisWorkerConnection = redisWorkerConnection
this.queueName = redisQueueName
this.queue = new Queue(redisQueueName, { connection: this.redisClient })
}
async onApplicationPrepareShutdown() {
// Close worker gracefully, i.e. wait for the current jobs to finish
await this.worker.close()
}
async onApplicationShutdown() {
await this.queue.close()
}
async onApplicationStart() {
this.worker = new Worker(
redisQueueName,
this.queueName,
async (job) => {
const allJobs = [
JobType.RETRY,
@@ -75,19 +89,10 @@ export class RedisDistributedTransactionStorage
)
}
},
{ connection: redisWorkerConnection }
{ connection: this.redisWorkerConnection }
)
}
async onApplicationPrepareShutdown() {
// Close worker gracefully, i.e. wait for the current jobs to finish
await this.worker.close()
}
async onApplicationShutdown() {
await this.queue.close()
}
setWorkflowOrchestratorService(workflowOrchestratorService) {
this.workflowOrchestratorService_ = workflowOrchestratorService
}