Repository navigation
Expand file tree
/
Copy pathworkflow_queue_composition_root.ts
More file actions
36 lines (34 loc) · 1.88 KB
/
Copy pathworkflow_queue_composition_root.ts
File metadata and controls
36 lines (34 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { WaitForPreviousWorkflowRunsUseCase } from '../../application/usecases/workflow/wait_for_previous_workflow_runs_use_case';
import { ActivePreviousWorkflowRunsRepository } from '../../data/repository/workflow/active_previous_workflow_runs_repository';
import { TimerWorkflowPollingDelayAdapter } from '../time/timer_workflow_polling_delay_adapter';
import { LoggerWorkflowPollingObserverAdapter } from '../logging/logger_workflow_polling_observer_adapter';
import { SystemWorkflowQueueClockAdapter } from '../time/system_workflow_queue_clock_adapter';
import { SystemWorkflowPollingRandomAdapter } from '../time/system_workflow_polling_random_adapter';
import { NativeWorkflowCoordinationRepository } from '../../data/repository/workflow/native_workflow_coordination_repository';
import { getOctokitClient } from '../github/octokit_client_resolver';
import type { GithubWorkflowDefinitionClient, GithubWorkflowRunsClient } from '../github/ports/github_workflow_provider_ports';
export function createWaitForPreviousWorkflowRunsUseCase(token: string): WaitForPreviousWorkflowRunsUseCase {
const client = getOctokitClient<GithubWorkflowRunsClient & GithubWorkflowDefinitionClient>(token);
const delayPort = new TimerWorkflowPollingDelayAdapter();
const observerPort = new LoggerWorkflowPollingObserverAdapter();
const clock = new SystemWorkflowQueueClockAdapter();
const random = new SystemWorkflowPollingRandomAdapter();
return new WaitForPreviousWorkflowRunsUseCase(
new ActivePreviousWorkflowRunsRepository(
client,
delayPort,
undefined,
clock,
random,
observerPort,
),
delayPort,
observerPort,
undefined,
clock,
random,
new NativeWorkflowCoordinationRepository(client, {
delayPort, clock, random, observer: observerPort,
}),
);
}