refactor(core): Cache workflow ownership (#6738)
* refactor: Set up ownership service * refactor: Specify cache keys and values * refactor: Replace util with service calls * test: Mock service in tests * refactor: Use dependency injection * test: Write tests * refactor: Apply feedback from Omar and Micha * test: Fix tests * test: Fix missing spot * refactor: Return user entity from cache * refactor: More dependency injection!
This commit is contained in:
@@ -16,10 +16,10 @@ import type {
|
||||
IWorkflowExecutionDataProcess,
|
||||
} from '@/Interfaces';
|
||||
import { WorkflowRunner } from '@/WorkflowRunner';
|
||||
import { getWorkflowOwner } from '@/UserManagement/UserManagementHelper';
|
||||
import { recoverExecutionDataFromEventLogMessages } from './eventbus/MessageEventBus/recoverEvents';
|
||||
import { ExecutionRepository } from '@db/repositories';
|
||||
import type { ExecutionEntity } from '@db/entities/ExecutionEntity';
|
||||
import { OwnershipService } from './services/ownership.service';
|
||||
|
||||
@Service()
|
||||
export class WaitTracker {
|
||||
@@ -32,7 +32,10 @@ export class WaitTracker {
|
||||
|
||||
mainTimer: NodeJS.Timeout;
|
||||
|
||||
constructor(private executionRepository: ExecutionRepository) {
|
||||
constructor(
|
||||
private executionRepository: ExecutionRepository,
|
||||
private ownershipService: OwnershipService,
|
||||
) {
|
||||
// Poll every 60 seconds a list of upcoming executions
|
||||
this.mainTimer = setInterval(() => {
|
||||
void this.getWaitingExecutions();
|
||||
@@ -180,7 +183,8 @@ export class WaitTracker {
|
||||
if (!fullExecutionData.workflowData.id) {
|
||||
throw new Error('Only saved workflows can be resumed.');
|
||||
}
|
||||
const user = await getWorkflowOwner(fullExecutionData.workflowData.id);
|
||||
const workflowId = fullExecutionData.workflowData.id;
|
||||
const user = await this.ownershipService.getWorkflowOwnerCached(workflowId);
|
||||
|
||||
const data: IWorkflowExecutionDataProcess = {
|
||||
executionMode: fullExecutionData.mode,
|
||||
|
||||
Reference in New Issue
Block a user