UNPKG

kafka-ts

Version:

**KafkaTS** is a Apache Kafka client library for Node.js. It provides both a low-level API for communicating directly with the Apache Kafka cluster and high-level APIs for publishing and subscribing to Kafka topics.

56 lines (55 loc) 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OFFSET_FETCH = void 0; const api_1 = require("../utils/api"); const error_1 = require("../utils/error"); exports.OFFSET_FETCH = (0, api_1.createApi)({ apiKey: 9, apiVersion: 8, request: (encoder, data) => encoder .writeUVarInt(0) .writeCompactArray(data.groups, (encoder, group) => encoder .writeCompactString(group.groupId) .writeCompactArray(group.topics, (encoder, topic) => encoder .writeCompactString(topic.name) .writeCompactArray(topic.partitionIndexes, (encoder, partitionIndex) => encoder.writeInt32(partitionIndex)) .writeUVarInt(0)) .writeUVarInt(0)) .writeBoolean(data.requireStable) .writeUVarInt(0), response: (decoder) => { const result = { _tag: decoder.readTagBuffer(), throttleTimeMs: decoder.readInt32(), groups: decoder.readCompactArray((decoder) => ({ groupId: decoder.readCompactString(), topics: decoder.readCompactArray((decoder) => ({ name: decoder.readCompactString(), partitions: decoder.readCompactArray((decoder) => ({ partitionIndex: decoder.readInt32(), committedOffset: decoder.readInt64(), committedLeaderEpoch: decoder.readInt32(), committedMetadata: decoder.readCompactString(), errorCode: decoder.readInt16(), _tag: decoder.readTagBuffer(), })), _tag: decoder.readTagBuffer(), })), errorCode: decoder.readInt16(), _tag: decoder.readTagBuffer(), })), _tag2: decoder.readTagBuffer(), }; result.groups.forEach((group) => { if (group.errorCode) throw new error_1.KafkaTSApiError(group.errorCode, null, result); group.topics.forEach((topic) => { topic.partitions.forEach((partition) => { if (partition.errorCode) throw new error_1.KafkaTSApiError(partition.errorCode, null, result); }); }); }); return result; }, });