feat(kms): add operation timeout and typed retry policy engine (#5472)

This commit is contained in:
Zhengchao An
2026-07-30 19:20:17 +08:00
committed by GitHub
parent e86d4cb579
commit 6e5f330ff5
9 changed files with 735 additions and 12 deletions
+18
View File
@@ -90,6 +90,14 @@ pub enum KmsError {
/// Encryption context mismatch
#[error("Encryption context mismatch: {message}")]
ContextMismatch { message: String },
/// Backend operation exceeded its per-attempt timeout or total deadline
#[error("Operation timed out: {message}")]
OperationTimedOut { message: String },
/// Backend operation aborted by cancellation or shutdown
#[error("Operation cancelled: {message}")]
OperationCancelled { message: String },
}
impl KmsError {
@@ -187,6 +195,16 @@ impl KmsError {
pub fn context_mismatch<S: Into<String>>(message: S) -> Self {
Self::ContextMismatch { message: message.into() }
}
/// Create an operation timed out error
pub fn operation_timed_out<S: Into<String>>(message: S) -> Self {
Self::OperationTimedOut { message: message.into() }
}
/// Create an operation cancelled error
pub fn operation_cancelled<S: Into<String>>(message: S) -> Self {
Self::OperationCancelled { message: message.into() }
}
}
/// Convert from standard library errors