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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-License-Identifier: Apache-2.0
//! Portable idempotency receipt vocabulary.
use crateOperationId;
use ;
/// Default retention for completed receipts. Pending reservations do not expire.
pub const DEFAULT_RETENTION_SECS: i64 = 7 * 24 * 60 * 60;
/// Hash the caller's canonical request bytes for deduplication.
/// One persisted dedup entry. Identity is `(operation_id, verb)`.
/// Result of a dedup reservation call.
///
/// - [`DedupOutcome::Reserved`]: this id has not been seen, and the store
/// has atomically claimed the slot for the caller. The caller MUST
/// either complete the request or release the reservation. While
/// the reservation is held, concurrent identical requests see
/// [`DedupOutcome::InFlight`].
/// - [`DedupOutcome::Replay`]: a completed entry exists with a matching
/// body hash; the cached response is returned and the request must
/// *not* be re-executed.
/// - [`DedupOutcome::InFlight`]: a reservation for the same
/// `(operation_id, verb)` is currently held by another caller (with
/// the same body hash). The caller should surface a transient error
/// (`Status::aborted`) so the client can retry once the original
/// completes.
/// - [`DedupOutcome::Conflict`]: same id, different body. Caller should
/// surface a `FailedPrecondition` to the client.
/// Safe-to-report metadata for an existing op-id slot. This deliberately
/// omits cached response bytes; callers use it to explain conflicts without
/// leaking command output.