feat(ql3): add cluster log retention authority

This commit is contained in:
whyour
2026-08-12 03:38:27 +08:00
parent 2bfa8ca279
commit 40628c843d
20 changed files with 1737 additions and 19 deletions
+8
View File
@@ -238,6 +238,9 @@
],
"run-attempt-log-retention": [
"dist/run/log-retention/runAttemptLogRetention.d.ts"
],
"cluster-run-attempt-log-retention": [
"dist/run/log-retention/clusterRunAttemptLogRetention.d.ts"
]
}
},
@@ -297,6 +300,11 @@
"require": "./dist/run/log-retention/runAttemptLogRetention.js",
"default": "./dist/run/log-retention/runAttemptLogRetention.js"
},
"./cluster-run-attempt-log-retention": {
"types": "./dist/run/log-retention/clusterRunAttemptLogRetention.d.ts",
"require": "./dist/run/log-retention/clusterRunAttemptLogRetention.js",
"default": "./dist/run/log-retention/clusterRunAttemptLogRetention.js"
},
"./task-definition": {
"types": "./dist/task-definition/taskDefinition.d.ts",
"require": "./dist/task-definition/taskDefinition.js",
@@ -0,0 +1,62 @@
import type {
RunAttemptLogRetentionCandidate,
RunAttemptLogRetentionStateReader,
RunAttemptLogRetirementRecord,
} from './runAttemptLogRetention';
export const MAX_CLUSTER_RUN_ATTEMPT_LOG_RETENTION_CLAIMS = 16;
export const MIN_CLUSTER_RUN_ATTEMPT_LOG_RETENTION_LEASE_MS = 5_000;
export const MAX_CLUSTER_RUN_ATTEMPT_LOG_RETENTION_LEASE_MS = 5 * 60_000;
export const MAX_CLUSTER_RUN_ATTEMPT_LOG_RETENTION_RETRY_DELAY_MS =
24 * 60 * 60_000;
export type ClusterRunAttemptLogRetentionFailureCode =
| 'artifact_unavailable'
| 'artifact_integrity_mismatch'
| 'retirement_record_unavailable';
export interface ClusterRunAttemptLogRetentionClaim {
readonly candidate: Readonly<RunAttemptLogRetentionCandidate>;
readonly eligibleAtMs: number;
readonly observedAtMs: number;
readonly ownerId: string;
readonly token: string;
readonly version: number;
readonly expiresAtMs: number;
readonly failureCount: number;
}
export interface ClusterRunAttemptLogRetentionClaimPage {
readonly claims: readonly Readonly<ClusterRunAttemptLogRetentionClaim>[];
readonly hasMore: boolean;
}
export type ClusterRunAttemptLogRetentionSettlement =
| Readonly<{
readonly status: 'retired';
readonly record: Readonly<RunAttemptLogRetirementRecord>;
}>
| Readonly<{
readonly status: 'retry';
readonly delayMs: number;
readonly failureCode: ClusterRunAttemptLogRetentionFailureCode;
}>
| Readonly<{
readonly status: 'manual';
readonly failureCode: ClusterRunAttemptLogRetentionFailureCode;
}>;
export interface ClusterRunAttemptLogRetentionClaimRepository
extends RunAttemptLogRetentionStateReader {
claim(options: Readonly<{
readonly ownerId: string;
readonly retentionMs: number;
readonly limit: number;
readonly leaseMs: number;
}>): Promise<Readonly<ClusterRunAttemptLogRetentionClaimPage>>;
settle(
claim: Readonly<ClusterRunAttemptLogRetentionClaim>,
settlement: Readonly<ClusterRunAttemptLogRetentionSettlement>,
): Promise<'settled' | 'fenced'>;
}