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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! Data-only effects emitted by the deterministic connection machine.
use calandria::Deadline;
use crate::{
ConnectionEpoch, Delivery, EffectId, MatchKey, OperationFailure, OperationId, OperationOutcome,
};
/// Why an epoch must close.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum CloseReason {
/// Accepted work drained after admission closed.
Drained,
/// The owner explicitly requested closure.
Requested,
/// A possibly-sent operation reached its deadline.
DeadlineAfterPossibleSend,
/// The transport reported loss of the connection.
TransportLost,
/// One exact nonblocking connection attempt failed before establishment.
ConnectFailed,
/// One exact nonblocking connection attempt exceeded its absolute deadline.
ConnectTimedOut,
/// A reply arrived when no operation could own it.
UnexpectedReply,
/// The adapter rejected a complete inbound frame as malformed.
MalformedReply,
/// A complete inbound frame exceeded its configured retained-byte bound.
InboundRetainedCapacity,
/// A reply key did not equal the wire-order front.
MatchKeyMismatch {
/// Match key required by the FIFO front.
expected: MatchKey,
/// Match key carried by the received reply.
received: MatchKey,
},
}
/// A capability action or terminal publication requested by core policy.
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ConnectionEffect<F = ()> {
/// Schedule the original absolute deadline.
ScheduleDeadline {
/// Owning epoch.
epoch: ConnectionEpoch,
/// Owning operation.
operation: OperationId,
/// Absolute, never-restarted deadline.
deadline: Deadline,
},
/// Remove a frame that never entered transport write ownership.
DiscardWrite {
/// Original write effect.
effect: EffectId,
/// Owning epoch.
epoch: ConnectionEpoch,
/// Owning operation.
operation: OperationId,
},
/// Remove the deadline owned by an operation.
CancelDeadline {
/// Owning epoch.
epoch: ConnectionEpoch,
/// Owning operation.
operation: OperationId,
},
/// Close the physical capability for this exact epoch.
CloseEpoch {
/// Epoch that must close.
epoch: ConnectionEpoch,
/// Mechanical closure reason.
reason: CloseReason,
},
/// Publish one terminal operation outcome outside the owner path.
PublishOutcome {
/// Owning epoch.
epoch: ConnectionEpoch,
/// Terminal operation.
operation: OperationId,
/// Mechanical terminal outcome, including an opaque matched reply when present.
outcome: OperationOutcome<F>,
},
}
impl<F> ConnectionEffect<F> {
pub(crate) fn failed(
epoch: ConnectionEpoch,
operation: OperationId,
failure: OperationFailure,
delivery: Delivery,
) -> Self {
Self::PublishOutcome {
epoch,
operation,
outcome: OperationOutcome::Failed { failure, delivery },
}
}
}