-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathevents.ts
More file actions
132 lines (104 loc) · 3.5 KB
/
Copy pathevents.ts
File metadata and controls
132 lines (104 loc) · 3.5 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { UUID } from '@openfn/lexicon';
import { Versions } from './types';
import { SerializedLogEvent } from './worker/events';
// If the worker thread exists a process safely, it'll return this error code
// any other error code is unexpected
export const HANDLED_EXIT_CODE = 111111;
// Top level API events - these are what the engine publishes externally
// should it just be start, log, job-start, job-complete, end etc?
// What about engine-level logging? CLI-level stuff?
export const WORKFLOW_START = 'workflow-start';
export const WORKFLOW_COMPLETE = 'workflow-complete';
export const WORKFLOW_ERROR = 'workflow-error';
export const JOB_START = 'job-start';
export const JOB_ERROR = 'job-error';
export const JOB_COMPLETE = 'job-complete';
export const COMPILE_START = 'compile-start';
export const COMPILE_COMPLETE = 'compile-complete';
// TODO To be fair this is just a log, not neccesarily a workflow log
// A log line may have a workflow and job id
export const WORKFLOW_LOG = 'workflow-log';
export const WORKFLOW_EDGE_RESOLVED = 'workflow-edge-resolved';
export const AUTOINSTALL_COMPLETE = 'autoinstall-complete';
export const AUTOINSTALL_ERROR = 'autoinstall-error';
export type EventMap = {
[WORKFLOW_START]: WorkflowStartPayload;
[WORKFLOW_COMPLETE]: WorkflowCompletePayload;
[JOB_START]: JobStartPayload;
[JOB_ERROR]: JobErrorPayload;
[JOB_COMPLETE]: JobCompletePayload;
[WORKFLOW_LOG]: WorkerLogPayload;
[WORKFLOW_ERROR]: WorkflowErrorPayload;
[AUTOINSTALL_COMPLETE]: AutoinstallCompletePayload;
[AUTOINSTALL_ERROR]: AutoinstallErrorPayload;
[COMPILE_START]: CompileStartPayload;
[COMPILE_COMPLETE]: CompileCompletePayload;
};
export type ExternalEvents = keyof EventMap;
interface ExternalEvent {
threadId?: string;
workflowId: UUID;
}
export interface WorkflowStartPayload extends ExternalEvent {
versions: Versions;
time: bigint;
}
export interface WorkflowCompletePayload extends ExternalEvent {
state: any;
duration: number;
time: bigint;
}
export interface WorkflowErrorPayload extends ExternalEvent {
type: string;
message: string;
severity: string;
// where the error originated; 'engine' generally, but OOM errors narrow
// this to the limit that was breached ('heap' or 'cgroup')
source?: string;
}
export interface JobStartPayload extends ExternalEvent {
jobId: string;
time: bigint;
}
export interface JobCompletePayload extends ExternalEvent {
jobId: string;
duration: number;
state: any; // the result state
next: string[]; // downstream jobs
time: bigint;
redacted?: boolean;
mem: {
job: number;
system: number;
};
}
export interface JobErrorPayload extends ExternalEvent {
jobId: string;
duration: number;
time: bigint;
state: any; // the result state
error: any;
next: string[]; // downstream jobs
}
export interface WorkerLogPayload extends ExternalEvent, SerializedLogEvent {
redacted?: boolean;
}
export interface EdgeResolvedPayload extends ExternalEvent {
edgeId: string; // interesting, we don't really have this yet. Is index more appropriate? key? yeah, it's target node basically
result: boolean;
}
export interface AutoinstallCompletePayload extends ExternalEvent {
module: string;
version: string;
duration: number;
}
export interface AutoinstallErrorPayload extends ExternalEvent {
module: string;
version: string;
duration: number;
message: string;
}
export interface CompileStartPayload extends ExternalEvent {}
export interface CompileCompletePayload extends ExternalEvent {
duration: number;
}