chore(deps): consume alkcall 0.7.0 — CONNECTION_CLOSED maps 503
Dependency wave + one wire-surface behavior fix: - bump alkcall 0.6 -> 0.7 (gateway feature unchanged). No code change forced: this crate constructs no ServingConfig (the one 0.7.0 struct-literal break — from_wss keeps the pure-consumer from_connection; opt-in serving remains the review-006 Part C deferred decision), and the CF-006 per-call opener-identity overlay is behavior-only upstream (hub-forwarded WS-ferry opens now resolve the end client's identity, the intended effect) - gateway error table maps CONNECTION_CLOSED -> 503 Service Unavailable: alkcall 0.7.0's CF-007 amendment makes it the eighth protocol code (ADR-016's list is formal at eight); it previously fell to the catch-all 500, misreporting a retryable, provably-undelivered call as a permanent server failure. retryable: true, so the retry_after details path applies on 503. Tests pin the mapping and the Retry-After passthrough - ADR-023 amended: the protocol-code list is eight (ALREADY_EXISTS + CONNECTION_CLOSED rows added to the §3 table, normative rule and call.error code list updated); http-adapters.md six-code references de-staled Verification: cargo test (456 passed), cargo test --all-features (589 passed), clippy -D warnings (default + all-features), fmt --check, cargo doc --no-deps (0 warnings)
This commit is contained in:
1 parent
126fdec243
commit
dbaaa4ec8c
6 files changed
+80
-22
No files matched your search
+27
-3
@@ -4,9 +4,11 @@
|
||||
//! (`NOT_FOUND`, `FORBIDDEN`, `INVALID_INPUT`, `INVALID_OPERATION_TYPE`,
|
||||
//! `TIMEOUT`, `ALREADY_EXISTS` — the seventh code, alkcall ADR-022's
|
||||
//! `op/register` collision policy, mapped 409 Conflict, review-006
|
||||
//! UP-01) map to fixed statuses; operation-level codes imported from
|
||||
//! external HTTP APIs are prefixed `HTTP_<status>` and map to their
|
||||
//! declared status.
|
||||
//! UP-01; `CONNECTION_CLOSED` — the eighth code, alkcall ADR-016's
|
||||
//! retryable undelivered-call code, mapped 503 Service Unavailable,
|
||||
//! alkcall 0.7.0's CF-007 amendment made the list formal) map to fixed
|
||||
//! statuses; operation-level codes imported from external HTTP APIs are
|
||||
//! prefixed `HTTP_<status>` and map to their declared status.
|
||||
//!
|
||||
//! The identity-aware variant maps the ambiguous protocol codes
|
||||
//! (`FORBIDDEN`, `INVALID_OPERATION_TYPE`) to `401` when no token
|
||||
@@ -30,6 +32,7 @@ const PROTOCOL_CODE_INVALID_INPUT: &str = "INVALID_INPUT";
|
||||
const PROTOCOL_CODE_INVALID_OPERATION_TYPE: &str = "INVALID_OPERATION_TYPE";
|
||||
const PROTOCOL_CODE_TIMEOUT: &str = "TIMEOUT";
|
||||
const PROTOCOL_CODE_ALREADY_EXISTS: &str = "ALREADY_EXISTS";
|
||||
const PROTOCOL_CODE_CONNECTION_CLOSED: &str = "CONNECTION_CLOSED";
|
||||
const PROTOCOL_CODE_INTERNAL: &str = "INTERNAL";
|
||||
|
||||
const HTTP_PREFIX: &str = "HTTP_";
|
||||
@@ -40,6 +43,7 @@ const STATUS_FORBIDDEN: u16 = 403;
|
||||
const STATUS_UNPROCESSABLE: u16 = 422;
|
||||
const STATUS_TIMEOUT: u16 = 504;
|
||||
const STATUS_CONFLICT: u16 = 409;
|
||||
const STATUS_SERVICE_UNAVAILABLE: u16 = 503;
|
||||
const STATUS_INTERNAL: u16 = 500;
|
||||
|
||||
const RETRY_AFTER_STATUSES: &[u16] = &[429, 503];
|
||||
@@ -77,6 +81,7 @@ pub fn call_error_to_http_status_with_identity(
|
||||
}
|
||||
PROTOCOL_CODE_TIMEOUT => STATUS_TIMEOUT,
|
||||
PROTOCOL_CODE_ALREADY_EXISTS => STATUS_CONFLICT,
|
||||
PROTOCOL_CODE_CONNECTION_CLOSED => STATUS_SERVICE_UNAVAILABLE,
|
||||
PROTOCOL_CODE_INTERNAL => STATUS_INTERNAL,
|
||||
code if code.starts_with(HTTP_PREFIX) => code[HTTP_PREFIX.len()..]
|
||||
.parse::<u16>()
|
||||
@@ -193,6 +198,25 @@ mod tests {
|
||||
assert_eq!(call_error_to_http_status(&error), 409);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connection_closed_maps_to_503() {
|
||||
let error = CallError::connection_closed("undelivered");
|
||||
assert_eq!(call_error_to_http_status(&error), 503);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connection_closed_carries_retry_after_when_details_present() {
|
||||
let error = CallError::connection_closed("undelivered")
|
||||
.with_details(serde_json::json!({ "retry_after": "5" }));
|
||||
let resp = call_error_to_http_response(&error);
|
||||
assert_eq!(resp.status(), 503);
|
||||
let retry_after = resp
|
||||
.headers()
|
||||
.get(header::RETRY_AFTER)
|
||||
.map(|v| v.to_str().unwrap().to_string());
|
||||
assert_eq!(retry_after.as_deref(), Some("5"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn internal_maps_to_500() {
|
||||
let error = CallError::internal("boom");
|
||||
|
||||
Reference in new issue
Block a user