kf_protocol_message/kf_code_gen/
update_metadata.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// KfUpdateMetadataRequest
15// -----------------------------------
16
17#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
18pub struct KfUpdateMetadataRequest {
19    /// The controller id.
20    pub controller_id: i32,
21
22    /// The controller epoch.
23    pub controller_epoch: i32,
24
25    /// The broker epoch.
26    #[fluvio_kf(min_version = 5, ignorable)]
27    pub broker_epoch: i64,
28
29    /// Each topic that we would like to update.
30    #[fluvio_kf(min_version = 5)]
31    pub topic_states: Vec<UpdateMetadataRequestTopicState>,
32
33    /// Each partition that we would like to update.
34    #[fluvio_kf(max_version = 4)]
35    pub partition_states_v0: Vec<UpdateMetadataRequestPartitionStateV0>,
36
37    pub brokers: Vec<UpdateMetadataRequestBroker>,
38}
39
40#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
41pub struct UpdateMetadataRequestTopicState {
42    /// The topic name.
43    pub topic_name: String,
44
45    /// The partition that we would like to update.
46    #[fluvio_kf(min_version = 5)]
47    pub partition_states: Vec<UpdateMetadataPartitionState>,
48}
49
50#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
51pub struct UpdateMetadataRequestPartitionStateV0 {
52    /// The topic name.
53    #[fluvio_kf(max_version = 4)]
54    pub topic_name: String,
55
56    /// The partition index.
57    #[fluvio_kf(max_version = 4)]
58    pub partition_index: i32,
59
60    /// The controller epoch.
61    #[fluvio_kf(max_version = 4)]
62    pub controller_epoch: i32,
63
64    /// The ID of the broker which is the current partition leader.
65    #[fluvio_kf(max_version = 4)]
66    pub leader: i32,
67
68    /// The leader epoch of this partition.
69    #[fluvio_kf(max_version = 4)]
70    pub leader_epoch: i32,
71
72    /// The brokers which are in the ISR for this partition.
73    #[fluvio_kf(max_version = 4)]
74    pub isr: Vec<i32>,
75
76    /// The Zookeeper version.
77    #[fluvio_kf(max_version = 4)]
78    pub zk_version: i32,
79
80    /// All the replicas of this partition.
81    #[fluvio_kf(max_version = 4)]
82    pub replicas: Vec<i32>,
83
84    /// The replicas of this partition which are offline.
85    #[fluvio_kf(min_version = 4, max_version = 4)]
86    pub offline_replicas: Vec<i32>,
87}
88
89#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
90pub struct UpdateMetadataRequestBroker {
91    pub id: i32,
92
93    /// The broker endpoints.
94    #[fluvio_kf(min_version = 1)]
95    pub endpoints: Vec<UpdateMetadataRequestEndpoint>,
96
97    /// The rack which this broker belongs to.
98    #[fluvio_kf(min_version = 2, ignorable)]
99    pub rack: Option<String>,
100}
101
102#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
103pub struct UpdateMetadataRequestEndpoint {
104    /// The port of this endpoint
105    #[fluvio_kf(min_version = 1)]
106    pub port: i32,
107
108    /// The hostname of this endpoint
109    #[fluvio_kf(min_version = 1)]
110    pub host: String,
111
112    /// The listener name.
113    #[fluvio_kf(min_version = 3)]
114    pub listener: String,
115
116    /// The security protocol type.
117    #[fluvio_kf(min_version = 1)]
118    pub security_protocol: i16,
119}
120
121#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
122pub struct UpdateMetadataPartitionState {
123    /// The partition index.
124    #[fluvio_kf(min_version = 5)]
125    pub partition_index: i32,
126
127    /// The controller epoch.
128    #[fluvio_kf(min_version = 5)]
129    pub controller_epoch: i32,
130
131    /// The ID of the broker which is the current partition leader.
132    #[fluvio_kf(min_version = 5)]
133    pub leader: i32,
134
135    /// The leader epoch of this partition.
136    #[fluvio_kf(min_version = 5)]
137    pub leader_epoch: i32,
138
139    /// The brokers which are in the ISR for this partition.
140    #[fluvio_kf(min_version = 5)]
141    pub isr: Vec<i32>,
142
143    /// The Zookeeper version.
144    #[fluvio_kf(min_version = 5)]
145    pub zk_version: i32,
146
147    /// All the replicas of this partition.
148    #[fluvio_kf(min_version = 5)]
149    pub replicas: Vec<i32>,
150
151    /// The replicas of this partition which are offline.
152    #[fluvio_kf(min_version = 5)]
153    pub offline_replicas: Vec<i32>,
154}
155
156// -----------------------------------
157// KfUpdateMetadataResponse
158// -----------------------------------
159
160#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
161pub struct KfUpdateMetadataResponse {
162    /// The error code, or 0 if there was no error.
163    pub error_code: ErrorCode,
164}
165
166// -----------------------------------
167// Implementation - KfUpdateMetadataRequest
168// -----------------------------------
169
170impl Request for KfUpdateMetadataRequest {
171    const API_KEY: u16 = 6;
172
173    const MIN_API_VERSION: i16 = 0;
174    const MAX_API_VERSION: i16 = 5;
175    const DEFAULT_API_VERSION: i16 = 5;
176
177    type Response = KfUpdateMetadataResponse;
178}