fluvio_dataplane_protocol/fetch/
request.rs1use std::fmt::Debug;
2use std::marker::PhantomData;
3
4use crate::Isolation;
5use crate::api::Request;
6
7use crate::core::Decoder;
8use crate::core::Encoder;
9use crate::derive::FluvioDefault;
10
11use crate::record::RecordSet;
12
13use super::FetchResponse;
14
15pub type DefaultFetchRequest = FetchRequest<RecordSet>;
16
17#[derive(Encoder, Decoder, FluvioDefault, Debug)]
18pub struct FetchRequest<R>
19where
20 R: Encoder + Decoder + Default + Debug,
21{
22 pub max_wait: i32,
24
25 pub min_bytes: i32,
27
28 #[fluvio(min_version = 3, ignorable)]
30 pub max_bytes: i32,
31
32 #[fluvio(min_version = 4)]
39 pub isolation_level: Isolation,
40
41 pub topics: Vec<FetchableTopic>,
43
44 #[fluvio(min_version = 7)]
46 pub forgotten: Vec<ForgottenTopic>,
47
48 pub data: PhantomData<R>,
49}
50
51impl<R> Request for FetchRequest<R>
52where
53 R: Debug + Decoder + Encoder,
54{
55 const API_KEY: u16 = 1;
56
57 const MIN_API_VERSION: i16 = 0;
58 const MAX_API_VERSION: i16 = 10;
59 const DEFAULT_API_VERSION: i16 = 10;
60
61 type Response = FetchResponse<R>;
62}
63
64#[derive(Encoder, Decoder, FluvioDefault, Debug)]
65pub struct FetchableTopic {
66 pub name: String,
68
69 pub fetch_partitions: Vec<FetchPartition>,
71}
72
73#[derive(Encoder, Decoder, FluvioDefault, Debug)]
74pub struct ForgottenTopic {
75 #[fluvio(min_version = 7)]
77 pub name: String,
78
79 #[fluvio(min_version = 7)]
81 pub forgotten_partition_indexes: Vec<i32>,
82}
83
84#[derive(Encoder, Decoder, FluvioDefault, Debug)]
85pub struct FetchPartition {
86 pub partition_index: i32,
88
89 #[fluvio(min_version = 9, ignorable)]
91 pub current_leader_epoch: i32,
92
93 pub fetch_offset: i64,
95
96 #[fluvio(min_version = 5)]
99 pub log_start_offset: i64,
100
101 pub max_bytes: i32,
104}
105
106#[cfg(feature = "file")]
107pub use file::*;
108#[cfg(feature = "file")]
109mod file {
110 use super::*;
111 use crate::record::FileRecordSet;
112 pub type FileFetchRequest = FetchRequest<FileRecordSet>;
113}