mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-20 16:07:11 +08:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import type {
|
|
CancellationDispatchRecord,
|
|
CancellationDispatchResult,
|
|
} from '../domain/cancellationDispatch';
|
|
import type { RunEventRecord } from '../domain/run';
|
|
|
|
export interface ClaimCancellationDispatchCommand {
|
|
runId: string;
|
|
attemptId: string;
|
|
requestedAtMs: number;
|
|
owner: string;
|
|
leaseToken: string;
|
|
leaseDurationMs: number;
|
|
}
|
|
|
|
export type ClaimCancellationDispatchResult =
|
|
| {
|
|
status: 'claimed';
|
|
dispatch: CancellationDispatchRecord;
|
|
leaseToken: string;
|
|
}
|
|
| { status: 'not_eligible' }
|
|
| {
|
|
status: 'not_due' | 'leased' | 'dispatched' | 'blocked';
|
|
dispatch: CancellationDispatchRecord;
|
|
};
|
|
|
|
export interface RecordCancellationDispatchResultCommand {
|
|
runId: string;
|
|
attemptId: string;
|
|
owner: string;
|
|
leaseToken: string;
|
|
expectedVersion: number;
|
|
result: CancellationDispatchResult;
|
|
retryDelayMs?: number;
|
|
eventId: string;
|
|
}
|
|
|
|
export interface RecordCancellationDispatchResult {
|
|
dispatch: CancellationDispatchRecord;
|
|
event: RunEventRecord;
|
|
}
|
|
|
|
export interface CancellationDispatchRepository {
|
|
findByRunId(runId: string): Promise<CancellationDispatchRecord | null>;
|
|
claim(
|
|
command: ClaimCancellationDispatchCommand,
|
|
): Promise<ClaimCancellationDispatchResult>;
|
|
recordResult(
|
|
command: RecordCancellationDispatchResultCommand,
|
|
): Promise<RecordCancellationDispatchResult>;
|
|
}
|