kf-protocol-message 2.0.0

Rust kafka protocol message definition
Documentation
/// WARNING: CODE GENERATED FILE
/// * This file is generated by kfspec2code.
/// * Any changes applied to this file will be lost when a new spec is generated.
use serde::{Deserialize, Serialize};

use kf_protocol_api::ErrorCode;
use kf_protocol_api::Request;

use kf_protocol_derive::Decode;
use kf_protocol_derive::Encode;
use kf_protocol_derive::KfDefault;

// -----------------------------------
// KfOffsetCommitRequest
// -----------------------------------

#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct KfOffsetCommitRequest {
    /// The unique group identifier.
    pub group_id: String,

    /// The generation of the group.
    #[fluvio_kf(min_version = 1, ignorable)]
    pub generation_id: i32,

    /// The member ID assigned by the group coordinator.
    #[fluvio_kf(min_version = 1, ignorable)]
    pub member_id: String,

    /// The time period in ms to retain the offset.
    #[fluvio_kf(min_version = 2, max_version = 4, ignorable)]
    pub retention_time_ms: i64,

    /// The topics to commit offsets for.
    pub topics: Vec<OffsetCommitRequestTopic>,
}

#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct OffsetCommitRequestTopic {
    /// The topic name.
    pub name: String,

    /// Each partition to commit offsets for.
    pub partitions: Vec<OffsetCommitRequestPartition>,
}

#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct OffsetCommitRequestPartition {
    /// The partition index.
    pub partition_index: i32,

    /// The message offset to be committed.
    pub committed_offset: i64,

    /// The leader epoch of this partition.
    #[fluvio_kf(min_version = 6, ignorable)]
    pub committed_leader_epoch: i32,

    /// The timestamp of the commit.
    #[fluvio_kf(min_version = 1, max_version = 1)]
    pub commit_timestamp: i64,

    /// Any associated metadata the client wants to keep.
    pub committed_metadata: Option<String>,
}

// -----------------------------------
// KfOffsetCommitResponse
// -----------------------------------

#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct KfOffsetCommitResponse {
    /// The duration in milliseconds for which the request was throttled due to a quota violation,
    /// or zero if the request did not violate any quota.
    #[fluvio_kf(min_version = 3, ignorable)]
    pub throttle_time_ms: i32,

    /// The responses for each topic.
    pub topics: Vec<OffsetCommitResponseTopic>,
}

#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct OffsetCommitResponseTopic {
    /// The topic name.
    pub name: String,

    /// The responses for each partition in the topic.
    pub partitions: Vec<OffsetCommitResponsePartition>,
}

#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct OffsetCommitResponsePartition {
    /// The partition index.
    pub partition_index: i32,

    /// The error code, or 0 if there was no error.
    pub error_code: ErrorCode,
}

// -----------------------------------
// Implementation - KfOffsetCommitRequest
// -----------------------------------

impl Request for KfOffsetCommitRequest {
    const API_KEY: u16 = 8;

    const MIN_API_VERSION: i16 = 0;
    const MAX_API_VERSION: i16 = 6;
    const DEFAULT_API_VERSION: i16 = 6;

    type Response = KfOffsetCommitResponse;
}