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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use std::fmt::Debug;
use std::marker::PhantomData;
use crate::Isolation;
use crate::api::Request;
use crate::core::Decoder;
use crate::core::Encoder;
use crate::derive::Decode;
use crate::derive::Encode;
use crate::derive::FluvioDefault;
use crate::record::RecordSet;
use super::FetchResponse;
pub type DefaultFetchRequest = FetchRequest<RecordSet>;
#[derive(Encode, Decode, FluvioDefault, Debug)]
pub struct FetchRequest<R>
where
R: Encoder + Decoder + Default + Debug,
{
pub max_wait: i32,
pub min_bytes: i32,
#[fluvio(min_version = 3, ignorable)]
pub max_bytes: i32,
#[fluvio(min_version = 4)]
pub isolation_level: Isolation,
pub topics: Vec<FetchableTopic>,
#[fluvio(min_version = 7)]
pub forgotten: Vec<ForgottenTopic>,
pub data: PhantomData<R>,
}
impl<R> Request for FetchRequest<R>
where
R: Debug + Decoder + Encoder,
{
const API_KEY: u16 = 1;
const MIN_API_VERSION: i16 = 0;
const MAX_API_VERSION: i16 = 10;
const DEFAULT_API_VERSION: i16 = 10;
type Response = FetchResponse<R>;
}
#[derive(Encode, Decode, FluvioDefault, Debug)]
pub struct FetchableTopic {
pub name: String,
pub fetch_partitions: Vec<FetchPartition>,
}
#[derive(Encode, Decode, FluvioDefault, Debug)]
pub struct ForgottenTopic {
#[fluvio(min_version = 7)]
pub name: String,
#[fluvio(min_version = 7)]
pub forgotten_partition_indexes: Vec<i32>,
}
#[derive(Encode, Decode, FluvioDefault, Debug)]
pub struct FetchPartition {
pub partition_index: i32,
#[fluvio(min_version = 9, ignorable)]
pub current_leader_epoch: i32,
pub fetch_offset: i64,
#[fluvio(min_version = 5)]
pub log_start_offset: i64,
pub max_bytes: i32,
}
#[cfg(feature = "file")]
pub use file::*;
#[cfg(feature = "file")]
mod file {
use super::*;
use crate::record::FileRecordSet;
pub type FileFetchRequest = FetchRequest<FileRecordSet>;
}