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
#![allow(clippy::assign_op_pattern)]
use std::fmt::Debug;
use std::marker::PhantomData;
use dataplane::core::{Encoder, Decoder};
use dataplane::api::{Request};
use fluvio_controlplane_metadata::store::Epoch;
use fluvio_controlplane_metadata::message::Message;
use crate::{AdminPublicApiKey, AdminSpec};
use crate::core::Spec;
use super::{Metadata, ObjectApiEnum};
ObjectApiEnum!(WatchRequest);
ObjectApiEnum!(WatchResponse);
#[derive(Debug, Encoder, Default, Decoder)]
pub struct WatchRequest<S: AdminSpec> {
epoch: Epoch,
data: PhantomData<S>,
}
impl Request for ObjectApiWatchRequest {
const API_KEY: u16 = AdminPublicApiKey::Watch as u16;
const DEFAULT_API_VERSION: i16 = 3;
type Response = ObjectApiWatchResponse;
}
#[derive(Debug, Default, Encoder, Decoder)]
pub struct WatchResponse<S: AdminSpec>
where
<S::WatchResponseType as Spec>::Status: Encoder + Decoder,
{
inner: MetadataUpdate<S::WatchResponseType>,
}
impl<S> WatchResponse<S>
where
S: AdminSpec,
<S::WatchResponseType as Spec>::Status: Encoder + Decoder,
{
pub fn new(inner: MetadataUpdate<S::WatchResponseType>) -> Self {
Self { inner }
}
pub fn inner(self) -> MetadataUpdate<S::WatchResponseType> {
self.inner
}
}
#[derive(Encoder, Decoder, Default, Clone, Debug)]
pub struct MetadataUpdate<S>
where
S: Spec + Encoder + Decoder,
S::Status: Encoder + Decoder + Debug,
{
pub epoch: Epoch,
pub changes: Vec<Message<Metadata<S>>>,
pub all: Vec<Metadata<S>>,
}
impl<S> MetadataUpdate<S>
where
S: Spec + Encoder + Decoder,
S::Status: Encoder + Decoder + Debug,
{
pub fn with_changes(epoch: i64, changes: Vec<Message<Metadata<S>>>) -> Self {
Self {
epoch,
changes,
all: vec![],
}
}
pub fn with_all(epoch: i64, all: Vec<Metadata<S>>) -> Self {
Self {
epoch,
changes: vec![],
all,
}
}
}