Skip to main content

encode_share_fetch_response

Function encode_share_fetch_response 

Source
pub fn encode_share_fetch_response(
    buf: &mut BytesMut,
    version: i16,
    topics: &[ShareFetchedTopic],
) -> Result<()>
Expand description

Encode a successful ShareFetch response (version 0–1).

v1 adds AcquisitionLockTimeoutMs after ErrorMessage. v0 omits it. Top-level ErrorCode is 0 on this helper (encode_share_fetch_response_with_error_code writes a non-zero code). ShareFetchedPartition::partition_response is Java ShareFetchResponse.partitionResponse (PartitionIndex and ErrorCode; crate encode writes CurrentLeader from the partition fields, JSON default 0/0, partition ErrorMessage from the partition fields, JSON default null, and v1 AcquisitionLockTimeoutMs 15000). NodeEndpoints stay empty (encode_share_fetch_response_with_endpoints writes a non-empty list). NodeEndpoints is JSON 0+ (untagged compact array, not Fetch v16 tagged field 0). CurrentLeader is JSON 0+ (untagged nested LeaderIdAndEpoch, not Fetch v12+ tagged field 1). Partition ErrorMessage is JSON 0+ (nullable compact STRING, not the top-level ErrorMessage). AcknowledgeErrorCode is JSON 0+ (not fetch ErrorCode). AcknowledgeErrorMessage is JSON 0+ (nullable compact STRING, not fetch ErrorMessage). ThrottleTimeMs is JSON 0+ (encode_share_fetch_response_with_throttle; this helper still writes 0). Top-level ErrorMessage is JSON 0+ (nullable compact STRING; encode_share_fetch_response_with_error_message; this helper still writes null). AcquisitionLockTimeoutMs is JSON 1+ (encode_share_fetch_response_with_acquisition_lock_timeout; this helper still writes 15000 on v1). Top-level ErrorCode is JSON 0+ (encode_share_fetch_response_with_error_code; this helper still writes 0). Records is JSON records (Kafka 4.0 nullableVersions 0+; Kafka 4.1 nullableVersions 0 only). This helper always writes empty as compact non-null (Java toMessage / MemoryRecords.EMPTY), not null.