fluvio_stream_model/
lib.rs1pub mod epoch;
2pub mod core;
3pub mod store;
4
5#[cfg(feature = "k8")]
7pub use k8_types;
8
9#[cfg(feature = "fixture")]
10pub mod fixture {
11
12 use std::fmt::Display;
13
14 use serde::{Serialize, Deserialize};
15
16 use crate::core::{Spec, Status, MetadataItem, MetadataContext, MetadataRevExtension};
17 use crate::store::MetadataStoreObject;
18 use crate::epoch::DualEpochMap;
19
20 #[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize)]
22 pub struct TestSpec {
23 pub replica: u16,
24 }
25
26 impl Spec for TestSpec {
27 const LABEL: &'static str = "Test";
28 type IndexKey = String;
29 type Owner = Self;
30 type Status = TestStatus;
31 }
32
33 #[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize)]
34 pub struct TestStatus {
35 pub up: bool,
36 }
37
38 impl Status for TestStatus {}
39
40 impl Display for TestStatus {
41 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 write!(f, "{}", self.up)
43 }
44 }
45
46 pub type DefaultTest = MetadataStoreObject<TestSpec, TestMeta>;
47
48 pub type TestEpochMap = DualEpochMap<String, DefaultTest>;
49
50 #[derive(Debug, Default, Eq, PartialEq, Clone)]
51 pub struct TestMeta {
52 pub rev: u32,
53 pub comment: String,
54 }
55
56 impl MetadataItem for TestMeta {
57 type UId = u32;
58
59 fn uid(&self) -> &Self::UId {
60 &self.rev
61 }
62
63 fn is_newer(&self, another: &Self) -> bool {
64 self.rev >= another.rev
65 }
66 }
67
68 impl MetadataRevExtension for TestMeta {
69 fn next_rev(&self) -> Self {
70 Self {
71 rev: self.rev + 1,
72 comment: self.comment.clone(),
73 }
74 }
75 }
76
77 impl TestMeta {
78 pub fn new(rev: u32) -> Self {
79 Self {
80 rev,
81 comment: "new".to_owned(),
82 }
83 }
84 }
85
86 impl From<u32> for MetadataContext<TestMeta> {
87 fn from(val: u32) -> MetadataContext<TestMeta> {
88 TestMeta::new(val).into()
89 }
90 }
91}