kf_protocol_message/kf_code_gen/
leader_and_isr.rs1use serde::{Deserialize, Serialize};
5
6use kf_protocol_api::ErrorCode;
7use kf_protocol_api::Request;
8
9use kf_protocol_derive::Decode;
10use kf_protocol_derive::Encode;
11use kf_protocol_derive::KfDefault;
12
13#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
18pub struct KfLeaderAndIsrRequest {
19 pub controller_id: i32,
21
22 pub controller_epoch: i32,
24
25 #[fluvio_kf(min_version = 2, ignorable)]
27 pub broker_epoch: i64,
28
29 #[fluvio_kf(min_version = 2)]
31 pub topic_states: Vec<LeaderAndIsrRequestTopicState>,
32
33 #[fluvio_kf(max_version = 1)]
35 pub partition_states_v0: Vec<LeaderAndIsrRequestPartitionStateV0>,
36
37 pub live_leaders: Vec<LeaderAndIsrLiveLeader>,
39}
40
41#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
42pub struct LeaderAndIsrRequestTopicState {
43 #[fluvio_kf(min_version = 2)]
45 pub name: String,
46
47 pub partition_states: Vec<LeaderAndIsrRequestPartitionState>,
49}
50
51#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
52pub struct LeaderAndIsrRequestPartitionStateV0 {
53 #[fluvio_kf(max_version = 1)]
55 pub topic_name: String,
56
57 #[fluvio_kf(max_version = 1)]
59 pub partition_index: i32,
60
61 #[fluvio_kf(max_version = 1)]
63 pub controller_epoch: i32,
64
65 #[fluvio_kf(max_version = 1)]
67 pub leader_key: i32,
68
69 #[fluvio_kf(max_version = 1)]
71 pub leader_epoch: i32,
72
73 #[fluvio_kf(max_version = 1)]
75 pub isr_replicas: Vec<i32>,
76
77 #[fluvio_kf(max_version = 1)]
79 pub zk_version: i32,
80
81 #[fluvio_kf(max_version = 1)]
83 pub replicas: Vec<i32>,
84
85 #[fluvio_kf(min_version = 1, max_version = 1, ignorable)]
87 pub is_new: bool,
88}
89
90#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
91pub struct LeaderAndIsrLiveLeader {
92 pub broker_id: i32,
94
95 pub host_name: String,
97
98 pub port: i32,
100}
101
102#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
103pub struct LeaderAndIsrRequestPartitionState {
104 pub partition_index: i32,
106
107 pub controller_epoch: i32,
109
110 pub leader_key: i32,
112
113 pub leader_epoch: i32,
115
116 pub isr_replicas: Vec<i32>,
118
119 pub zk_version: i32,
121
122 pub replicas: Vec<i32>,
124
125 #[fluvio_kf(min_version = 1, ignorable)]
127 pub is_new: bool,
128}
129
130#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
135pub struct KfLeaderAndIsrResponse {
136 pub error_code: ErrorCode,
138
139 pub partitions: Vec<LeaderAndIsrResponsePartition>,
141}
142
143#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
144pub struct LeaderAndIsrResponsePartition {
145 pub topic_name: String,
147
148 pub partition_index: i32,
150
151 pub error_code: ErrorCode,
153}
154
155impl Request for KfLeaderAndIsrRequest {
160 const API_KEY: u16 = 4;
161
162 const MIN_API_VERSION: i16 = 0;
163 const MAX_API_VERSION: i16 = 2;
164 const DEFAULT_API_VERSION: i16 = 2;
165
166 type Response = KfLeaderAndIsrResponse;
167}