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
use trellis_core::{HostResourceStatus, ResourceKey, Revision, ScopeId, TransactionId};
/// Explicit host status event fed to tests after plan application.
pub type HostStatusEvent = HostResourceStatus;
/// Recorded classification for a host status event.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct HostStatusRecord {
/// Status supplied by the fake host.
pub status: HostStatusEvent,
/// Deterministic classification assigned by the ledger.
pub class: HostStatusClass,
/// Last command transaction known for this resource key, if any.
pub last_transaction_id: Option<TransactionId>,
/// Last command revision known for this resource key, if any.
pub last_command_revision: Option<Revision>,
}
/// Classification for host status delivery.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum HostStatusClass {
/// Status matches the current resource/scope/revision.
Current,
/// Status duplicates the last accepted status revision.
Duplicate,
/// Status targets an old command revision.
Stale,
/// Status targets a command revision newer than the ledger has observed.
Future,
/// Status targets a scope that no longer owns the resource.
Late,
}
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub(crate) struct HostStatusIdentity {
resource_key: ResourceKey,
scope: ScopeId,
command_revision: Revision,
status_revision: Revision,
}
impl From<&HostStatusEvent> for HostStatusIdentity {
fn from(status: &HostStatusEvent) -> Self {
Self {
resource_key: status.resource_key.clone(),
scope: status.scope,
command_revision: status.command_revision,
status_revision: status.status_revision,
}
}
}