1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/// Default incoming request header carrying the client idempotency key.
pub const DEFAULT_IDEMPOTENCY_KEY_HEADER: &str = "idempotency-key";
/// Response header attached to every replayed idempotent response.
pub const HEADER_IDEMPOTENT_REPLAYED: &str = "idempotent-replayed";
/// Header value emitted on [`HEADER_IDEMPOTENT_REPLAYED`].
pub const HEADER_VALUE_REPLAYED_TRUE: &str = "true";
/// Context attribute key holding the active RAII in-flight guard between request and response hooks.
pub const ATTR_IDEMPOTENCY_GUARD: &str = "hyperlane_plugin_idempotency_guard";
/// Default cached response TTL in milliseconds (24 hours).
pub const DEFAULT_IDEMPOTENCY_TTL_MS: u64 = 86_400_000;
/// Default in-flight lock TTL in milliseconds (60 seconds).
pub const DEFAULT_IN_FLIGHT_TTL_MS: u64 = 60_000;
/// Default maximum distinct idempotency keys stored across all 64 shards.
pub const DEFAULT_IDEMPOTENCY_MAX_ENTRIES: usize = 65_536;
/// Default maximum total memory budget across all 64 shards (64 MiB).
pub const DEFAULT_IDEMPOTENCY_MAX_BYTES: usize = 64 * 1024 * 1024;
/// Default maximum individual response body length eligible for replay caching (4 MiB).
pub const DEFAULT_IDEMPOTENCY_MAX_BODY_BYTES: usize = 4 * 1024 * 1024;
/// Default maximum `Idempotency-Key` header byte length.
pub const DEFAULT_MAX_KEY_LEN: usize = 256;
/// Number of lock-striped shards in [`InMemoryIdempotencyStore`] (power of two).
pub const IDEMPOTENCY_SHARD_COUNT: usize = 64;
/// Default `Content-Type` header emitted on idempotency error responses (`400`/`409`/`422`).
pub const ERROR_CONTENT_TYPE: &str = "text/plain; charset=utf-8";
/// Prebuilt response body for `400 Bad Request` invalid or missing `Idempotency-Key`.
pub const BODY_BAD_KEY: & = b"Invalid or missing Idempotency-Key";
/// Prebuilt response body for `409 Conflict` when an identical key is currently executing.
pub const BODY_IN_FLIGHT: & = b"Request with this Idempotency-Key is in progress";
/// Prebuilt response body for `422 Unprocessable Entity` when key payload fingerprint mismatches.
pub const BODY_FINGERPRINT_MISMATCH: & =
b"Idempotency-Key reused with a different request payload";
/// `Retry-After` seconds value emitted on `409 Conflict` in-flight responses.
pub const IN_FLIGHT_RETRY_AFTER: &str = "1";
/// HTTP status code threshold above which responses are not cached for replay by default (`500`).
pub const NON_CACHEABLE_STATUS_MIN: usize = 500;
/// Domain separator byte mixed between method, path, and body during fingerprint hashing.
pub const FINGERPRINT_SEPARATOR: & = &;
/// Overhead constant in bytes charged per stored entry for memory accounting.
pub const ENTRY_OVERHEAD_BYTES: usize = 96;