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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user