Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-02-10 14:34:14 +01:00
parent 491fba45df
commit 2b900fee6d
9 changed files with 274 additions and 101 deletions
@@ -26,5 +26,4 @@ export type {
TaskEventType,
TaskState,
TaskStatus,
CheckpointRecord,
} from './types';
+34 -21
View File
@@ -26,24 +26,6 @@ export type TaskSecrets = Record<string, string> & {
backstageToken?: string;
};
/**
* The record passed to TaskBroker for updating a checkpoint.
* Parameters to store the result of the executed checkpoint
*
* @public
*/
export type CheckpointRecord =
| {
key: string;
status: 'success';
value: JsonValue;
}
| {
key: string;
status: 'failed';
reason: string;
};
/**
* The state of all task's checkpoints
*
@@ -142,7 +124,14 @@ export interface TaskContext {
cancelSignal: AbortSignal;
spec: TaskSpec;
secrets?: TaskSecrets;
state?: TaskState;
state?: {
[key: string]:
| { status: 'failed'; reason: string }
| {
status: 'success';
value: JsonValue;
};
};
createdBy?: string;
done: boolean;
isDryRun?: boolean;
@@ -151,9 +140,33 @@ export interface TaskContext {
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
getCheckpoints?(): Promise<{ state: TaskState } | undefined>;
getTaskState?(): Promise<
| {
state: {
[key: string]:
| { status: 'failed'; reason: string }
| {
status: 'success';
value: JsonValue;
};
};
}
| undefined
>;
updateCheckpoint?(options: CheckpointRecord): Promise<void>;
updateCheckpoint?(
options:
| {
key: string;
status: 'success';
value: JsonValue;
}
| {
key: string;
status: 'failed';
reason: string;
},
): Promise<void>;
getWorkspaceName(): Promise<string>;
}