Checkpoint

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-02-04 20:43:59 +01:00
parent 4be36f9f19
commit 245617991c
5 changed files with 58 additions and 15 deletions
@@ -26,4 +26,5 @@ export type {
TaskEventType,
TaskState,
TaskStatus,
UpdateCheckpointOptions,
} from './types';
+27 -2
View File
@@ -31,7 +31,14 @@ export type TaskSecrets = Record<string, string> & {
*
* @public
*/
export type TaskState = Record<string, JsonObject>;
export type TaskState = {
[key: string]:
| { status: 'failed'; reason: string }
| {
status: 'success';
value: JsonObject;
};
};
/**
* The status of each step of the Task
@@ -108,6 +115,24 @@ export type TaskBrokerDispatchOptions = {
createdBy?: string;
};
/**
* The options passed to {@link TaskBroker.updateCheckpoint}
* Parameters to store the result of the executed checkpoint
*
* @public
*/
export type UpdateCheckpointOptions =
| {
key: string;
status: 'success';
value: JsonObject;
}
| {
key: string;
status: 'failed';
reason: string;
};
/**
* Task
*
@@ -126,7 +151,7 @@ export interface TaskContext {
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
updateCheckpoint?(key: string, value: JsonObject): Promise<void>;
updateCheckpoint?(options: UpdateCheckpointOptions): Promise<void>;
getWorkspaceName(): Promise<string>;
}