kf_protocol_message/kf_code_gen/
leader_and_isr.rs

1/// WARNING: CODE GENERATED FILE
2/// * This file is generated by kfspec2code.
3/// * Any changes applied to this file will be lost when a new spec is generated.
4use 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// -----------------------------------
14// KfLeaderAndIsrRequest
15// -----------------------------------
16
17#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
18pub struct KfLeaderAndIsrRequest {
19    /// The current controller ID.
20    pub controller_id: i32,
21
22    /// The current controller epoch.
23    pub controller_epoch: i32,
24
25    /// The current broker epoch.
26    #[fluvio_kf(min_version = 2, ignorable)]
27    pub broker_epoch: i64,
28
29    /// Each topic.
30    #[fluvio_kf(min_version = 2)]
31    pub topic_states: Vec<LeaderAndIsrRequestTopicState>,
32
33    /// The state of each partition
34    #[fluvio_kf(max_version = 1)]
35    pub partition_states_v0: Vec<LeaderAndIsrRequestPartitionStateV0>,
36
37    /// The current live leaders.
38    pub live_leaders: Vec<LeaderAndIsrLiveLeader>,
39}
40
41#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
42pub struct LeaderAndIsrRequestTopicState {
43    /// The topic name.
44    #[fluvio_kf(min_version = 2)]
45    pub name: String,
46
47    /// The state of each partition
48    pub partition_states: Vec<LeaderAndIsrRequestPartitionState>,
49}
50
51#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
52pub struct LeaderAndIsrRequestPartitionStateV0 {
53    /// The topic name.
54    #[fluvio_kf(max_version = 1)]
55    pub topic_name: String,
56
57    /// The partition index.
58    #[fluvio_kf(max_version = 1)]
59    pub partition_index: i32,
60
61    /// The controller epoch.
62    #[fluvio_kf(max_version = 1)]
63    pub controller_epoch: i32,
64
65    /// The broker ID of the leader.
66    #[fluvio_kf(max_version = 1)]
67    pub leader_key: i32,
68
69    /// The leader epoch.
70    #[fluvio_kf(max_version = 1)]
71    pub leader_epoch: i32,
72
73    /// The in-sync replica IDs.
74    #[fluvio_kf(max_version = 1)]
75    pub isr_replicas: Vec<i32>,
76
77    /// The ZooKeeper version.
78    #[fluvio_kf(max_version = 1)]
79    pub zk_version: i32,
80
81    /// The replica IDs.
82    #[fluvio_kf(max_version = 1)]
83    pub replicas: Vec<i32>,
84
85    /// Whether the replica should have existed on the broker or not.
86    #[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    /// The leader's broker ID.
93    pub broker_id: i32,
94
95    /// The leader's hostname.
96    pub host_name: String,
97
98    /// The leader's port.
99    pub port: i32,
100}
101
102#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
103pub struct LeaderAndIsrRequestPartitionState {
104    /// The partition index.
105    pub partition_index: i32,
106
107    /// The controller epoch.
108    pub controller_epoch: i32,
109
110    /// The broker ID of the leader.
111    pub leader_key: i32,
112
113    /// The leader epoch.
114    pub leader_epoch: i32,
115
116    /// The in-sync replica IDs.
117    pub isr_replicas: Vec<i32>,
118
119    /// The ZooKeeper version.
120    pub zk_version: i32,
121
122    /// The replica IDs.
123    pub replicas: Vec<i32>,
124
125    /// Whether the replica should have existed on the broker or not.
126    #[fluvio_kf(min_version = 1, ignorable)]
127    pub is_new: bool,
128}
129
130// -----------------------------------
131// KfLeaderAndIsrResponse
132// -----------------------------------
133
134#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
135pub struct KfLeaderAndIsrResponse {
136    /// The error code, or 0 if there was no error.
137    pub error_code: ErrorCode,
138
139    /// Each partition.
140    pub partitions: Vec<LeaderAndIsrResponsePartition>,
141}
142
143#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
144pub struct LeaderAndIsrResponsePartition {
145    /// The topic name.
146    pub topic_name: String,
147
148    /// The partition index.
149    pub partition_index: i32,
150
151    /// The partition error code, or 0 if there was no error.
152    pub error_code: ErrorCode,
153}
154
155// -----------------------------------
156// Implementation - KfLeaderAndIsrRequest
157// -----------------------------------
158
159impl 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}