kf_protocol_message/kf_code_gen/
offset_fetch.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// KfOffsetFetchRequest
15// -----------------------------------
16
17#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
18pub struct KfOffsetFetchRequest {
19    /// The group to fetch offsets for.
20    pub group_id: String,
21
22    /// Each topic we would like to fetch offsets for, or null to fetch offsets for all topics.
23    pub topics: Option<Vec<OffsetFetchRequestTopic>>,
24}
25
26#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
27pub struct OffsetFetchRequestTopic {
28    pub name: String,
29
30    /// The partition indexes we would like to fetch offsets for.
31    pub partition_indexes: Vec<i32>,
32}
33
34// -----------------------------------
35// KfOffsetFetchResponse
36// -----------------------------------
37
38#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
39pub struct KfOffsetFetchResponse {
40    /// The duration in milliseconds for which the request was throttled due to a quota violation,
41    /// or zero if the request did not violate any quota.
42    #[fluvio_kf(min_version = 3, ignorable)]
43    pub throttle_time_ms: i32,
44
45    /// The responses per topic.
46    pub topics: Vec<OffsetFetchResponseTopic>,
47
48    /// The top-level error code, or 0 if there was no error.
49    #[fluvio_kf(min_version = 2)]
50    pub error_code: ErrorCode,
51}
52
53#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
54pub struct OffsetFetchResponseTopic {
55    /// The topic name.
56    pub name: String,
57
58    /// The responses per partition
59    pub partitions: Vec<OffsetFetchResponsePartition>,
60}
61
62#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
63pub struct OffsetFetchResponsePartition {
64    /// The partition index.
65    pub partition_index: i32,
66
67    /// The committed message offset.
68    pub committed_offset: i64,
69
70    /// The leader epoch.
71    #[fluvio_kf(min_version = 5)]
72    pub committed_leader_epoch: i32,
73
74    /// The partition metadata.
75    pub metadata: Option<String>,
76
77    /// The error code, or 0 if there was no error.
78    pub error_code: ErrorCode,
79}
80
81// -----------------------------------
82// Implementation - KfOffsetFetchRequest
83// -----------------------------------
84
85impl Request for KfOffsetFetchRequest {
86    const API_KEY: u16 = 9;
87
88    const MIN_API_VERSION: i16 = 0;
89    const MAX_API_VERSION: i16 = 5;
90    const DEFAULT_API_VERSION: i16 = 5;
91
92    type Response = KfOffsetFetchResponse;
93}