├── .vscode └── settings.json ├── LICENSE ├── README.md ├── docker-compose.yml ├── examples ├── example_consumer.ts ├── example_producer.ts └── prettyConsoleLogger2.ts ├── index.d.ts ├── index.ts ├── src ├── admin │ ├── index.ts │ └── instrumentationEvents.ts ├── broker │ ├── index.ts │ └── saslAuthenticator │ │ ├── awsIam.ts │ │ ├── index.ts │ │ ├── oauthBearer.ts │ │ ├── plain.ts │ │ ├── scram.ts │ │ ├── scram256.ts │ │ └── scram512.ts ├── cluster │ ├── brokerPool.ts │ ├── connectionBuilder.ts │ └── index.ts ├── constants.ts ├── consumer │ ├── assignerProtocol.ts │ ├── assigners │ │ ├── index.ts │ │ └── roundRobinAssigner │ │ │ └── index.ts │ ├── barrier.ts │ ├── batch.ts │ ├── consumerGroup.ts │ ├── filterAbortedMessages.ts │ ├── index.ts │ ├── instrumentationEvents.ts │ ├── offsetManager │ │ ├── index.ts │ │ ├── initializeConsumerOffsets.ts │ │ └── isInvalidOffset.ts │ ├── runner.ts │ ├── seekOffsets.ts │ └── subscriptionState.ts ├── env.ts ├── errors.ts ├── index.ts ├── instrumentation │ ├── emitter.ts │ ├── event.ts │ └── eventType.ts ├── loggers │ ├── console.ts │ └── index.ts ├── network │ ├── connection.ts │ ├── connectionStatus.ts │ ├── instrumentationEvents.ts │ ├── requestQueue │ │ ├── index.ts │ │ └── socketRequest.ts │ ├── socket.ts │ ├── socketClass.ts │ └── socketFactory.ts ├── producer │ ├── createTopicData.ts │ ├── eosManager │ │ ├── index.ts │ │ ├── transactionStateMachine.ts │ │ └── transactionStates.ts │ ├── groupMessagesPerPartition.ts │ ├── index.ts │ ├── instrumentationEvents.ts │ ├── messageProducer.ts │ ├── partitioners │ │ ├── default │ │ │ ├── index.ts │ │ │ ├── murmur2.ts │ │ │ ├── partitioner.ts │ │ │ └── randomBytes.ts │ │ ├── defaultJava │ │ │ ├── Test.java │ │ │ ├── index.ts │ │ │ └── murmur2.ts │ │ └── index.ts │ ├── responseSerializer.ts │ └── sendMessages.ts ├── protocol │ ├── aclOperationTypes.ts │ ├── aclPermissionTypes.ts │ ├── aclResourceTypes.ts │ ├── configResourceTypes.ts │ ├── configSource.ts │ ├── coordinatorTypes.ts │ ├── crc32.ts │ ├── decoder.ts │ ├── encoder.ts │ ├── error.ts │ ├── isolationLevel.ts │ ├── message │ │ ├── compression │ │ │ ├── gzip.ts │ │ │ └── index.ts │ │ ├── decoder.ts │ │ ├── index.ts │ │ ├── v0 │ │ │ ├── decoder.ts │ │ │ └── index.ts │ │ └── v1 │ │ │ ├── decoder.ts │ │ │ └── index.ts │ ├── messageSet │ │ ├── decoder.ts │ │ ├── fixtures │ │ │ ├── messages_v0_GZIP.json │ │ │ └── messages_v0_uncompressed.json.json │ │ └── index.ts │ ├── recordBatch │ │ ├── crc32C │ │ │ ├── crc32C.ts │ │ │ ├── fixtures │ │ │ │ ├── crcPayload.json │ │ │ │ └── samples.ts │ │ │ └── index.ts │ │ ├── fixtures │ │ │ ├── v0_record.json │ │ │ ├── v0_recordbatch.json │ │ │ └── v0_recordbatch_zstd.json │ │ ├── header │ │ │ └── v0 │ │ │ │ ├── decoder.ts │ │ │ │ └── index.ts │ │ ├── record │ │ │ └── v0 │ │ │ │ ├── decoder.ts │ │ │ │ └── index.ts │ │ └── v0 │ │ │ ├── decoder.ts │ │ │ └── index.ts │ ├── request.ts │ ├── requests │ │ ├── addOffsetsToTxn │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── addPartitionsToTxn │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── alterConfigs │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── apiKeys.ts │ │ ├── apiVersions │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_response.json │ │ │ │ └── v1_response_missing_throttle_time.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── createAcls │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── createPartitions │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── createTopics │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ └── v2_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── deleteAcls │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── deleteGroups │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── deleteRecords │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── deleteTopics │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── describeAcls │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── describeConfigs │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_request_broker_config.json │ │ │ │ ├── v0_request_topic_config.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v0_response_broker_config.json │ │ │ │ ├── v0_response_topic_config.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── describeGroups │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_memberAssignment.json │ │ │ │ ├── v1_memberMetadata.json │ │ │ │ ├── v1_request.json │ │ │ │ └── v1_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── endTxn │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── fetch │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v0_response_gzip.json │ │ │ │ ├── v10_request.json │ │ │ │ ├── v10_response.json │ │ │ │ ├── v11_request.json │ │ │ │ ├── v11_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v1_response_gzip.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v2_response_gzip.json │ │ │ │ ├── v2_response_index_out_of_range.json │ │ │ │ ├── v2_response_partial_messages_many_partitions.json │ │ │ │ ├── v3_request.json │ │ │ │ ├── v3_response.json │ │ │ │ ├── v3_response_gzip.json │ │ │ │ ├── v4_from_scala_producer_response.json │ │ │ │ ├── v4_request.json │ │ │ │ ├── v4_response.json │ │ │ │ ├── v4_response_010_format.json │ │ │ │ ├── v4_response_gzip.json │ │ │ │ ├── v4_response_mixed_formats.json │ │ │ │ ├── v4_response_snappy.json │ │ │ │ ├── v5_request.json │ │ │ │ ├── v5_response.json │ │ │ │ ├── v6_request.json │ │ │ │ ├── v6_response.json │ │ │ │ ├── v7_request.json │ │ │ │ ├── v7_response.json │ │ │ │ ├── v8_request.json │ │ │ │ ├── v8_response.json │ │ │ │ ├── v9_request.json │ │ │ │ └── v9_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v10 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v11 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v4 │ │ │ │ ├── decodeMessages.ts │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v5 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v6 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v7 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v8 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v9 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── findCoordinator │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ └── v1_response_version_error.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── heartbeat │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v3_request.json │ │ │ │ └── v3_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── index.ts │ │ ├── initProducerId │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── joinGroup │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_assignerMetadata.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_assignerMetadata.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v5_request.json │ │ │ │ └── v5_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v4 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v5 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── leaveGroup │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v3_request.json │ │ │ │ └── v3_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── listGroups │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── listOffsets │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ └── v2_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── metadata │ │ │ ├── fixtures │ │ │ │ ├── v3_response.json │ │ │ │ ├── v4_response.json │ │ │ │ ├── v5_offline_replicas_response.json │ │ │ │ └── v5_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v4 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v5 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v6 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── offsetCommit │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_request_metadata.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_request_metadata.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_request_metadata.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v3_request.json │ │ │ │ ├── v3_request_metadata.json │ │ │ │ ├── v3_response.json │ │ │ │ ├── v4_request.json.json │ │ │ │ ├── v4_request_metadata.json │ │ │ │ ├── v4_response.json │ │ │ │ ├── v5_request.json │ │ │ │ ├── v5_request_metadata.json │ │ │ │ └── v5_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v4 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v5 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── offsetFetch │ │ │ ├── fixtures │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v3_request.json │ │ │ │ └── v3_response.json │ │ │ ├── index.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v4 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── produce │ │ │ ├── fixtures │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_request_gzip_darwin.json │ │ │ │ ├── v2_request_gzip_linux.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v2_response_gzip.json │ │ │ │ ├── v3_request.json │ │ │ │ ├── v3_response.json │ │ │ │ ├── v4_request.json │ │ │ │ ├── v4_response.json │ │ │ │ ├── v5_request.json │ │ │ │ ├── v5_response.json │ │ │ │ ├── v6_request.json │ │ │ │ ├── v6_response.json │ │ │ │ ├── v7_request.json │ │ │ │ └── v7_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v4 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v5 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v6 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v7 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── saslAuthenticate │ │ │ ├── fixtures │ │ │ │ ├── plain_bytes.json │ │ │ │ ├── scram256_bytes.json │ │ │ │ ├── scram256_firstRequest_response.json │ │ │ │ ├── scram256_firstRequest_response_v1.json │ │ │ │ ├── v0_request_plain.json │ │ │ │ ├── v0_request_scram256.json │ │ │ │ ├── v0_response_plain.json │ │ │ │ ├── v0_response_scram256.json │ │ │ │ ├── v1_response_plain.json │ │ │ │ └── v1_response_scram256.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── saslHandshake │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ ├── syncGroup │ │ │ ├── fixtures │ │ │ │ ├── v0_request.json │ │ │ │ ├── v0_response.json │ │ │ │ ├── v0_response_empty_member_assignment.json │ │ │ │ ├── v1_memberAssignment.json │ │ │ │ ├── v1_request.json │ │ │ │ ├── v1_response.json │ │ │ │ ├── v2_request.json │ │ │ │ ├── v2_response.json │ │ │ │ ├── v3_request.json │ │ │ │ └── v3_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v1 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ ├── v2 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ │ └── v3 │ │ │ │ ├── request.ts │ │ │ │ └── response.ts │ │ └── txnOffsetCommit │ │ │ ├── fixtures │ │ │ ├── v0_request.json │ │ │ └── v0_response.json │ │ │ ├── index.ts │ │ │ ├── v0 │ │ │ ├── request.ts │ │ │ └── response.ts │ │ │ └── v1 │ │ │ ├── request.ts │ │ │ └── response.ts │ ├── resourcePatternTypes.ts │ ├── resourceTypes.ts │ ├── sasl │ │ ├── awsIam │ │ │ ├── index.ts │ │ │ ├── request.ts │ │ │ └── response.ts │ │ ├── oauthBearer │ │ │ ├── index.ts │ │ │ ├── request.ts │ │ │ └── response.ts │ │ ├── plain │ │ │ ├── index.ts │ │ │ ├── request.ts │ │ │ └── response.ts │ │ └── scram │ │ │ ├── finalMessage │ │ │ ├── request.ts │ │ │ └── response.ts │ │ │ ├── firstMessage │ │ │ ├── fixtures │ │ │ │ └── response.json │ │ │ ├── request.ts │ │ │ └── response.ts │ │ │ └── index.ts │ └── timestampTypes.ts ├── retry │ ├── defaults.ts │ └── index.ts ├── testHelpers │ ├── certs │ │ ├── ca-cert.srl │ │ ├── ca-key │ │ ├── cert-file │ │ ├── cert-signed │ │ ├── kafka.server.keystore.jks │ │ ├── kafka.server.truststore.jks │ │ ├── keystore_creds │ │ ├── sslkey_creds │ │ └── truststore_creds │ ├── index.ts │ ├── kafka │ │ ├── log4j.properties │ │ ├── server-jaas.conf │ │ └── server-jaas_oauth.conf │ └── setup.ts ├── testing │ └── producer.test.ts └── utils │ ├── arrayDiff.ts │ ├── bufferedAsyncIterator.ts │ ├── concurrency.ts │ ├── flatten.ts │ ├── groupBy.ts │ ├── lock.ts │ ├── long.ts │ ├── promisify.ts │ ├── sharedPromiseTo.ts │ ├── shuffle.ts │ ├── sleep.ts │ ├── swapObject.ts │ ├── waitFor.ts │ └── websiteUrl.ts └── static_images ├── 03365-glow.png └── sirdeno-modified.png /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.suggest.imports.hosts": { 3 | "https://deno.land": true 4 | }, 5 | "deno.enable": true, 6 | "deno.lint": true, 7 | "deno.unstable": true 8 | } 9 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | zookeeper: 4 | image: wurstmeister/zookeeper:latest 5 | ports: 6 | - "2181:2181" 7 | kafka: 8 | image: wurstmeister/kafka:2.11-1.1.1 9 | ports: 10 | - "9092:9092" 11 | links: 12 | - zookeeper 13 | environment: 14 | KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1 15 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 16 | KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true' 17 | KAFKA_DELETE_TOPIC_ENABLE: 'true' 18 | KAFKA_CREATE_TOPICS: "topic-test:1:1" 19 | volumes: 20 | - /var/run/docker.sock:/var/run/docker.sock -------------------------------------------------------------------------------- /src/broker/saslAuthenticator/scram256.ts: -------------------------------------------------------------------------------- 1 | import { SCRAM,DIGESTS } from './scram.ts'; 2 | 3 | export class SCRAM256Authenticator extends SCRAM { 4 | constructor(connection: any, logger: any, saslAuthenticate: any) { 5 | super(connection, logger.namespace('SCRAM256Authenticator'), saslAuthenticate, DIGESTS.SHA256) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/broker/saslAuthenticator/scram512.ts: -------------------------------------------------------------------------------- 1 | import { SCRAM,DIGESTS } from './scram.ts'; 2 | 3 | export class SCRAM512Authenticator extends SCRAM { 4 | constructor(connection: any, logger: any, saslAuthenticate: any) { 5 | super(connection, logger.namespace('SCRAM512Authenticator'), saslAuthenticate, DIGESTS.SHA512) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | const EARLIEST_OFFSET = -2 2 | const LATEST_OFFSET = -1 3 | const INT_32_MAX_VALUE = Math.pow(2, 32) 4 | 5 | 6 | 7 | export default { 8 | 9 | EARLIEST_OFFSET, 10 | LATEST_OFFSET, 11 | INT_32_MAX_VALUE, 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/consumer/assigners/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import roundRobin from './roundRobinAssigner/index.ts'; 4 | 5 | export { 6 | roundRobin, 7 | }; 8 | -------------------------------------------------------------------------------- /src/consumer/barrier.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @template T 3 | * @return {{lock: Promise, unlock: (v?: T) => void, unlockWithError: (e: Error) => void}} 4 | */ 5 | 6 | export default () => { 7 | 8 | let unlock 9 | let unlockWithError 10 | const lock = new Promise((resolve: any) => { 11 | unlock = resolve 12 | unlockWithError = resolve 13 | }) 14 | 15 | return { lock, unlock, unlockWithError } 16 | } 17 | -------------------------------------------------------------------------------- /src/consumer/offsetManager/isInvalidOffset.ts: -------------------------------------------------------------------------------- 1 | import Long from '../../utils/long.ts' 2 | 3 | export default (offset: any) => (!offset && offset !== 0) || Long.fromValue(offset).isNegative() 4 | -------------------------------------------------------------------------------- /src/consumer/seekOffsets.ts: -------------------------------------------------------------------------------- 1 | 2 | export class SeekOffsets{ 3 | constructor(private map: Map = new Map()){} 4 | 5 | delete: any; 6 | entries: any; 7 | keys: any; 8 | size: any; 9 | 10 | public set(topic: any, partition: any, offset: any) { 11 | this.map.set([topic, partition], offset) 12 | 13 | } 14 | 15 | public has(topic: any, partition: any) { 16 | return Array.from(this.map.keys()).some(([t, p]) => t === topic && p === partition) 17 | } 18 | 19 | public pop() { 20 | if (this.map.size === 0) { 21 | return 22 | } 23 | 24 | const [key, offset] = this.map.entries().next().value 25 | this.map.delete(key) 26 | const [topic, partition] = key 27 | return { topic, partition, offset } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/env.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import process from 'https://deno.land/std@0.110.0/node/process.ts'; 3 | 4 | export default () => ({ 5 | KAFKAJS_DEBUG_PROTOCOL_BUFFERS: process.env.KAFKAJS_DEBUG_PROTOCOL_BUFFERS, 6 | KAFKAJS_DEBUG_EXTENDED_PROTOCOL_BUFFERS: 7 | process.env.KAFKAJS_DEBUG_EXTENDED_PROTOCOL_BUFFERS, 8 | }); 9 | -------------------------------------------------------------------------------- /src/instrumentation/event.ts: -------------------------------------------------------------------------------- 1 | let id = 0 2 | const nextId = () => { 3 | if (id === Number.MAX_VALUE) { 4 | id = 0 5 | } 6 | 7 | return id++ 8 | } 9 | 10 | export class InstrumentationEvent { 11 | id: any; 12 | payload: any; 13 | timestamp: any; 14 | type: any; 15 | /** 16 | * @param {String} type 17 | * @param {Object} payload 18 | */ 19 | constructor(type: any, payload: any) { 20 | this.id = nextId() 21 | this.type = type 22 | this.timestamp = Date.now() 23 | this.payload = payload 24 | } 25 | } 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/instrumentation/eventType.ts: -------------------------------------------------------------------------------- 1 | 2 | export default (namespace: any) => (type: any) => `${namespace}.${type}` 3 | 4 | -------------------------------------------------------------------------------- /src/loggers/console.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | //const { LEVELS: logLevel } = require('./index') 4 | import * as lvl from './index.ts'; 5 | const { LEVELS: logLevel } = lvl; 6 | 7 | export default () => 8 | ({ namespace, level, label, log }: any) => { 9 | const prefix = namespace ? `[${namespace}] ` : ''; 10 | const message = JSON.stringify( 11 | Object.assign({ level: label }, log, { 12 | message: `${prefix}${log.message}`, 13 | }) 14 | ); 15 | 16 | switch (level) { 17 | case logLevel.INFO: 18 | return console.info(message); 19 | case logLevel.ERROR: 20 | return console.error(message); 21 | case logLevel.WARN: 22 | return console.warn(message); 23 | case logLevel.DEBUG: 24 | return console.log(message); 25 | case logLevel.DEMO: 26 | return console.info(message) 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/network/connectionStatus.ts: -------------------------------------------------------------------------------- 1 | const CONNECTION_STATUS = { 2 | CONNECTED: 'connected', 3 | DISCONNECTING: 'disconnecting', 4 | DISCONNECTED: 'disconnected', 5 | } 6 | 7 | const CONNECTED_STATUS = [CONNECTION_STATUS.CONNECTED, CONNECTION_STATUS.DISCONNECTING] 8 | 9 | export { 10 | CONNECTION_STATUS, 11 | CONNECTED_STATUS, 12 | } 13 | -------------------------------------------------------------------------------- /src/network/instrumentationEvents.ts: -------------------------------------------------------------------------------- 1 | import InstrumentationEventType from '../instrumentation/eventType.ts' 2 | 3 | const eventType = InstrumentationEventType('network') 4 | 5 | export default { 6 | NETWORK_REQUEST: eventType('request'), 7 | NETWORK_REQUEST_TIMEOUT: eventType('request_timeout'), 8 | NETWORK_REQUEST_QUEUE_SIZE: eventType('request_queue_size'), 9 | } 10 | -------------------------------------------------------------------------------- /src/network/socket.ts: -------------------------------------------------------------------------------- 1 | //deno-lint-ignore-file no-explicit-any 2 | 3 | import { ISocketFactory } from '../../index.d.ts' 4 | 5 | interface SocketOptions { 6 | socketFactory: ISocketFactory 7 | host: string; 8 | port: number; 9 | ssl: any; 10 | onConnect: () => void; 11 | onData: (data: any) => void; 12 | onEnd: () => void; 13 | onError: (e: Error) => void; 14 | onTimeout: () => void; 15 | } 16 | 17 | export default ({ 18 | socketFactory, 19 | host, 20 | port, 21 | ssl, 22 | onConnect, 23 | onData, 24 | onEnd, 25 | onError, 26 | onTimeout 27 | }: SocketOptions) => { 28 | //create the socket 29 | const socket = socketFactory({ host, port, ssl, onConnect }) 30 | //assign events to functions 31 | socket.on('data', onData) 32 | socket.on('end', onEnd) 33 | socket.on('error', onError) 34 | socket.on('timeout', onTimeout) 35 | socket.on('connect', onConnect) 36 | //connect and return 37 | socket.connect() 38 | 39 | return socket 40 | } 41 | -------------------------------------------------------------------------------- /src/network/socketFactory.ts: -------------------------------------------------------------------------------- 1 | //returns a function that intializes a socket object that can be used in socket.ts 2 | /* 3 | TODO - in KafkaJS, this was used to check for SSL and switch between net and tls modules 4 | for socket creation. This is no longer necessary, however it would take a good amount 5 | of refactoring to completley remove this file. 6 | */ 7 | 8 | import { CustomSocket } from './socketClass.ts' 9 | 10 | export default () => { 11 | //deno-lint-ignore no-explicit-any 12 | return ({ host, port, ssl }: {host: string, port: number, ssl: any}) => { 13 | 14 | const socket = new CustomSocket({hostname: host, port: port, ssl: ssl}) 15 | 16 | return socket; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/producer/createTopicData.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | export default (topicDataForBroker: any) => { 4 | return topicDataForBroker.map( 5 | ({ 6 | topic, 7 | partitions, 8 | messagesPerPartition, 9 | sequencePerPartition, 10 | }: any) => ({ 11 | topic, 12 | partitions: partitions.map((partition: any) => ({ 13 | partition, 14 | firstSequence: sequencePerPartition[partition], 15 | messages: messagesPerPartition[partition], 16 | })), 17 | }) 18 | ); 19 | }; 20 | -------------------------------------------------------------------------------- /src/producer/eosManager/transactionStates.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | UNINITIALIZED: 'UNINITIALIZED', 3 | READY: 'READY', 4 | TRANSACTING: 'TRANSACTING', 5 | COMMITTING: 'COMMITTING', 6 | ABORTING: 'ABORTING', 7 | } 8 | -------------------------------------------------------------------------------- /src/producer/groupMessagesPerPartition.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | export default ({ topic, partitionMetadata, messages, partitioner }: any) => { 4 | if (partitionMetadata.length === 0) { 5 | return {}; 6 | } 7 | 8 | return messages.reduce((result: any, message: any) => { 9 | const partition = partitioner({ topic, partitionMetadata, message }); 10 | const current = result[partition] || []; 11 | return Object.assign(result, { [partition]: [...current, message] }); 12 | }, {}); 13 | }; 14 | -------------------------------------------------------------------------------- /src/producer/partitioners/default/index.ts: -------------------------------------------------------------------------------- 1 | import murmur2 from './murmur2.ts' 2 | import createDefaultPartitioner from './partitioner.ts' 3 | 4 | export default createDefaultPartitioner(murmur2) 5 | -------------------------------------------------------------------------------- /src/producer/partitioners/defaultJava/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import murmur2 from './murmur2.ts' 3 | import createDefaultPartitioner from '../default/partitioner.ts' 4 | 5 | export default createDefaultPartitioner(murmur2) 6 | -------------------------------------------------------------------------------- /src/producer/partitioners/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import DefaultPartitioner from './default/index.ts'; 4 | import JavaCompatiblePartitioner from './defaultJava/index.ts'; 5 | 6 | export default { 7 | DefaultPartitioner, 8 | JavaCompatiblePartitioner, 9 | }; 10 | -------------------------------------------------------------------------------- /src/producer/responseSerializer.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import flatten from '../utils/flatten.ts'; 4 | 5 | export default ({ topics }: any) => { 6 | const partitions = topics.map(({ topicName, partitions }: any) => 7 | partitions.map((partition: any) => ({ 8 | topicName, 9 | ...partition, 10 | })) 11 | ); 12 | 13 | return flatten(partitions); 14 | }; 15 | -------------------------------------------------------------------------------- /src/protocol/aclPermissionTypes.ts: -------------------------------------------------------------------------------- 1 | // From: 2 | // https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/acl/AclPermissionType.java/#L31 3 | 4 | /** 5 | * @typedef {number} ACLPermissionTypes 6 | * 7 | * Enum for Permission Types 8 | * @readonly 9 | * @enum {ACLPermissionTypes} 10 | */ 11 | export default { 12 | /** 13 | * Represents any AclPermissionType which this client cannot understand, 14 | * perhaps because this client is too old. 15 | */ 16 | UNKNOWN: 0, 17 | /** 18 | * In a filter, matches any AclPermissionType. 19 | */ 20 | ANY: 1, 21 | /** 22 | * Disallows access. 23 | */ 24 | DENY: 2, 25 | /** 26 | * Grants access. 27 | */ 28 | ALLOW: 3, 29 | } 30 | -------------------------------------------------------------------------------- /src/protocol/configResourceTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @see https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/config/ConfigResource.java 3 | */ 4 | export default { 5 | UNKNOWN: 0, 6 | TOPIC: 2, 7 | BROKER: 4, 8 | BROKER_LOGGER: 8, 9 | } 10 | -------------------------------------------------------------------------------- /src/protocol/configSource.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | * @see https://github.com/apache/kafka/blob/1f240ce1793cab09e1c4823e17436d2b030df2bc/clients/src/main/java/org/apache/kafka/common/requests/DescribeConfigsResponse.java#L115-L122 4 | */ 5 | 6 | export default { 7 | UNKNOWN: 0, 8 | TOPIC_CONFIG: 1, 9 | DYNAMIC_BROKER_CONFIG: 2, 10 | DYNAMIC_DEFAULT_BROKER_CONFIG: 3, 11 | STATIC_BROKER_CONFIG: 4, 12 | DEFAULT_CONFIG: 5, 13 | DYNAMIC_BROKER_LOGGER_CONFIG: 6, 14 | }; 15 | -------------------------------------------------------------------------------- /src/protocol/coordinatorTypes.ts: -------------------------------------------------------------------------------- 1 | // From: https://kafka.apache.org/protocol.html#The_Messages_FindCoordinator 2 | 3 | /** 4 | * @typedef {number} CoordinatorType 5 | * 6 | * Enum for the types of coordinator to find. 7 | * @enum {CoordinatorType} 8 | */ 9 | export default{ 10 | GROUP: 0, 11 | TRANSACTION: 1, 12 | } 13 | -------------------------------------------------------------------------------- /src/protocol/isolationLevel.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Enum for isolation levels 3 | * @readonly 4 | * @enum {number} 5 | */ 6 | export default { 7 | // Makes all records visible 8 | READ_UNCOMMITTED: 0, 9 | 10 | // non-transactional and COMMITTED transactional records are visible. It returns all data 11 | // from offsets smaller than the current LSO (last stable offset), and enables the inclusion of 12 | // the list of aborted transactions in the result, which allows consumers to discard ABORTED 13 | // transactional records 14 | READ_COMMITTED: 1, 15 | } 16 | -------------------------------------------------------------------------------- /src/protocol/message/compression/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { KafkaJSNotImplemented } from '../../../errors.ts'; 4 | import gzip from './gzip.ts'; 5 | 6 | const COMPRESSION_CODEC_MASK = 0x07; 7 | const Types = { 8 | None: 0, 9 | GZIP: 1, 10 | Snappy: 2, 11 | LZ4: 3, 12 | ZSTD: 4, 13 | }; 14 | 15 | const Codecs = { 16 | [Types.GZIP]: () => gzip, 17 | [Types.Snappy]: () => { 18 | throw new KafkaJSNotImplemented(); 19 | }, 20 | [Types.LZ4]: () => { 21 | throw new KafkaJSNotImplemented(); 22 | }, 23 | [Types.ZSTD]: () => { 24 | throw new KafkaJSNotImplemented(); 25 | }, 26 | }; 27 | 28 | const lookupCodec = (type: any) => (Codecs[type] ? Codecs[type]() : null); 29 | const lookupCodecByAttributes = (attributes: any) => { 30 | const codec = Codecs[attributes & COMPRESSION_CODEC_MASK]; 31 | return codec ? codec() : null; 32 | }; 33 | 34 | export default { 35 | Types, 36 | Codecs, 37 | lookupCodec, 38 | lookupCodecByAttributes, 39 | COMPRESSION_CODEC_MASK, 40 | }; 41 | -------------------------------------------------------------------------------- /src/protocol/message/index.ts: -------------------------------------------------------------------------------- 1 | import v0 from './v0/index.ts' 2 | import v1 from './v1/index.ts' 3 | 4 | const versions: Record = { 5 | 0: v0, 6 | 1: v1, 7 | } 8 | 9 | export default ({ version = 0 }) => versions[version] 10 | 11 | //export default versions[0] 12 | -------------------------------------------------------------------------------- /src/protocol/message/v0/decoder.ts: -------------------------------------------------------------------------------- 1 | import {Decoder} from '../../decoder.ts' 2 | 3 | export default (decoder: Decoder) => ({ 4 | attributes: decoder.readInt8(), 5 | key: decoder.readBytes(), 6 | value: decoder.readBytes() 7 | }) 8 | -------------------------------------------------------------------------------- /src/protocol/message/v1/decoder.ts: -------------------------------------------------------------------------------- 1 | import { Decoder } from '../../decoder.ts' 2 | 3 | export default(decoder: Decoder) => ({ 4 | attributes: decoder.readInt8(), 5 | timestamp: decoder.readInt64().toString(), 6 | key: decoder.readBytes(), 7 | value: decoder.readBytes() 8 | }) 9 | -------------------------------------------------------------------------------- /src/protocol/messageSet/fixtures/messages_v0_GZIP.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,107,0,0,0,0,0,0,0,2,0,0,0,95,127,17,25,62,0,1,255,255,255,255,0,0,0,81,31,139,8,0,0,0,0,0,0,0,99,96,128,3,121,118,173,69,193,96,22,107,118,106,165,174,1,144,193,83,156,159,155,170,91,150,152,83,154,10,230,131,0,35,72,233,247,238,200,54,132,82,67,52,165,134,80,165,76,32,165,182,18,193,59,16,74,141,208,148,26,1,0,35,174,26,230,129,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/messageSet/fixtures/messages_v0_uncompressed.json.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,129,0,0,0,0,0,0,0,0,0,0,0,31,7,42,162,83,0,0,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48,0,0,0,0,0,0,0,1,0,0,0,31,247,139,89,134,0,0,0,0,0,5,107,101,121,45,49,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,49,0,0,0,0,0,0,0,2,0,0,0,31,61,24,83,184,0,0,0,0,0,5,107,101,121,45,50,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/recordBatch/crc32C/fixtures/crcPayload.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,2,0,0,1,95,142,187,58,12,0,0,1,95,142,187,58,12,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,3,130,1,0,0,0,48,107,101,121,45,56,50,99,102,48,57,51,99,55,52,51,98,100,51,56,51,54,101,49,56,62,115,111,109,101,45,118,97,108,117,101,45,55,56,101,97,101,99,102,52,98,53,55,53,102,97,51,101,52,48,52,99,2,2,97,2,98,130,1,0,0,2,48,107,101,121,45,48,54,101,51,102,53,57,97,98,100,50,55,101,99,102,53,54,49,97,51,62,115,111,109,101,45,118,97,108,117,101,45,55,102,51,48,57,52,53,51,53,100,98,51,52,99,102,48,51,54,98,49,2,2,97,2,98,130,1,0,0,4,48,107,101,121,45,102,51,55,48,50,57,52,99,102,51,57,101,53,54,53,48,49,55,97,54,62,115,111,109,101,45,118,97,108,117,101,45,49,97,98,57,48,98,55,55,57,50,57,100,102,102,99,52,97,97,99,57,2,2,97,2,98]} 2 | -------------------------------------------------------------------------------- /src/protocol/recordBatch/crc32C/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import crc32C from './crc32C.ts' 3 | const unsigned = (value: any) => Uint32Array.from([value])[0] 4 | 5 | 6 | export default(buffer: any) => unsigned(crc32C(buffer)) 7 | -------------------------------------------------------------------------------- /src/protocol/recordBatch/fixtures/v0_record.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,10,107,101,121,45,48,24,115,111,109,101,45,118,97,108,117,101,45,48,2,24,104,101,97,100,101,114,45,107,101,121,45,48,28,104,101,97,100,101,114,45,118,97,108,117,101,45,48]} -------------------------------------------------------------------------------- /src/protocol/recordBatch/fixtures/v0_recordbatch.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,113,0,0,0,0,2,228,195,36,165,0,9,0,0,0,0,0,0,1,115,237,245,255,167,0,0,1,115,237,245,255,201,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,1,31,139,8,0,0,0,0,0,0,19,11,99,96,96,224,202,78,173,212,53,112,40,75,204,41,77,213,53,208,53,50,48,50,208,53,176,208,53,52,9,49,52,183,50,52,182,50,176,208,51,179,48,138,98,0,0,181,227,241,167,44,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/recordBatch/header/v0/decoder.ts: -------------------------------------------------------------------------------- 1 | export default (decoder: any) => ({ 2 | key: decoder.readVarIntString(), 3 | value: decoder.readVarIntBytes() 4 | }) 5 | -------------------------------------------------------------------------------- /src/protocol/recordBatch/header/v0/index.ts: -------------------------------------------------------------------------------- 1 | import { Encoder } from '../../../encoder.ts' 2 | 3 | /** 4 | * v0 5 | * Header => Key Value 6 | * Key => varInt|string 7 | * Value => varInt|bytes 8 | */ 9 | 10 | export default({ 11 | key, 12 | value 13 | }: any) => { 14 | return new Encoder().writeVarIntString(key).writeVarIntBytes(value) 15 | } 16 | -------------------------------------------------------------------------------- /src/protocol/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | // deno-lint-ignore-file no-explicit-any 3 | import { Encoder } from './encoder.ts'; 4 | 5 | export default async ({ 6 | correlationId, 7 | clientId, 8 | request: { apiKey, apiVersion, encode }, 9 | }: {correlationId: number; clientId: string; request: Record}) => { 10 | const payload = await encode(); 11 | const requestPayload = new Encoder() 12 | .writeInt16(apiKey) 13 | .writeInt16(apiVersion) 14 | .writeInt32(correlationId) 15 | .writeString(clientId) 16 | .writeEncoder(payload); 17 | 18 | return new Encoder() 19 | .writeInt32(requestPayload.size()) 20 | .writeEncoder(requestPayload); 21 | }; 22 | -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,21,116,101,115,116,45,116,114,97,110,115,97,99,116,105,111,110,97,108,45,105,100,0,0,0,0,0,0,3,233,0,0,0,6,102,111,111,98,97,114]} -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | 4 | import requestV1 from './v1/request.ts' 5 | import responseV1 from './v1/response.ts' 6 | 7 | const versions: any = { 8 | 0: ({ 9 | transactionalId, 10 | producerId, 11 | producerEpoch, 12 | groupId 13 | }: any) => { 14 | const request = requestV0 15 | const response =responseV0 16 | return { request: request({ transactionalId, producerId, producerEpoch, groupId }), response } 17 | }, 18 | 1: ({ 19 | transactionalId, 20 | producerId, 21 | producerEpoch, 22 | groupId 23 | }: any) => { 24 | const request = requestV1 25 | const response =responseV1 26 | return { request: request({ transactionalId, producerId, producerEpoch, groupId }), response } 27 | }, 28 | } 29 | 30 | export default { 31 | versions: Object.keys(versions), 32 | protocol: ({ 33 | version 34 | }: any) => versions[version], 35 | } 36 | -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/v0/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Encoder } from '../../../encoder.ts'; 4 | import apiKeys from '../../apiKeys.ts'; 5 | const apiKey = apiKeys.AddOffsetsToTxn; 6 | 7 | /** 8 | * AddOffsetsToTxn Request (Version: 0) => transactional_id producer_id producer_epoch group_id 9 | * transactional_id => STRING 10 | * producer_id => INT64 11 | * producer_epoch => INT16 12 | * group_id => STRING 13 | */ 14 | 15 | export default ({ 16 | transactionalId, 17 | producerId, 18 | producerEpoch, 19 | groupId, 20 | }: any) => ({ 21 | apiKey, 22 | apiVersion: 0, 23 | apiName: 'AddOffsetsToTxn', 24 | //deno-lint-ignore require-await 25 | encode: async () => { 26 | return new Encoder() 27 | .writeString(transactionalId) 28 | .writeInt64(producerId) 29 | .writeInt16(producerEpoch) 30 | .writeString(groupId); 31 | }, 32 | }); 33 | -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/v0/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {Decoder} from '../../../decoder.ts'; 4 | 5 | import { 6 | failure, 7 | createErrorFromCode, 8 | failIfVersionNotSupported, 9 | } from '../../../error.ts'; 10 | 11 | /** 12 | * AddOffsetsToTxn Response (Version: 0) => throttle_time_ms error_code 13 | * throttle_time_ms => INT32 14 | * error_code => INT16 15 | */ 16 | 17 | const decode = async (rawData: any) => { 18 | const decoder = new Decoder(rawData); 19 | const throttleTime = decoder.readInt32(); 20 | const errorCode = decoder.readInt16(); 21 | 22 | failIfVersionNotSupported(errorCode); 23 | 24 | return { 25 | throttleTime, 26 | errorCode, 27 | }; 28 | }; 29 | 30 | const parse = async (data: any) => { 31 | if (failure(data.errorCode)) { 32 | throw createErrorFromCode(data.errorCode); 33 | } 34 | 35 | return data; 36 | }; 37 | 38 | export default { decode, parse }; 39 | -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * AddOffsetsToTxn Request (Version: 1) => transactional_id producer_id producer_epoch group_id 7 | * transactional_id => STRING 8 | * producer_id => INT64 9 | * producer_epoch => INT16 10 | * group_id => STRING 11 | */ 12 | 13 | export default ({ transactionalId, producerId, producerEpoch, groupId }: any) => 14 | Object.assign( 15 | requestV0({ 16 | transactionalId, 17 | producerId, 18 | producerEpoch, 19 | groupId, 20 | }), 21 | { apiVersion: 1 } 22 | ); 23 | -------------------------------------------------------------------------------- /src/protocol/requests/addOffsetsToTxn/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts' 4 | 5 | const decodeV0 = response.decode 6 | const parse = response.parse 7 | 8 | 9 | /** 10 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 11 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 12 | * 13 | * AddOffsetsToTxn Response (Version: 1) => throttle_time_ms error_code 14 | * throttle_time_ms => INT32 15 | * error_code => INT16 16 | */ 17 | const decode = async (rawData: any) => { 18 | const decoded = await decodeV0(rawData); 19 | 20 | return { 21 | ...decoded, 22 | throttleTime: 0, 23 | clientSideThrottleTime: decoded.throttleTime, 24 | }; 25 | }; 26 | 27 | export default { 28 | decode, 29 | parse, 30 | }; 31 | -------------------------------------------------------------------------------- /src/protocol/requests/addPartitionsToTxn/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type": "Buffer","data": [0,21,116,101,115,116,45,116,114,97,110,115,97,99,116,105,111,110,97,108,45,105,100,0,0,0,0,0,0,3,233,0,0,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,4,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3]} -------------------------------------------------------------------------------- /src/protocol/requests/addPartitionsToTxn/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,102,54,98,97,98,57,55,56,98,100,99,97,48,57,52,54,56,56,101,51,45,51,55,48,49,53,45,99,97,52,102,55,97,100,52,45,53,100,99,99,45,52,98,98,57,45,57,56,53,51,45,98,49,101,52,99,52,101,100,55,56,97,55,0,0,0,2,0,0,0,1,0,0,0,0,0,2,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/addPartitionsToTxn/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import requestv0 from './v0/request.ts'; 3 | import responsev0 from './v0/response.ts'; 4 | import requestv1 from './v1/request.ts'; 5 | import responsev1 from './v1/response.ts'; 6 | 7 | const versions: any = { 8 | 0: ({ transactionalId, producerId, producerEpoch, topics }: any) => { 9 | const request = requestv0 10 | const response = responsev0 11 | return { 12 | request: request({ transactionalId, producerId, producerEpoch, topics }), 13 | response, 14 | }; 15 | }, 16 | 1: ({ transactionalId, producerId, producerEpoch, topics }: any) => { 17 | const request = requestv1 18 | const response = responsev1 19 | return { 20 | request: request({ transactionalId, producerId, producerEpoch, topics }), 21 | response, 22 | }; 23 | }, 24 | }; 25 | 26 | export default { 27 | versions: Object.keys(versions), 28 | protocol: ({ 29 | version, 30 | }: 31 | any) => versions[version], 32 | }; 33 | -------------------------------------------------------------------------------- /src/protocol/requests/addPartitionsToTxn/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * AddPartitionsToTxn Request (Version: 1) => transactional_id producer_id producer_epoch [topics] 7 | * transactional_id => STRING 8 | * producer_id => INT64 9 | * producer_epoch => INT16 10 | * topics => topic [partitions] 11 | * topic => STRING 12 | * partitions => INT32 13 | */ 14 | 15 | export default ({ transactionalId, producerId, producerEpoch, topics }: any) => 16 | Object.assign( 17 | requestV0({ 18 | transactionalId, 19 | producerId, 20 | producerEpoch, 21 | topics, 22 | }), 23 | { apiVersion: 1 } 24 | ); 25 | -------------------------------------------------------------------------------- /src/protocol/requests/addPartitionsToTxn/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | const decodeV0 = response.decode 5 | const parse = response.parse 6 | 7 | 8 | /** 9 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 10 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 11 | * 12 | * AddPartitionsToTxn Response (Version: 1) => throttle_time_ms [errors] 13 | * throttle_time_ms => INT32 14 | * errors => topic [partition_errors] 15 | * topic => STRING 16 | * partition_errors => partition error_code 17 | * partition => INT32 18 | * error_code => INT16 19 | */ 20 | const decode = async (rawData: any) => { 21 | const decoded = await decodeV0(rawData); 22 | 23 | return { 24 | ...decoded, 25 | throttleTime: 0, 26 | clientSideThrottleTime: decoded.throttleTime, 27 | }; 28 | }; 29 | 30 | export default { decode, parse }; 31 | -------------------------------------------------------------------------------- /src/protocol/requests/alterConfigs/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,100,55,102,97,57,50,99,48,51,49,55,55,100,56,55,53,55,51,98,49,45,51,56,48,55,54,45,50,49,51,54,52,102,54,54,45,56,54,49,51,45,52,55,101,48,45,98,50,55,51,45,98,99,57,100,101,51,57,55,53,49,53,101,0,0,0,1,0,14,99,108,101,97,110,117,112,46,112,111,108,105,99,121,0,7,99,111,109,112,97,99,116,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/alterConfigs/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,2,0,74,116,101,115,116,45,116,111,112,105,99,45,100,55,102,97,57,50,99,48,51,49,55,55,100,56,55,53,55,51,98,49,45,51,56,48,55,54,45,50,49,51,54,52,102,54,54,45,56,54,49,51,45,52,55,101,48,45,98,50,55,51,45,98,99,57,100,101,51,57,55,53,49,53,101]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/alterConfigs/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import requestV0 from './v0/request.ts' 3 | import responseV0 from './v0/response.ts' 4 | 5 | import requestV1 from './v1/request.ts' 6 | import responseV1 from './v1/response.ts' 7 | 8 | const versions: any = { 9 | 0: ({ resources, validateOnly }: any) => { 10 | const request = requestV0 11 | const response =responseV0 12 | return { request: request({ resources, validateOnly }), response }; 13 | }, 14 | 1: ({ resources, validateOnly }: any) => { 15 | const request = requestV1 16 | const response =responseV1 17 | return { request: request({ resources, validateOnly }), response }; 18 | }, 19 | }; 20 | 21 | export default { 22 | versions: Object.keys(versions), 23 | protocol: ({ 24 | version, 25 | }: 26 | any) => versions[version], 27 | }; 28 | -------------------------------------------------------------------------------- /src/protocol/requests/alterConfigs/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * AlterConfigs Request (Version: 1) => [resources] validate_only 7 | * resources => resource_type resource_name [config_entries] 8 | * resource_type => INT8 9 | * resource_name => STRING 10 | * config_entries => config_name config_value 11 | * config_name => STRING 12 | * config_value => NULLABLE_STRING 13 | * validate_only => BOOLEAN 14 | */ 15 | 16 | /** 17 | * @param {Array} resources An array of resources to change 18 | * @param {boolean} [validateOnly=false] 19 | */ 20 | export default ({ resources, validateOnly }: any) => 21 | Object.assign( 22 | requestV0({ 23 | resources, 24 | validateOnly, 25 | }), 26 | { apiVersion: 1 } 27 | ); 28 | -------------------------------------------------------------------------------- /src/protocol/requests/alterConfigs/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | 5 | const parse = response.parse 6 | const decodeV0 = response.decode 7 | 8 | /** 9 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 10 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 11 | * 12 | * AlterConfigs Response (Version: 1) => throttle_time_ms [resources] 13 | * throttle_time_ms => INT32 14 | * resources => error_code error_message resource_type resource_name 15 | * error_code => INT16 16 | * error_message => NULLABLE_STRING 17 | * resource_type => INT8 18 | * resource_name => STRING 19 | */ 20 | 21 | const decode = async (rawData: any) => { 22 | const decoded = await decodeV0(rawData); 23 | 24 | return { 25 | ...decoded, 26 | throttleTime: 0, 27 | clientSideThrottleTime: decoded.throttleTime, 28 | }; 29 | }; 30 | 31 | export default { decode, parse }; 32 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,21,0,0,0,0,0,2,0,1,0,0,0,3,0,2,0,0,0,1,0,3,0,0,0,2,0,4,0,0,0,0,0,5,0,0,0,0,0,6,0,0,0,3,0,7,0,1,0,1,0,8,0,0,0,2,0,9,0,0,0,2,0,10,0,0,0,0,0,11,0,0,0,1,0,12,0,0,0,0,0,13,0,0,0,0,0,14,0,0,0,0,0,15,0,0,0,0,0,16,0,0,0,0,0,17,0,0,0,0,0,18,0,0,0,0,0,19,0,0,0,1,0,20,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,34,0,0,0,0,0,3,0,1,0,0,0,5,0,2,0,0,0,2,0,3,0,0,0,4,0,4,0,0,0,0,0,5,0,0,0,0,0,6,0,0,0,3,0,7,0,1,0,1,0,8,0,0,0,3,0,9,0,0,0,3,0,10,0,0,0,1,0,11,0,0,0,2,0,12,0,0,0,1,0,13,0,0,0,1,0,14,0,0,0,1,0,15,0,0,0,1,0,16,0,0,0,1,0,17,0,0,0,0,0,18,0,0,0,1,0,19,0,0,0,2,0,20,0,0,0,1,0,21,0,0,0,0,0,22,0,0,0,0,0,23,0,0,0,0,0,24,0,0,0,0,0,25,0,0,0,0,0,26,0,0,0,0,0,27,0,0,0,0,0,28,0,0,0,0,0,29,0,0,0,0,0,30,0,0,0,0,0,31,0,0,0,0,0,32,0,0,0,0,0,33,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/fixtures/v1_response_missing_throttle_time.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,34,0,0,0,0,0,3,0,1,0,0,0,5,0,2,0,0,0,2,0,3,0,0,0,4,0,4,0,0,0,0,0,5,0,0,0,0,0,6,0,0,0,3,0,7,0,1,0,1,0,8,0,0,0,3,0,9,0,0,0,3,0,10,0,0,0,1,0,11,0,0,0,2,0,12,0,0,0,1,0,13,0,0,0,1,0,14,0,0,0,1,0,15,0,0,0,1,0,16,0,0,0,1,0,17,0,0,0,0,0,18,0,0,0,1,0,19,0,0,0,2,0,20,0,0,0,1,0,21,0,0,0,0,0,22,0,0,0,0,0,23,0,0,0,0,0,24,0,0,0,0,0,25,0,0,0,0,0,26,0,0,0,0,0,27,0,0,0,0,0,28,0,0,0,0,0,29,0,0,0,0,0,30,0,0,0,0,0,31,0,0,0,0,0,32,0,0,0,0,0,33,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/v0/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {Encoder} from '../../../encoder.ts'; 4 | import apiKeys from '../../apiKeys.ts'; 5 | const apiKey = apiKeys.ApiVersions; 6 | 7 | /** 8 | * ApiVersionRequest => ApiKeys 9 | */ 10 | 11 | export default () => ({ 12 | apiKey, 13 | apiVersion: 0, 14 | apiName: 'ApiVersions', 15 | encode: async () => new Encoder(), 16 | }); 17 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | // ApiVersions Request after v1 indicates the client can parse throttle_time_ms 6 | 7 | export default () => ({ ...requestV0(), apiVersion: 1 }); 8 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/v2/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | // ApiVersions Request after v1 indicates the client can parse throttle_time_ms 6 | 7 | export default () => ({ ...requestV0(), apiVersion: 2 }); 8 | -------------------------------------------------------------------------------- /src/protocol/requests/apiVersions/v2/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v1/response.ts'; 4 | 5 | /** 6 | * Starting in version 2, on quota violation, brokers send out responses before throttling. 7 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 8 | * 9 | * ApiVersions Response (Version: 2) => error_code [api_versions] throttle_time_ms 10 | * error_code => INT16 11 | * api_versions => api_key min_version max_version 12 | * api_key => INT16 13 | * min_version => INT16 14 | * max_version => INT16 15 | * throttle_time_ms => INT32 16 | */ 17 | const { parse }: any = response.parse; 18 | const decodeV1: any = response.decode; 19 | const decode = async (rawData: any) => { 20 | const decoded = await decodeV1(rawData); 21 | 22 | return { 23 | ...decoded, 24 | throttleTime: 0, 25 | clientSideThrottleTime: decoded.throttleTime, 26 | }; 27 | }; 28 | 29 | export default { decode, parse }; 30 | -------------------------------------------------------------------------------- /src/protocol/requests/createAcls/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,49,49,57,102,101,48,57,100,100,98,56,48,57,50,100,54,49,49,51,100,45,49,53,52,51,54,45,57,102,100,99,102,53,56,51,45,55,98,55,55,45,52,52,56,57,45,97,99,56,54,45,56,97,102,52,97,55,54,101,102,52,50,48,0,72,85,115,101,114,58,98,111,98,45,53,55,53,55,48,51,98,102,97,99,49,101,56,99,49,50,57,51,51,50,45,49,53,52,51,54,45,49,51,55,98,51,101,100,100,45,98,55,52,49,45,52,98,98,54,45,97,50,54,54,45,51,49,56,97,99,50,57,50,98,101,98,56,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/createAcls/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255]} -------------------------------------------------------------------------------- /src/protocol/requests/createAcls/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,51,57,50,56,53,48,100,100,54,100,55,97,53,100,53,98,49,57,99,101,45,49,52,52,55,50,45,52,97,50,49,54,57,99,49,45,52,55,56,52,45,52,55,49,55,45,98,50,100,49,45,57,49,56,57,98,100,102,98,56,51,50,50,3,0,72,85,115,101,114,58,98,111,98,45,52,51,51,48,52,48,55,57,52,54,53,56,53,48,54,55,100,50,98,50,45,49,52,52,55,50,45,50,57,48,52,52,52,54,97,45,52,56,56,99,45,52,101,52,48,45,56,100,50,52,45,99,100,55,102,55,53,56,100,101,55,49,51,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/createAcls/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255]} -------------------------------------------------------------------------------- /src/protocol/requests/createAcls/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | 4 | import requestV1 from './v1/request.ts' 5 | import responseV1 from './v1/response.ts' 6 | 7 | 8 | const versions: any = { 9 | 0: ({ 10 | creations 11 | }: any) => { 12 | 13 | const request = requestV0 14 | const response = responseV0 15 | return { request: request({ creations }), response } 16 | }, 17 | 1: ({ 18 | creations 19 | }: any) => { 20 | 21 | const request = requestV1 22 | const response = responseV1 23 | return { request: request({ creations }), response } 24 | }, 25 | } 26 | 27 | 28 | export default { 29 | versions: Object.keys(versions), 30 | protocol: ({ 31 | version 32 | }: any) => versions[version], 33 | } 34 | -------------------------------------------------------------------------------- /src/protocol/requests/createAcls/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | const { parse } = response 5 | //const { decode } = response 6 | const decodeV0 = response.decode 7 | 8 | /** 9 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 10 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 11 | * 12 | * CreateAcls Response (Version: 1) => throttle_time_ms [creation_responses] 13 | * throttle_time_ms => INT32 14 | * creation_responses => error_code error_message 15 | * error_code => INT16 16 | * error_message => NULLABLE_STRING 17 | */ 18 | 19 | const decode = async (rawData: any) => { 20 | const decoded = await decodeV0(rawData); 21 | 22 | return { 23 | ...decoded, 24 | throttleTime: 0, 25 | clientSideThrottleTime: decoded.throttleTime, 26 | }; 27 | }; 28 | 29 | export default { decode, parse }; 30 | -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,99,56,100,56,99,97,51,100,57,53,52,57,53,99,54,98,57,48,48,100,0,0,0,3,255,255,255,255,0,31,116,101,115,116,45,116,111,112,105,99,45,48,53,48,102,98,50,101,54,97,101,100,49,51,97,57,53,52,50,56,56,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,19,136,0]} -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,2,0,74,116,101,115,116,45,116,111,112,105,99,45,102,100,101,54,55,98,53,97,55,57,55,57,56,52,97,99,48,56,51,55,45,53,53,52,57,50,45,49,98,102,50,102,51,48,97,45,99,99,101,56,45,52,48,51,100,45,56,56,57,55,45,54,57,48,50,97,48,98,56,54,102,98,48,0,0,255,255,0,74,116,101,115,116,45,116,111,112,105,99,45,51,100,54,99,53,51,97,102,50,101,48,102,57,98,49,100,49,55,53,55,45,53,53,52,57,50,45,99,98,100,101,50,51,52,52,45,100,57,100,51,45,52,97,100,55,45,98,52,48,56,45,57,57,54,99,100,97,49,51,101,54,101,53,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,99,56,100,56,99,97,51,100,57,53,52,57,53,99,54,98,57,48,48,100,0,0,0,3,255,255,255,255,0,31,116,101,115,116,45,116,111,112,105,99,45,48,53,48,102,98,50,101,54,97,101,100,49,51,97,57,53,52,50,56,56,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,19,136,0]} -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,2,0,74,116,101,115,116,45,116,111,112,105,99,45,102,100,101,54,55,98,53,97,55,57,55,57,56,52,97,99,48,56,51,55,45,53,53,52,57,50,45,49,98,102,50,102,51,48,97,45,99,99,101,56,45,52,48,51,100,45,56,56,57,55,45,54,57,48,50,97,48,98,56,54,102,98,48,0,0,255,255,0,74,116,101,115,116,45,116,111,112,105,99,45,51,100,54,99,53,51,97,102,50,101,48,102,57,98,49,100,49,55,53,55,45,53,53,52,57,50,45,99,98,100,101,50,51,52,52,45,100,57,100,51,45,52,97,100,55,45,98,52,48,56,45,57,57,54,99,100,97,49,51,101,54,101,53,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | 4 | import requestV1 from './v1/request.ts' 5 | import responseV1 from './v1/response.ts' 6 | 7 | 8 | const versions: any = { 9 | 0: ({ 10 | topicPartitions, 11 | timeout, 12 | validateOnly 13 | }: any) => { 14 | const request = requestV0 15 | const response =responseV0 16 | return { request: request({ topicPartitions, timeout, validateOnly }), response } 17 | }, 18 | 1: ({ 19 | topicPartitions, 20 | validateOnly, 21 | timeout 22 | }: any) => { 23 | const request = requestV1 24 | const response =responseV1 25 | return { request: request({ topicPartitions, validateOnly, timeout }), response } 26 | }, 27 | } 28 | 29 | export default { 30 | versions: Object.keys(versions), 31 | protocol: ({ 32 | version 33 | }: any) => versions[version], 34 | } 35 | -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * CreatePartitions Request (Version: 1) => [topic_partitions] timeout validate_only 5 | * topic_partitions => topic new_partitions 6 | * topic => STRING 7 | * new_partitions => count [assignment] 8 | * count => INT32 9 | * assignment => ARRAY(INT32) 10 | * timeout => INT32 11 | * validate_only => BOOLEAN 12 | */ 13 | 14 | export default({ 15 | topicPartitions, 16 | validateOnly, 17 | timeout 18 | }: any) => 19 | Object.assign(requestV0({ topicPartitions, validateOnly, timeout }), { apiVersion: 1 }) 20 | -------------------------------------------------------------------------------- /src/protocol/requests/createPartitions/v1/response.ts: -------------------------------------------------------------------------------- 1 | 2 | import response from '../v0/response.ts' 3 | const parse = response.parse 4 | const decodeV0 = response.decode 5 | 6 | /** 7 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 8 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 9 | * 10 | * CreatePartitions Response (Version: 0) => throttle_time_ms [topic_errors] 11 | * throttle_time_ms => INT32 12 | * topic_errors => topic error_code error_message 13 | * topic => STRING 14 | * error_code => INT16 15 | * error_message => NULLABLE_STRING 16 | */ 17 | 18 | const decode = async (rawData: any) => { 19 | const decoded = await decodeV0(rawData) 20 | 21 | return { 22 | ...decoded, 23 | throttleTime: 0, 24 | clientSideThrottleTime: decoded.throttleTime, 25 | } 26 | } 27 | 28 | export default { 29 | decode, 30 | parse, 31 | } 32 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,99,56,100,56,99,97,51,100,57,53,52,57,53,99,54,98,57,48,48,100,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,31,116,101,115,116,45,116,111,112,105,99,45,48,53,48,102,98,50,101,54,97,101,100,49,51,97,57,53,52,50,56,56,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,19,136]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,99,56,100,56,99,97,51,100,57,53,52,57,53,99,54,98,57,48,48,100,0,0,0,31,116,101,115,116,45,116,111,112,105,99,45,48,53,48,102,98,50,101,54,97,101,100,49,51,97,57,53,52,50,56,56,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,99,56,100,56,99,97,51,100,57,53,52,57,53,99,54,98,57,48,48,100,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,31,116,101,115,116,45,116,111,112,105,99,45,48,53,48,102,98,50,101,54,97,101,100,49,51,97,57,53,52,50,56,56,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,19,136,1]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,56,97,98,101,57,55,100,52,49,50,100,102,55,54,98,52,100,101,98,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,74,116,101,115,116,45,116,111,112,105,99,45,102,100,101,54,55,98,53,97,55,57,55,57,56,52,97,99,48,56,51,55,45,53,53,52,57,50,45,49,98,102,50,102,51,48,97,45,99,99,101,56,45,52,48,51,100,45,56,56,57,55,45,54,57,48,50,97,48,98,56,54,102,98,48,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,74,116,101,115,116,45,116,111,112,105,99,45,51,100,54,99,53,51,97,102,50,101,48,102,57,98,49,100,49,55,53,55,45,53,53,52,57,50,45,99,98,100,101,50,51,52,52,45,100,57,100,51,45,52,97,100,55,45,98,52,48,56,45,57,57,54,99,100,97,49,51,101,54,101,53,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,19,136,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,2,0,74,116,101,115,116,45,116,111,112,105,99,45,102,100,101,54,55,98,53,97,55,57,55,57,56,52,97,99,48,56,51,55,45,53,53,52,57,50,45,49,98,102,50,102,51,48,97,45,99,99,101,56,45,52,48,51,100,45,56,56,57,55,45,54,57,48,50,97,48,98,56,54,102,98,48,0,0,255,255,0,74,116,101,115,116,45,116,111,112,105,99,45,51,100,54,99,53,51,97,102,50,101,48,102,57,98,49,100,49,55,53,55,45,53,53,52,57,50,45,99,98,100,101,50,51,52,52,45,100,57,100,51,45,52,97,100,55,45,98,52,48,56,45,57,57,54,99,100,97,49,51,101,54,101,53,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/v1/response.ts: -------------------------------------------------------------------------------- 1 | import {Decoder} from '../../../decoder.ts' 2 | import parse from '../v0/response.ts' 3 | 4 | 5 | 6 | /** 7 | * CreateTopics Response (Version: 1) => [topic_errors] 8 | * topic_errors => topic error_code error_message 9 | * topic => STRING 10 | * error_code => INT16 11 | * error_message => NULLABLE_STRING 12 | */ 13 | 14 | const topicNameComparator = (a: any, b: any) => a.topic.localeCompare(b.topic) 15 | 16 | const topicErrors = (decoder: any) => ({ 17 | topic: decoder.readString(), 18 | errorCode: decoder.readInt16(), 19 | errorMessage: decoder.readString() 20 | }) 21 | //deno-lint-ignore require-await 22 | const decode = async (rawData: any) => { 23 | const decoder = new Decoder(rawData) 24 | return { 25 | topicErrors: decoder.readArray(topicErrors).sort(topicNameComparator), 26 | } 27 | } 28 | 29 | export default { 30 | decode, 31 | parse 32 | } 33 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV1 from '../v1/request.ts' 2 | 3 | /** 4 | * CreateTopics Request (Version: 2) => [create_topic_requests] timeout validate_only 5 | * create_topic_requests => topic num_partitions replication_factor [replica_assignment] [config_entries] 6 | * topic => STRING 7 | * num_partitions => INT32 8 | * replication_factor => INT16 9 | * replica_assignment => partition [replicas] 10 | * partition => INT32 11 | * replicas => INT32 12 | * config_entries => config_name config_value 13 | * config_name => STRING 14 | * config_value => NULLABLE_STRING 15 | * timeout => INT32 16 | * validate_only => BOOLEAN 17 | */ 18 | 19 | export default ({ 20 | topics, 21 | validateOnly, 22 | timeout 23 | }: any) => 24 | Object.assign(requestV1({ topics, validateOnly, timeout }), { apiVersion: 2 }) 25 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/v3/request.ts: -------------------------------------------------------------------------------- 1 | 2 | import requestV2 from '../v2/request.ts' 3 | 4 | /** 5 | * CreateTopics Request (Version: 3) => [create_topic_requests] timeout validate_only 6 | * create_topic_requests => topic num_partitions replication_factor [replica_assignment] [config_entries] 7 | * topic => STRING 8 | * num_partitions => INT32 9 | * replication_factor => INT16 10 | * replica_assignment => partition [replicas] 11 | * partition => INT32 12 | * replicas => INT32 13 | * config_entries => config_name config_value 14 | * config_name => STRING 15 | * config_value => NULLABLE_STRING 16 | * timeout => INT32 17 | * validate_only => BOOLEAN 18 | */ 19 | 20 | export default({ 21 | topics, 22 | validateOnly, 23 | timeout 24 | }: any) => 25 | Object.assign(requestV2({ topics, validateOnly, timeout }), { apiVersion: 3 }) 26 | -------------------------------------------------------------------------------- /src/protocol/requests/createTopics/v3/response.ts: -------------------------------------------------------------------------------- 1 | 2 | import response from '../v2/response.ts' 3 | 4 | const parse = response.parse 5 | const decodeV2 = response.decode 6 | /** 7 | * Starting in version 3, on quota violation, brokers send out responses before throttling. 8 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 9 | * 10 | * CreateTopics Response (Version: 3) => throttle_time_ms [topic_errors] 11 | * throttle_time_ms => INT32 12 | * topic_errors => topic error_code error_message 13 | * topic => STRING 14 | * error_code => INT16 15 | * error_message => NULLABLE_STRING 16 | */ 17 | 18 | const decode = async (rawData: any) => { 19 | const decoded = await decodeV2(rawData) 20 | 21 | return { 22 | ...decoded, 23 | throttleTime: 0, 24 | clientSideThrottleTime: decoded.throttleTime, 25 | } 26 | } 27 | 28 | export default { 29 | decode, 30 | parse, 31 | } 32 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteAcls/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,55,56,100,53,57,57,101,57,100,55,56,97,52,100,97,54,56,53,97,101,45,50,49,51,56,49,45,101,56,102,51,57,102,48,55,45,55,100,49,57,45,52,54,55,55,45,97,101,99,98,45,98,100,48,102,55,51,49,102,49,101,50,56,0,72,85,115,101,114,58,98,111,98,45,99,100,56,56,53,54,99,102,52,102,50,51,102,101,49,57,56,57,57,99,45,50,49,51,56,49,45,99,50,48,98,54,51,52,48,45,98,57,53,99,45,52,51,49,100,45,57,50,51,55,45,50,102,49,53,101,51,49,48,102,98,97,55,0,1,42,1,3]} -------------------------------------------------------------------------------- /src/protocol/requests/deleteAcls/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,0,0,0,1,0,0,255,255,2,0,74,116,101,115,116,45,116,111,112,105,99,45,55,56,100,53,57,57,101,57,100,55,56,97,52,100,97,54,56,53,97,101,45,50,49,51,56,49,45,101,56,102,51,57,102,48,55,45,55,100,49,57,45,52,54,55,55,45,97,101,99,98,45,98,100,48,102,55,51,49,102,49,101,50,56,0,72,85,115,101,114,58,98,111,98,45,99,100,56,56,53,54,99,102,52,102,50,51,102,101,49,57,56,57,57,99,45,50,49,51,56,49,45,99,50,48,98,54,51,52,48,45,98,57,53,99,45,52,51,49,100,45,57,50,51,55,45,50,102,49,53,101,51,49,48,102,98,97,55,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/deleteAcls/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,48,48,48,98,48,102,97,57,48,48,56,102,57,50,48,98,99,54,56,52,45,50,48,56,50,54,45,54,98,99,102,53,55,57,101,45,101,56,56,50,45,52,55,98,56,45,57,53,56,54,45,101,55,55,56,53,56,56,102,57,101,55,56,3,0,72,85,115,101,114,58,98,111,98,45,53,49,102,101,49,53,100,57,102,99,49,99,53,97,51,98,101,53,102,50,45,50,48,56,50,54,45,102,99,102,49,50,56,51,48,45,98,53,97,49,45,52,55,55,97,45,56,97,99,57,45,56,54,54,97,52,48,56,56,50,55,51,97,0,1,42,1,3]} -------------------------------------------------------------------------------- /src/protocol/requests/deleteAcls/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,0,0,0,1,0,0,255,255,2,0,74,116,101,115,116,45,116,111,112,105,99,45,48,48,48,98,48,102,97,57,48,48,56,102,57,50,48,98,99,54,56,52,45,50,48,56,50,54,45,54,98,99,102,53,55,57,101,45,101,56,56,50,45,52,55,98,56,45,57,53,56,54,45,101,55,55,56,53,56,56,102,57,101,55,56,3,0,72,85,115,101,114,58,98,111,98,45,53,49,102,101,49,53,100,57,102,99,49,99,53,97,51,98,101,53,102,50,45,50,48,56,50,54,45,102,99,102,49,50,56,51,48,45,98,53,97,49,45,52,55,55,97,45,56,97,99,57,45,56,54,54,97,52,48,56,56,50,55,51,97,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/deleteAcls/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | 4 | import requestV1 from './v1/request.ts' 5 | import responseV1 from './v1/response.ts' 6 | 7 | const versions: any = { 8 | 0: ({ 9 | filters 10 | }: any) => { 11 | const request = requestV0 12 | const response =responseV0 13 | return { request: request({ filters }), response } 14 | }, 15 | 1: ({ 16 | filters 17 | }: any) => { 18 | const request = requestV1 19 | const response =responseV1 20 | return { request: request({ filters }), response } 21 | }, 22 | } 23 | 24 | export default{ 25 | versions: Object.keys(versions), 26 | protocol: ({ 27 | version 28 | }: any) => versions[version], 29 | } 30 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteGroups/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | 4 | import requestV1 from './v1/request.ts' 5 | import responseV1 from './v1/response.ts' 6 | 7 | const versions: any = { 8 | 0: (groupIds: any) => { 9 | const request = requestV0 10 | const response =responseV0 11 | return { request: request(groupIds), response } 12 | }, 13 | 1: (groupIds: any) => { 14 | const request = requestV1 15 | const response =responseV1 16 | return { request: request(groupIds), response } 17 | }, 18 | } 19 | 20 | export default{ 21 | versions: Object.keys(versions), 22 | protocol: ({ 23 | version 24 | }: any) => versions[version], 25 | } 26 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteGroups/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | const apiKey = apiKeys.DeleteGroups 4 | /** 5 | * DeleteGroups Request (Version: 0) => [groups_names] 6 | * groups_names => STRING 7 | */ 8 | 9 | /** 10 | */ 11 | export default (groupIds: any) => ({ 12 | apiKey, 13 | apiVersion: 0, 14 | apiName: 'DeleteGroups', 15 | //deno-lint-ignore require-await 16 | encode: async () => { 17 | return new Encoder().writeArray(groupIds.map(encodeGroups)) 18 | } 19 | }) 20 | 21 | const encodeGroups = (group: any) => { 22 | return new Encoder().writeString(group) 23 | } 24 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteGroups/v1/request.ts: -------------------------------------------------------------------------------- 1 | 2 | import requestV0 from '../v0/request.ts' 3 | 4 | /** 5 | * DeleteGroups Request (Version: 1) 6 | */ 7 | 8 | export default (groupIds: any) => Object.assign(requestV0(groupIds), { apiVersion: 1 }) 9 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteGroups/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | 5 | const parse = response.parse; 6 | const decodeV0 = response.decode; 7 | 8 | /** 9 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 10 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 11 | * 12 | * DeleteGroups Response (Version: 1) => throttle_time_ms [results] 13 | * throttle_time_ms => INT32 14 | * results => group_id error_code 15 | * group_id => STRING 16 | * error_code => INT16 17 | */ 18 | 19 | const decode = async (rawData: any) => { 20 | const decoded: any = await decodeV0(rawData); 21 | 22 | return { 23 | ...decoded, 24 | throttleTime: 0, 25 | clientSideThrottleTime: decoded.throttleTime, 26 | }; 27 | }; 28 | 29 | export default { 30 | decode, 31 | parse, 32 | }; 33 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteRecords/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,52,50,49,51,50,99,97,49,99,55,57,101,53,100,100,54,99,52,51,54,45,56,49,56,56,52,45,49,52,100,51,97,49,56,49,45,48,49,51,100,45,52,49,55,54,45,56,101,55,101,45,55,53,49,56,97,54,55,102,52,56,49,51,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,7,0,0,19,136]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteRecords/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,53,100,97,54,56,51,102,97,51,98,49,56,57,56,50,50,51,52,57,56,45,57,55,49,49,57,45,100,48,54,56,50,57,101,51,45,51,53,100,50,45,52,98,57,55,45,98,52,98,52,45,55,99,48,51,100,52,97,100,55,99,99,56,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,7,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteRecords/index.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | import requestV0 from './v0/request.ts' 4 | import responseV0 from './v0/response.ts' 5 | 6 | import requestV1 from './v1/request.ts' 7 | import responseV1 from './v1/response.ts' 8 | 9 | 10 | const versions: any = { 11 | 0: ({ 12 | topics, 13 | timeout 14 | }: any) => { 15 | const request = requestV0 16 | const response =responseV0 17 | return { request: request({ topics, timeout }), response: response({ topics }) } 18 | }, 19 | 1: ({ 20 | topics, 21 | timeout 22 | }: any) => { 23 | const request = requestV1 24 | const response =responseV1 25 | return { request: request({ topics, timeout }), response: response({ topics }) } 26 | }, 27 | } 28 | 29 | export default { 30 | versions: Object.keys(versions), 31 | protocol: ({ 32 | version 33 | }: any) => versions[version], 34 | } 35 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteRecords/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * DeleteRecords Request (Version: 1) => [topics] timeout_ms 5 | * topics => topic [partitions] 6 | * topic => STRING 7 | * partitions => partition offset 8 | * partition => INT32 9 | * offset => INT64 10 | * timeout => INT32 11 | */ 12 | export default({ 13 | topics, 14 | timeout 15 | }: any) => 16 | Object.assign(requestV0({ topics, timeout }), { apiVersion: 1 }) 17 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,53,102,56,48,50,56,51,99,97,56,97,49,101,52,54,100,50,50,55,51,0,31,116,101,115,116,45,116,111,112,105,99,45,51,52,54,51,49,53,52,52,98,56,100,98,49,100,49,50,54,51,98,57,0,0,19,136]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,31,116,101,115,116,45,116,111,112,105,99,45,98,98,57,56,56,54,101,98,56,53,57,55,56,54,99,101,54,52,54,100,0,0,0,31,116,101,115,116,45,116,111,112,105,99,45,100,52,49,52,49,54,54,48,49,98,52,50,50,52,50,57,100,98,55,56,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,2,0,74,116,101,115,116,45,116,111,112,105,99,45,51,56,54,101,97,52,48,52,51,57,54,100,54,54,51,97,56,48,52,50,45,53,54,50,57,56,45,101,54,101,50,54,51,51,49,45,100,101,50,53,45,52,56,100,56,45,57,48,98,54,45,52,55,49,48,99,100,48,98,54,49,56,98,0,74,116,101,115,116,45,116,111,112,105,99,45,98,98,53,100,52,99,48,99,51,55,97,101,53,51,101,98,56,98,53,51,45,53,54,50,57,56,45,97,99,50,48,50,98,102,56,45,55,56,101,55,45,52,100,56,98,45,97,100,48,55,45,52,101,48,49,100,56,49,52,56,100,98,48,0,0,19,136]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,2,0,74,116,101,115,116,45,116,111,112,105,99,45,98,98,53,100,52,99,48,99,51,55,97,101,53,51,101,98,56,98,53,51,45,53,54,50,57,56,45,97,99,50,48,50,98,102,56,45,55,56,101,55,45,52,100,56,98,45,97,100,48,55,45,52,101,48,49,100,56,49,52,56,100,98,48,0,0,0,74,116,101,115,116,45,116,111,112,105,99,45,51,56,54,101,97,52,48,52,51,57,54,100,54,54,51,97,56,48,52,50,45,53,54,50,57,56,45,101,54,101,50,54,51,51,49,45,100,101,50,53,45,52,56,100,56,45,57,48,98,54,45,52,55,49,48,99,100,48,98,54,49,56,98,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | 4 | import requestV1 from './v1/request.ts' 5 | import responseV1 from './v1/response.ts' 6 | 7 | const versions : any = { 8 | 0: ({ 9 | topics, 10 | timeout 11 | }: any) => { 12 | const request = requestV0 13 | const response =responseV0 14 | return { request: request({ topics, timeout }), response } 15 | }, 16 | 1: ({ 17 | topics, 18 | timeout 19 | }: any) => { 20 | const request = requestV1 21 | const response =responseV1 22 | return { request: request({ topics, timeout }), response } 23 | }, 24 | } 25 | 26 | export default{ 27 | versions: Object.keys(versions), 28 | protocol: ({ 29 | version 30 | }: any) => versions[version], 31 | } 32 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | 3 | import apiKeys from '../../apiKeys.ts' 4 | const apiKey = apiKeys.DeleteTopics 5 | /** 6 | * DeleteTopics Request (Version: 0) => [topics] timeout 7 | * topics => STRING 8 | * timeout => INT32 9 | */ 10 | export default ({ 11 | topics, 12 | timeout = 5000 13 | }: any) => ({ 14 | apiKey, 15 | apiVersion: 0, 16 | apiName: 'DeleteTopics', 17 | //deno-lint-ignore require-await 18 | encode: async () => { 19 | return new Encoder().writeArray(topics).writeInt32(timeout) 20 | }, 21 | }) 22 | -------------------------------------------------------------------------------- /src/protocol/requests/deleteTopics/v1/request.ts: -------------------------------------------------------------------------------- 1 | 2 | import requestV0 from '../v0/request.ts' 3 | /** 4 | * DeleteTopics Request (Version: 1) => [topics] timeout 5 | * topics => STRING 6 | * timeout => INT32 7 | */ 8 | 9 | export default ({ 10 | topics, 11 | timeout 12 | }: any) => 13 | Object.assign(requestV0({ topics, timeout }), { apiVersion: 1 }) 14 | -------------------------------------------------------------------------------- /src/protocol/requests/describeAcls/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[2,0,74,116,101,115,116,45,116,111,112,105,99,45,48,54,52,97,49,98,99,102,54,50,99,56,55,55,56,52,51,101,51,99,45,49,56,55,52,50,45,100,97,52,48,48,48,53,54,45,102,55,52,49,45,52,98,51,101,45,97,55,50,53,45,98,55,53,56,100,56,49,48,52,97,102,97,255,255,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/describeAcls/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,255,255,0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,48,54,52,97,49,98,99,102,54,50,99,56,55,55,56,52,51,101,51,99,45,49,56,55,52,50,45,100,97,52,48,48,48,53,54,45,102,55,52,49,45,52,98,51,101,45,97,55,50,53,45,98,55,53,56,100,56,49,48,52,97,102,97,0,0,0,1,0,72,85,115,101,114,58,98,111,98,45,101,101,102,55,50,99,100,100,100,49,97,55,98,98,51,102,49,50,53,50,45,49,56,55,52,50,45,98,99,97,99,54,53,99,51,45,98,101,99,52,45,52,50,97,99,45,56,102,51,48,45,48,48,51,49,52,102,54,100,52,50,56,101,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/describeAcls/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[2,0,74,116,101,115,116,45,116,111,112,105,99,45,51,48,57,49,101,51,55,99,98,51,52,101,49,101,57,49,54,99,102,97,45,49,56,48,50,57,45,49,98,50,55,55,98,52,49,45,52,102,52,48,45,52,55,52,48,45,57,50,55,52,45,53,49,102,53,53,54,102,50,49,50,99,57,3,255,255,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/describeAcls/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,255,255,0,0,0,1,2,0,74,116,101,115,116,45,116,111,112,105,99,45,51,48,57,49,101,51,55,99,98,51,52,101,49,101,57,49,54,99,102,97,45,49,56,48,50,57,45,49,98,50,55,55,98,52,49,45,52,102,52,48,45,52,55,52,48,45,57,50,55,52,45,53,49,102,53,53,54,102,50,49,50,99,57,3,0,0,0,1,0,72,85,115,101,114,58,98,111,98,45,98,98,99,57,101,56,102,50,49,99,97,48,100,49,101,54,48,101,98,97,45,49,56,48,50,57,45,101,48,99,101,101,49,51,54,45,54,102,48,53,45,52,51,102,99,45,97,50,51,53,45,50,54,97,55,55,57,101,55,50,52,49,51,0,1,42,2,3]} -------------------------------------------------------------------------------- /src/protocol/requests/describeAcls/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | 4 | const apiKey = apiKeys.DescribeAcls 5 | /** 6 | * DescribeAcls Request (Version: 0) => resource_type resource_name principal host operation permission_type 7 | * resource_type => INT8 8 | * resource_name => NULLABLE_STRING 9 | * principal => NULLABLE_STRING 10 | * host => NULLABLE_STRING 11 | * operation => INT8 12 | * permission_type => INT8 13 | */ 14 | 15 | export default ({ 16 | resourceType, 17 | resourceName, 18 | principal, 19 | host, 20 | operation, 21 | permissionType 22 | }: any) => ({ 23 | apiKey, 24 | apiVersion: 0, 25 | apiName: 'DescribeAcls', 26 | encode: async () => { 27 | return new Encoder() 28 | .writeInt8(resourceType) 29 | .writeString(resourceName) 30 | .writeString(principal) 31 | .writeString(host) 32 | .writeInt8(operation) 33 | .writeInt8(permissionType) 34 | }, 35 | }) 36 | -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,31,116,101,115,116,45,116,111,112,105,99,45,51,51,50,100,51,56,98,99,52,101,101,101,50,102,102,50,57,100,102,54,0,0,0,2,0,16,99,111,109,112,114,101,115,115,105,111,110,46,116,121,112,101,0,12,114,101,116,101,110,116,105,111,110,46,109,115]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v0_request_broker_config.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,4,0,1,48,0,0,0,1,0,26,115,97,115,108,46,107,101,114,98,101,114,111,115,46,115,101,114,118,105,99,101,46,110,97,109,101]} -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v0_request_topic_config.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,11,116,111,112,105,99,45,116,101,115,116,50,0,0,0,1,0,12,114,101,116,101,110,116,105,111,110,46,109,115]} -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,2,0,31,116,101,115,116,45,116,111,112,105,99,45,52,52,51,97,48,98,97,54,100,54,54,102,100,50,49,54,49,99,55,51,0,0,0,2,0,16,99,111,109,112,114,101,115,115,105,111,110,46,116,121,112,101,0,8,112,114,111,100,117,99,101,114,0,1,0,0,12,114,101,116,101,110,116,105,111,110,46,109,115,0,9,54,48,52,56,48,48,48,48,48,0,1,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v0_response_broker_config.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,4,0,1,48,0,0,0,1,0,26,115,97,115,108,46,107,101,114,98,101,114,111,115,46,115,101,114,118,105,99,101,46,110,97,109,101,255,255,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v0_response_topic_config.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,2,0,11,116,111,112,105,99,45,116,101,115,116,50,0,0,0,1,0,12,114,101,116,101,110,116,105,111,110,46,109,115,0,9,49,50,51,52,53,54,55,56,57,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,2,0,11,116,111,112,105,99,45,116,101,115,116,49,0,0,0,2,0,16,99,111,109,112,114,101,115,115,105,111,110,46,116,121,112,101,0,12,114,101,116,101,110,116,105,111,110,46,109,115,1]} -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,0,255,255,2,0,11,116,111,112,105,99,45,116,101,115,116,49,0,0,0,2,0,16,99,111,109,112,114,101,115,115,105,111,110,46,116,121,112,101,0,8,112,114,111,100,117,99,101,114,0,5,0,0,0,0,1,0,16,99,111,109,112,114,101,115,115,105,111,110,46,116,121,112,101,0,8,112,114,111,100,117,99,101,114,5,0,12,114,101,116,101,110,116,105,111,110,46,109,115,0,9,54,48,52,56,48,48,48,48,48,0,5,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/describeConfigs/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV1 from '../v1/request.ts' 2 | 3 | /** 4 | * DescribeConfigs Request (Version: 1) => [resources] include_synonyms 5 | * resources => resource_type resource_name [config_names] 6 | * resource_type => INT8 7 | * resource_name => STRING 8 | * config_names => STRING 9 | * include_synonyms => BOOLEAN 10 | */ 11 | 12 | /** 13 | * @param {Array} resources An array of config resources to be returned 14 | * @param [includeSynonyms=false] 15 | */ 16 | export default ({ 17 | resources, 18 | includeSynonyms 19 | }: any) => 20 | Object.assign(requestV1({ resources, includeSynonyms }), { apiVersion: 2 }) 21 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,54,48,56,101,55,101,52,50,48,52,51,100,57,49,55,101,99,98,52,52]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,0,0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,54,48,56,101,55,101,52,50,48,52,51,100,57,49,55,101,99,98,52,52,0,6,83,116,97,98,108,101,0,8,99,111,110,115,117,109,101,114,0,7,100,101,102,97,117,108,116,0,0,0,1,0,62,116,101,115,116,45,53,99,99,51,98,99,50,55,99,97,50,54,54,48,49,52,52,57,55,54,45,102,101,99,54,97,100,101,49,45,56,50,101,102,45,52,54,49,101,45,56,49,102,101,45,99,51,48,101,53,57,48,56,101,50,100,50,0,25,116,101,115,116,45,53,99,99,51,98,99,50,55,99,97,50,54,54,48,49,52,52,57,55,54,0,11,47,49,55,50,46,49,56,46,48,46,49,0,0,0,2,0,0,0,0,0,2,123,125]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/fixtures/v1_memberAssignment.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,100,49,54,55,102,53,101,99,53,51,48,50,98,102,99,49,99,54,52,57,45,53,51,51,56,52,45,55,53,50,97,56,55,101,56,45,53,57,51,54,45,52,102,55,56,45,56,102,52,50,45,52,100,57,50,48,51,57,51,98,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/fixtures/v1_memberMetadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,100,49,54,55,102,53,101,99,53,51,48,50,98,102,99,49,99,54,52,57,45,53,51,51,56,52,45,55,53,50,97,56,55,101,56,45,53,57,51,54,45,52,102,55,56,45,56,102,52,50,45,52,100,57,50,48,51,57,51,98,53,102,50,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,52,100,101,48,97,97,49,48,101,102,57,52,52,48,51,97,51,57,55,100,45,53,51,51,56,52,45,100,50,102,101,101,57,54,57,45,49,52,52,54,45,52,49,54,54,45,98,99,56,101,45,99,56,56,101,56,100,97,102,102,100,102,101]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | const apiKey = apiKeys.DescribeGroups 4 | /** 5 | * DescribeGroups Request (Version: 0) => [group_ids] 6 | * group_ids => STRING 7 | */ 8 | 9 | /** 10 | * @param {Array} groupIds List of groupIds to request metadata for (an empty groupId array will return empty group metadata) 11 | */ 12 | export default ({ 13 | groupIds 14 | }: any) => ({ 15 | apiKey, 16 | apiVersion: 0, 17 | apiName: 'DescribeGroups', 18 | //deno-lint-ignore require-await 19 | encode: async () => { 20 | return new Encoder().writeArray(groupIds) 21 | }, 22 | }) 23 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * DescribeGroups Request (Version: 1) => [group_ids] 5 | * group_ids => STRING 6 | */ 7 | 8 | export default ({ 9 | groupIds 10 | }: any) => Object.assign(requestV0({ groupIds }), { apiVersion: 1 }) 11 | -------------------------------------------------------------------------------- /src/protocol/requests/describeGroups/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV1 from '../v1/request.ts' 2 | 3 | /** 4 | * DescribeGroups Request (Version: 2) => [group_ids] 5 | * group_ids => STRING 6 | */ 7 | 8 | export default({ 9 | groupIds 10 | }: any) => Object.assign(requestV1({ groupIds }), { apiVersion: 2 }) 11 | -------------------------------------------------------------------------------- /src/protocol/requests/endTxn/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,21,116,101,115,116,45,116,114,97,110,115,97,99,116,105,111,110,97,108,45,105,100,0,0,0,0,0,0,3,233,0,0,1]} -------------------------------------------------------------------------------- /src/protocol/requests/endTxn/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/endTxn/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | const apiKey = apiKeys.EndTxn 4 | 5 | /** 6 | * EndTxn Request (Version: 0) => transactional_id producer_id producer_epoch transaction_result 7 | * transactional_id => STRING 8 | * producer_id => INT64 9 | * producer_epoch => INT16 10 | * transaction_result => BOOLEAN 11 | */ 12 | 13 | export default ({ 14 | transactionalId, 15 | producerId, 16 | producerEpoch, 17 | transactionResult 18 | }: any) => ({ 19 | apiKey, 20 | apiVersion: 0, 21 | apiName: 'EndTxn', 22 | encode: async () => { 23 | return new Encoder() 24 | .writeString(transactionalId) 25 | .writeInt64(producerId) 26 | .writeInt16(producerEpoch) 27 | .writeBoolean(transactionResult) 28 | }, 29 | }) 30 | -------------------------------------------------------------------------------- /src/protocol/requests/endTxn/v0/response.ts: -------------------------------------------------------------------------------- 1 | import {Decoder} from '../../../decoder.ts' 2 | import { failure, createErrorFromCode, failIfVersionNotSupported } from '../../../error.ts' 3 | 4 | /** 5 | * EndTxn Response (Version: 0) => throttle_time_ms error_code 6 | * throttle_time_ms => INT32 7 | * error_code => INT16 8 | */ 9 | //deno-lint-ignore require-await 10 | const decode = async (rawData: any) => { 11 | const decoder = new Decoder(rawData) 12 | const throttleTime = decoder.readInt32() 13 | const errorCode = decoder.readInt16() 14 | 15 | failIfVersionNotSupported(errorCode) 16 | 17 | return { 18 | throttleTime, 19 | errorCode, 20 | } 21 | } 22 | //deno-lint-ignore require-await 23 | const parse = async (data: any) => { 24 | if (failure(data.errorCode)) { 25 | throw createErrorFromCode(data.errorCode) 26 | } 27 | 28 | return data 29 | } 30 | 31 | export default { 32 | decode, 33 | parse, 34 | } 35 | -------------------------------------------------------------------------------- /src/protocol/requests/endTxn/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * EndTxn Request (Version: 1) => transactional_id producer_id producer_epoch transaction_result 5 | * transactional_id => STRING 6 | * producer_id => INT64 7 | * producer_epoch => INT16 8 | * transaction_result => BOOLEAN 9 | */ 10 | 11 | export default ({ 12 | transactionalId, 13 | producerId, 14 | producerEpoch, 15 | transactionResult 16 | }: any) => 17 | Object.assign(requestV0({ transactionalId, producerId, producerEpoch, transactionResult }), { 18 | apiVersion: 1, 19 | }) 20 | -------------------------------------------------------------------------------- /src/protocol/requests/endTxn/v1/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v0/response.ts' 2 | const parse = response.parse 3 | const decodeV0 = response.decode 4 | /** 5 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 6 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 7 | * 8 | * EndTxn Response (Version: 1) => throttle_time_ms error_code 9 | * throttle_time_ms => INT32 10 | * error_code => INT16 11 | */ 12 | 13 | const decode = async (rawData: any) => { 14 | const decoded = await decodeV0(rawData) 15 | 16 | return { 17 | ...decoded, 18 | throttleTime: 0, 19 | clientSideThrottleTime: decoded.throttleTime, 20 | } 21 | } 22 | 23 | export default { 24 | decode, 25 | parse, 26 | } 27 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,5,0,0,0,1,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,55,57,98,57,52,100,57,100,99,102,100,54,53,101,49,50,56,51,97,57,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,43,0,0,0,0,0,0,0,0,0,0,0,31,7,42,162,83,0,0,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v0_response_gzip.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,98,101,51,99,98,56,99,51,54,55,99,57,100,57,48,51,57,51,51,102,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,129,0,0,0,0,0,0,0,0,0,0,0,31,7,42,162,83,0,0,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48,0,0,0,0,0,0,0,1,0,0,0,31,247,139,89,134,0,0,0,0,0,5,107,101,121,45,49,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,49,0,0,0,0,0,0,0,2,0,0,0,31,61,24,83,184,0,0,0,0,0,5,107,101,121,45,50,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v10_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,0,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,50,48,55,55,98,57,100,50,98,51,54,99,52,48,56,50,101,53,57,52,45,52,48,50,48,45,98,53,97,53,50,98,50,55,45,53,54,100,102,45,52,98,56,55,45,56,48,48,100,45,56,50,99,49,99,102,50,54,51,49,55,100,0,0,0,1,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v11_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,0,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,50,48,55,55,98,57,100,50,98,51,54,99,52,48,56,50,101,53,57,52,45,52,48,50,48,45,98,53,97,53,50,98,50,55,45,53,54,100,102,45,52,98,56,55,45,56,48,48,100,45,56,50,99,49,99,102,50,54,51,49,55,100,0,0,0,1,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0,0,0,0,0,0,5,114,97,99,107,49]} -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,5,0,0,0,1,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,54,51,53,52,53,57,53,97,97,48,55,99,48,102,97,50,97,101,53,53,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,43,0,0,0,0,0,0,0,0,0,0,0,31,7,42,162,83,0,0,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v1_response_gzip.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,97,101,48,98,55,52,99,100,52,53,99,98,55,99,49,57,55,49,100,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,107,0,0,0,0,0,0,0,2,0,0,0,95,127,17,25,62,0,1,255,255,255,255,0,0,0,81,31,139,8,0,0,0,0,0,0,0,99,96,128,3,121,118,173,69,193,96,22,107,118,106,165,174,1,144,193,83,156,159,155,170,91,150,152,83,154,10,230,131,0,35,72,233,247,238,200,54,132,82,67,52,165,134,80,165,76,32,165,182,18,193,59,16,74,141,208,148,26,1,0,35,174,26,230,129,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,5,0,0,0,1,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,49,51,49,99,50,55,57,102,51,53,101,101,98,50,100,102,54,98,99,55,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,153,0,0,0,0,0,0,0,0,0,0,0,39,207,95,192,107,1,0,0,0,1,95,136,190,160,100,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48,0,0,0,0,0,0,0,1,0,0,0,39,216,227,157,41,1,0,0,0,1,95,136,190,160,101,0,0,0,5,107,101,121,45,49,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,49,0,0,0,0,0,0,0,2,0,0,0,39,18,112,151,23,1,0,0,0,1,95,136,190,160,101,0,0,0,5,107,101,121,45,50,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v2_response_gzip.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,55,100,52,56,99,48,49,101,100,52,56,102,48,54,54,55,54,55,50,98,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,127,0,0,0,0,0,0,0,2,0,0,0,115,108,89,3,222,1,1,0,0,1,95,136,190,161,206,255,255,255,255,0,0,0,93,31,139,8,0,0,0,0,0,0,0,99,96,128,3,245,115,223,53,182,51,2,25,140,241,29,251,22,158,5,50,88,179,83,43,117,13,128,12,158,226,252,220,84,221,178,196,156,210,84,48,31,4,64,42,213,207,48,218,205,130,107,57,7,211,98,136,166,197,16,170,133,9,164,133,109,146,201,18,76,45,70,104,90,140,0,159,238,172,37,153,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v2_response_index_out_of_range.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,29,116,101,115,116,45,116,111,112,105,99,45,105,110,100,101,120,45,111,117,116,45,111,102,45,114,97,110,103,101,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,240,21,193,0,0,0,138,0,0,0,0,0,240,20,148,0,0,0,31,7,42,162,83,0,0,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48,0,0,0,0,0,240,20,149,0,0,0,31,247,139,89,134,0,0,0,0,0,5,107,101,121,45,49,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,49,0,0,0,0,0,240,20,150,0,0,0,31,61,24,83,184,0,0,0,0,0,5,107,101,121,45,50,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,50,0,0,0,0,0,240,20,151,1]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v3_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,5,0,0,0,1,0,160,0,0,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,49,51,49,99,50,55,57,102,51,53,101,101,98,50,100,102,54,98,99,55,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,153,0,0,0,0,0,0,0,0,0,0,0,39,207,95,192,107,1,0,0,0,1,95,136,190,160,100,0,0,0,5,107,101,121,45,48,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,48,0,0,0,0,0,0,0,1,0,0,0,39,216,227,157,41,1,0,0,0,1,95,136,190,160,101,0,0,0,5,107,101,121,45,49,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,49,0,0,0,0,0,0,0,2,0,0,0,39,18,112,151,23,1,0,0,0,1,95,136,190,160,101,0,0,0,5,107,101,121,45,50,0,0,0,12,115,111,109,101,45,118,97,108,117,101,45,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v3_response_gzip.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,55,100,52,56,99,48,49,101,100,52,56,102,48,54,54,55,54,55,50,98,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,127,0,0,0,0,0,0,0,2,0,0,0,115,108,89,3,222,1,1,0,0,1,95,136,190,161,206,255,255,255,255,0,0,0,93,31,139,8,0,0,0,0,0,0,0,99,96,128,3,245,115,223,53,182,51,2,25,140,241,29,251,22,158,5,50,88,179,83,43,117,13,128,12,158,226,252,220,84,221,178,196,156,210,84,48,31,4,64,42,213,207,48,218,205,130,107,57,7,211,98,136,166,197,16,170,133,9,164,133,109,146,201,18,76,45,70,104,90,140,0,159,238,172,37,153,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v4_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,5,0,0,0,1,0,160,0,0,1,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v4_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,97,98,52,100,53,52,55,55,52,100,99,97,100,99,51,57,53,97,55,102,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,217,0,0,0,0,0,0,0,0,0,0,0,205,0,0,0,0,2,214,84,85,104,0,0,0,0,0,2,0,0,1,95,136,193,114,169,0,0,1,95,136,193,114,169,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,3,102,0,0,0,10,107,101,121,45,48,24,115,111,109,101,45,118,97,108,117,101,45,48,2,24,104,101,97,100,101,114,45,107,101,121,45,48,28,104,101,97,100,101,114,45,118,97,108,117,101,45,48,102,0,0,2,10,107,101,121,45,49,24,115,111,109,101,45,118,97,108,117,101,45,49,2,24,104,101,97,100,101,114,45,107,101,121,45,49,28,104,101,97,100,101,114,45,118,97,108,117,101,45,49,102,0,0,4,10,107,101,121,45,50,24,115,111,109,101,45,118,97,108,117,101,45,50,2,24,104,101,97,100,101,114,45,107,101,121,45,50,28,104,101,97,100,101,114,45,118,97,108,117,101,45,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v4_response_010_format.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,75,116,101,115,116,45,116,111,112,105,99,50,45,48,56,97,50,102,49,50,100,100,100,100,56,99,57,50,52,52,54,48,102,45,55,56,55,54,55,45,48,50,48,55,51,97,51,101,45,48,54,50,50,45,52,100,48,100,45,57,101,101,57,45,98,53,100,54,97,53,97,51,50,54,102,49,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,170,0,0,0,0,0,0,0,0,0,0,0,158,121,101,190,49,1,0,0,0,1,102,53,227,242,77,0,0,0,67,107,101,121,45,57,98,102,54,50,56,52,100,99,49,49,51,52,53,48,56,50,54,52,57,45,55,56,55,54,55,45,102,55,57,98,52,55,56,48,45,102,50,97,97,45,52,98,98,98,45,57,55,57,102,45,57,97,52,56,49,53,54,53,50,98,53,99,0,0,0,69,118,97,108,117,101,45,57,98,102,54,50,56,52,100,99,49,49,51,52,53,48,56,50,54,52,57,45,55,56,55,54,55,45,102,55,57,98,52,55,56,48,45,102,50,97,97,45,52,98,98,98,45,57,55,57,102,45,57,97,52,56,49,53,54,53,50,98,53,99]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v4_response_gzip.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,52,51,99,57,53,97,51,100,99,54,56,100,98,102,55,56,97,51,53,57,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,248,0,0,0,0,0,0,0,0,0,0,0,112,0,0,0,0,2,41,38,251,203,0,1,0,0,0,2,0,0,1,95,136,193,114,169,0,0,1,95,136,193,114,169,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,3,31,139,8,0,0,0,0,0,0,19,211,99,96,96,224,202,78,173,212,53,144,40,206,207,77,213,45,75,204,41,77,213,53,96,208,99,96,96,2,139,27,34,139,27,130,196,89,192,226,70,200,226,70,12,0,239,50,132,175,72,0,0,0,0,0,0,0,0,0,0,3,0,0,0,112,0,0,0,0,2,93,31,19,200,0,1,0,0,0,2,0,0,1,95,136,193,114,169,0,0,1,95,136,193,114,169,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,3,31,139,8,0,0,0,0,0,0,19,211,99,96,96,224,202,78,173,212,53,148,40,206,207,77,213,45,75,204,41,77,213,53,100,208,99,96,96,2,139,27,33,139,27,129,196,89,192,226,198,200,226,198,12,0,104,90,42,250,72,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v4_response_snappy.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,10,116,111,112,105,99,45,116,101,115,116,0,0,0,2,0,0,0,3,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,110,0,0,0,0,0,0,0,0,0,0,0,98,0,0,0,0,2,151,239,110,170,0,2,0,0,0,0,0,0,1,104,185,18,144,177,0,0,1,104,185,18,144,177,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,1,48,68,94,0,0,0,14,107,101,121,45,49,52,57,68,118,97,108,117,101,1,10,100,45,50,48,49,57,45,48,50,45,48,52,84,49,53,58,49,51,58,52,56,46,49,56,55,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v5_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,99,57,51,53,100,54,55,56,56,51,53,100,101,50,99,57,99,55,57,101,45,50,48,54,52,45,54,55,55,48,52,49,98,55,45,100,102,53,52,45,52,100,52,100,45,97,53,51,97,45,98,57,49,51,51,100,50,102,100,99,56,99,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v6_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,48,55,101,97,101,48,101,100,100,54,52,48,48,102,101,50,55,51,51,97,45,51,48,56,56,45,51,51,48,48,56,48,98,98,45,57,55,102,49,45,52,97,48,57,45,56,57,101,49,45,102,48,102,101,53,99,49,51,55,97,98,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v7_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,0,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,50,48,55,55,98,57,100,50,98,51,54,99,52,48,56,50,101,53,57,52,45,52,48,50,48,45,98,53,97,53,50,98,50,55,45,53,54,100,102,45,52,98,56,55,45,56,48,48,100,45,56,50,99,49,99,102,50,54,51,49,55,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v8_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,0,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,50,48,55,55,98,57,100,50,98,51,54,99,52,48,56,50,101,53,57,52,45,52,48,50,48,45,98,53,97,53,50,98,50,55,45,53,54,100,102,45,52,98,56,55,45,56,48,48,100,45,56,50,99,49,99,102,50,54,51,49,55,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/fixtures/v9_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,100,0,0,0,1,0,160,0,0,1,0,0,0,0,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,50,48,55,55,98,57,100,50,98,51,54,99,52,48,56,50,101,53,57,52,45,52,48,50,48,45,98,53,97,53,50,98,50,55,45,53,54,100,102,45,52,98,56,55,45,56,48,48,100,45,56,50,99,49,99,102,50,54,51,49,55,100,0,0,0,1,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,16,0,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/fetch/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | export default({ 4 | replicaId, 5 | maxWaitTime, 6 | minBytes, 7 | topics 8 | }: any) => { 9 | return Object.assign(requestV0({ replicaId, maxWaitTime, minBytes, topics }), { apiVersion: 1 }) 10 | } 11 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | export default ({ 4 | replicaId, 5 | maxWaitTime, 6 | minBytes, 7 | topics 8 | }: any) => { 9 | return Object.assign(requestV0({ replicaId, maxWaitTime, minBytes, topics }), { apiVersion: 2 }) 10 | } 11 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/v2/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v1/response.ts' 2 | 3 | const parse = response.parse 4 | const decode = response.decode 5 | /** 6 | * Fetch Response (Version: 2) => throttle_time_ms [responses] 7 | * throttle_time_ms => INT32 8 | * responses => topic [partition_responses] 9 | * topic => STRING 10 | * partition_responses => partition_header record_set 11 | * partition_header => partition error_code high_watermark 12 | * partition => INT32 13 | * error_code => INT16 14 | * high_watermark => INT64 15 | * record_set => RECORDS 16 | */ 17 | 18 | export default { 19 | decode, 20 | parse, 21 | } 22 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/v3/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v1/response.ts' 2 | 3 | const decode = response.decode 4 | const parse = response.parse 5 | 6 | /** 7 | * Fetch Response (Version: 3) => throttle_time_ms [responses] 8 | * throttle_time_ms => INT32 9 | * responses => topic [partition_responses] 10 | * topic => STRING 11 | * partition_responses => partition_header record_set 12 | * partition_header => partition error_code high_watermark 13 | * partition => INT32 14 | * error_code => INT16 15 | * high_watermark => INT64 16 | * record_set => RECORDS 17 | */ 18 | 19 | export default { 20 | decode, 21 | parse, 22 | } 23 | -------------------------------------------------------------------------------- /src/protocol/requests/fetch/v6/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v5/response.ts' 2 | const parse = response.parse 3 | const decode = response.decode 4 | 5 | /** 6 | * Fetch Response (Version: 6) => throttle_time_ms [responses] 7 | * throttle_time_ms => INT32 8 | * responses => topic [partition_responses] 9 | * topic => STRING 10 | * partition_responses => partition_header record_set 11 | * partition_header => partition error_code high_watermark last_stable_offset log_start_offset [aborted_transactions] 12 | * partition => INT32 13 | * error_code => INT16 14 | * high_watermark => INT64 15 | * last_stable_offset => INT64 16 | * log_start_offset => INT64 17 | * aborted_transactions => producer_id first_offset 18 | * producer_id => INT64 19 | * first_offset => INT64 20 | * record_set => RECORDS 21 | */ 22 | 23 | export default{ 24 | decode, 25 | parse, 26 | } 27 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,10,116,101,115,116,45,116,111,112,105,99]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,1,0,13,49,57,50,46,49,54,56,46,49,46,49,53,53,0,0,35,135]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,8,103,114,111,117,112,45,105,100,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,255,255,0,0,0,2,0,14,49,57,50,46,49,54,56,46,53,48,46,50,49,49,0,0,35,138]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/fixtures/v1_response_version_error.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,35,255,255,0,0,0,2,0,14,49,57,50,46,49,54,56,46,53,48,46,50,49,49,0,0,35,138]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | 4 | const apiKey = apiKeys.GroupCoordinator; 5 | 6 | /** 7 | * FindCoordinator Request (Version: 0) => group_id 8 | * group_id => STRING 9 | */ 10 | 11 | export default ({ 12 | groupId 13 | }: any) => ({ 14 | apiKey, 15 | apiVersion: 0, 16 | apiName: 'GroupCoordinator', 17 | //deno-lint-ignore require-await 18 | encode: async () => { 19 | return new Encoder().writeString(groupId) 20 | }, 21 | }) 22 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/v1/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | 4 | const apiKey = apiKeys.GroupCoordinator; 5 | 6 | /** 7 | * FindCoordinator Request (Version: 1) => coordinator_key coordinator_type 8 | * coordinator_key => STRING 9 | * coordinator_type => INT8 10 | */ 11 | 12 | export default ({ 13 | coordinatorKey, 14 | coordinatorType 15 | }: any) => ({ 16 | apiKey, 17 | apiVersion: 1, 18 | apiName: 'GroupCoordinator', 19 | //deno-lint-ignore require-await 20 | encode: async () => { 21 | return new Encoder().writeString(coordinatorKey).writeInt8(coordinatorType) 22 | }, 23 | }) 24 | -------------------------------------------------------------------------------- /src/protocol/requests/findCoordinator/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV1 from '../v1/request.ts' 2 | 3 | /** 4 | * FindCoordinator Request (Version: 2) => coordinator_key coordinator_type 5 | * coordinator_key => STRING 6 | * coordinator_type => INT8 7 | */ 8 | 9 | export default({ 10 | coordinatorKey, 11 | coordinatorType 12 | }: any) => 13 | Object.assign(requestV1({ coordinatorKey, coordinatorType }), { apiVersion: 2 }) 14 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,98,97,56,100,97,49,102,54,49,49,55,53,54,50,101,100,53,54,49,53,0,0,0,1,0,62,116,101,115,116,45,49,54,57,50,51,50,98,48,54,57,99,52,97,51,55,55,98,99,52,98,45,48,52,48,102,53,102,49,97,45,97,52,54,57,45,52,48,54,50,45,57,100,51,54,45,98,100,56,48,51,100,56,100,54,55,54,55]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,52,99,52,53,54,48,48,48,49,53,49,102,48,57,52,98,54,48,48,100,45,50,54,55,54,50,45,102,100,54,97,54,97,101,55,45,51,102,54,54,45,52,48,56,101,45,56,48,50,101,45,100,50,54,49,100,54,57,56,51,100,48,100,0,0,0,1,0,105,116,101,115,116,45,49,52,100,97,49,98,52,49,97,99,54,56,56,97,54,100,99,98,55,56,45,50,54,55,54,50,45,52,100,97,99,56,101,49,50,45,100,99,50,56,45,52,100,98,50,45,56,52,53,54,45,57,53,98,99,54,99,49,53,56,57,98,98,45,55,98,97,100,49,101,56,52,45,99,50,100,101,45,52,99,99,54,45,56,48,55,49,45,98,97,100,98,50,55,99,56,54,49,54,54]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,52,99,52,53,54,48,48,48,49,53,49,102,48,57,52,98,54,48,48,100,45,50,54,55,54,50,45,102,100,54,97,54,97,101,55,45,51,102,54,54,45,52,48,56,101,45,56,48,50,101,45,100,50,54,49,100,54,57,56,51,100,48,100,0,0,0,1,0,105,116,101,115,116,45,49,52,100,97,49,98,52,49,97,99,54,56,56,97,54,100,99,98,55,56,45,50,54,55,54,50,45,52,100,97,99,56,101,49,50,45,100,99,50,56,45,52,100,98,50,45,56,52,53,54,45,57,53,98,99,54,99,49,53,56,57,98,98,45,55,98,97,100,49,101,56,52,45,99,50,100,101,45,52,99,99,54,45,56,48,55,49,45,98,97,100,98,50,55,99,56,54,49,54,54]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v3_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,52,99,52,53,54,48,48,48,49,53,49,102,48,57,52,98,54,48,48,100,45,50,54,55,54,50,45,102,100,54,97,54,97,101,55,45,51,102,54,54,45,52,48,56,101,45,56,48,50,101,45,100,50,54,49,100,54,57,56,51,100,48,100,0,0,0,1,0,105,116,101,115,116,45,49,52,100,97,49,98,52,49,97,99,54,56,56,97,54,100,99,98,55,56,45,50,54,55,54,50,45,52,100,97,99,56,101,49,50,45,100,99,50,56,45,52,100,98,50,45,56,52,53,54,45,57,53,98,99,54,99,49,53,56,57,98,98,45,55,98,97,100,49,101,56,52,45,99,50,100,101,45,52,99,99,54,45,56,48,55,49,45,98,97,100,98,50,55,99,56,54,49,54,54,0,105,116,101,115,116,45,49,52,100,97,49,98,52,49,97,99,54,56,56,97,54,100,99,98,55,56,45,50,54,55,54,50,45,52,100,97,99,56,101,49,50,45,100,99,50,56,45,52,100,98,50,45,56,52,53,54,45,57,53,98,99,54,99,49,53,56,57,98,98,45,55,98,97,100,49,101,56,52,45,99,50,100,101,45,52,99,99,54,45,56,48,55,49,45,98,97,100,98,50,55,99,56,54,49,54,54]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v0/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | // deno-lint-ignore-file no-explicit-any 4 | import { Encoder } from '../../../encoder.ts'; 5 | import apiKeys from '../../apiKeys.ts'; 6 | const apiKey = apiKeys.Heartbeat; 7 | 8 | /** 9 | * Heartbeat Request (Version: 0) => group_id group_generation_id member_id 10 | * group_id => STRING 11 | * group_generation_id => INT32 12 | * member_id => STRING 13 | */ 14 | 15 | export default ({ groupId, groupGenerationId, memberId }: any) => ({ 16 | apiKey, 17 | apiVersion: 0, 18 | apiName: 'Heartbeat', 19 | //deno-lint-ignore require-await 20 | encode: async () => { 21 | return new Encoder() 22 | .writeString(groupId) 23 | .writeInt32(groupGenerationId) 24 | .writeString(memberId); 25 | }, 26 | }); 27 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v0/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Decoder } from '../../../decoder.ts'; 4 | import { 5 | failure, 6 | createErrorFromCode, 7 | failIfVersionNotSupported, 8 | } from '../../../error.ts'; 9 | 10 | /** 11 | * Heartbeat Response (Version: 0) => error_code 12 | * error_code => INT16 13 | */ 14 | //deno-lint-ignore require-await 15 | const decode = async (rawData: any) => { 16 | const decoder = new Decoder(rawData); 17 | const errorCode = decoder.readInt16(); 18 | 19 | failIfVersionNotSupported(errorCode); 20 | 21 | return { errorCode }; 22 | }; 23 | //deno-lint-ignore require-await 24 | const parse = async (data: any) => { 25 | if (failure(data.errorCode)) { 26 | throw createErrorFromCode(data.errorCode); 27 | } 28 | 29 | return data; 30 | }; 31 | 32 | export default { 33 | decode, 34 | parse, 35 | }; 36 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * Heartbeat Request (Version: 1) => group_id generation_id member_id 7 | * group_id => STRING 8 | * generation_id => INT32 9 | * member_id => STRING 10 | */ 11 | 12 | export default ({ groupId, groupGenerationId, memberId }: any) => 13 | Object.assign(requestV0({ groupId, groupGenerationId, memberId }), { 14 | apiVersion: 1, 15 | }); 16 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {Decoder} from '../../../decoder.ts'; 4 | import { failIfVersionNotSupported } from '../../../error.ts'; 5 | import response from '../v0/response.ts'; 6 | const {parse} = response 7 | /** 8 | * Heartbeat Response (Version: 1) => throttle_time_ms error_code 9 | * throttle_time_ms => INT32 10 | * error_code => INT16 11 | */ 12 | //deno-lint-ignore require-await 13 | const decode = async (rawData: any) => { 14 | const decoder = new Decoder(rawData); 15 | const throttleTime = decoder.readInt32(); 16 | const errorCode = decoder.readInt16(); 17 | 18 | failIfVersionNotSupported(errorCode); 19 | 20 | return { throttleTime, errorCode }; 21 | }; 22 | 23 | export default { decode, parse }; 24 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v2/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV1 from '../v1/request.ts'; 4 | 5 | /** 6 | * Heartbeat Request (Version: 2) => group_id generation_id member_id 7 | * group_id => STRING 8 | * generation_id => INT32 9 | * member_id => STRING 10 | */ 11 | 12 | export default ({ groupId, groupGenerationId, memberId }: any) => 13 | Object.assign(requestV1({ groupId, groupGenerationId, memberId }), { 14 | apiVersion: 2, 15 | }); 16 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v2/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v1/response.ts'; 4 | const decodeV1 = response.decode 5 | const parse = response.parse 6 | 7 | /** 8 | * In version 2 on quota violation, brokers send out responses before throttling. 9 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 10 | * 11 | * Heartbeat Response (Version: 2) => throttle_time_ms error_code 12 | * throttle_time_ms => INT32 13 | * error_code => INT16 14 | */ 15 | const decode = async (rawData: any) => { 16 | const decoded = await decodeV1(rawData); 17 | 18 | return { 19 | ...decoded, 20 | throttleTime: 0, 21 | clientSideThrottleTime: decoded.throttleTime, 22 | }; 23 | }; 24 | 25 | export default { 26 | decode, 27 | parse, 28 | }; 29 | -------------------------------------------------------------------------------- /src/protocol/requests/heartbeat/v3/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v2/response.ts'; 4 | 5 | const parse = response.parse; 6 | const decode = response.decode; 7 | 8 | /** 9 | * Heartbeat Response (Version: 3) => throttle_time_ms error_code 10 | * throttle_time_ms => INT32 11 | * error_code => INT16 12 | */ 13 | export default { 14 | decode, 15 | parse, 16 | }; 17 | -------------------------------------------------------------------------------- /src/protocol/requests/initProducerId/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,25,105,110,105,116,112,114,111,100,117,99,101,114,105,100,116,114,97,110,115,97,99,116,105,111,110,0,0,117,48]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/initProducerId/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,3,238,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/initProducerId/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import requestV0 from './v0/request.ts'; 3 | import responseV0 from './v0/response.ts'; 4 | import requestV1 from './v1/request.ts'; 5 | import responseV1 from './v1/response.ts'; 6 | 7 | const versions: any = { 8 | 0: ({ transactionalId, transactionTimeout = 5000 }: any) => { 9 | const request = requestV0; 10 | const response = responseV0; 11 | return { 12 | request: request({ transactionalId, transactionTimeout }), 13 | response, 14 | }; 15 | }, 16 | 1: ({ transactionalId, transactionTimeout = 5000 }: any) => { 17 | const request = requestV1; 18 | const response = responseV1; 19 | 20 | return { 21 | request: request({ transactionalId, transactionTimeout }), 22 | response, 23 | }; 24 | }, 25 | }; 26 | 27 | export default { 28 | versions: Object.keys(versions), 29 | protocol: ({ version }: any) => versions[version], 30 | }; 31 | -------------------------------------------------------------------------------- /src/protocol/requests/initProducerId/v0/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Encoder } from '../../../encoder.ts'; 4 | import apiKeys from '../../apiKeys.ts'; 5 | const apiKey = apiKeys.InitProducerId; 6 | /** 7 | * InitProducerId Request (Version: 0) => transactional_id transaction_timeout_ms 8 | * transactional_id => NULLABLE_STRING 9 | * transaction_timeout_ms => INT32 10 | */ 11 | 12 | export default ({ transactionalId, transactionTimeout }: any) => ({ 13 | apiKey, 14 | apiVersion: 0, 15 | apiName: 'InitProducerId', 16 | //deno-lint-ignore require-await 17 | encode: async () => { 18 | return new Encoder() 19 | .writeString(transactionalId) 20 | .writeInt32(transactionTimeout); 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /src/protocol/requests/initProducerId/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * InitProducerId Request (Version: 1) => transactional_id transaction_timeout_ms 7 | * transactional_id => NULLABLE_STRING 8 | * transaction_timeout_ms => INT32 9 | */ 10 | 11 | export default ({ transactionalId, transactionTimeout }: any) => 12 | Object.assign(requestV0({ transactionalId, transactionTimeout }), { 13 | apiVersion: 1, 14 | }); 15 | -------------------------------------------------------------------------------- /src/protocol/requests/initProducerId/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | const parse = response.parse; 5 | const decodeV0 = response.decode; 6 | /** 7 | * Starting in version 1, on quota violation, brokers send out responses before throttling. 8 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 9 | * 10 | * InitProducerId Response (Version: 0) => throttle_time_ms error_code producer_id producer_epoch 11 | * throttle_time_ms => INT32 12 | * error_code => INT16 13 | * producer_id => INT64 14 | * producer_epoch => INT16 15 | */ 16 | 17 | const decode = async (rawData: any) => { 18 | const decoded = await decodeV0(rawData); 19 | 20 | return { 21 | ...decoded, 22 | throttleTime: 0, 23 | clientSideThrottleTime: decoded.throttleTime, 24 | }; 25 | }; 26 | 27 | export default { 28 | decode, 29 | parse, 30 | }; 31 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"data":[0,10,116,101,115,116,45,103,114,111,117,112,0,0,117,48,0,0,0,8,99,111,110,115,117,109,101,114,0,0,0,1,0,7,100,101,102,97,117,108,116,0,0,0,0],"type":"Buffer"} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,11,0,7,100,101,102,97,117,108,116,0,62,116,101,115,116,45,49,54,57,48,50,57,100,98,50,57,102,50,101,98,102,101,48,55,99,49,45,102,101,48,100,53,51,51,56,45,56,48,52,101,45,52,50,102,97,45,97,102,54,97,45,99,56,102,55,98,50,52,54,55,99,54,101,0,62,116,101,115,116,45,49,54,57,48,50,57,100,98,50,57,102,50,101,98,102,101,48,55,99,49,45,102,101,48,100,53,51,51,56,45,56,48,52,101,45,52,50,102,97,45,97,102,54,97,45,99,56,102,55,98,50,52,54,55,99,54,101,0,0,0,1,0,62,116,101,115,116,45,49,54,57,48,50,57,100,98,50,57,102,50,101,98,102,101,48,55,99,49,45,102,101,48,100,53,51,51,56,45,56,48,52,101,45,52,50,102,97,45,97,102,54,97,45,99,56,102,55,98,50,52,54,55,99,54,101,0,0,0,2,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v1_assignerMetadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,57,53,97,54,56,56,101,54,56,51,49,57,51,52,102,53,98,49,97,102,45,50,49,52,56,54,45,57,100,99,49,53,50,55,97,45,49,102,101,53,45,52,97,98,50,45,98,52,51,56,45,56,99,48,54,55,57,50,100,53,99,48,50,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,53,100,53,50,48,51,55,51,101,49,99,102,52,100,48,51,99,97,55,55,45,50,49,52,56,54,45,57,48,57,52,56,102,53,55,45,53,50,56,99,45,52,99,51,98,45,98,97,55,50,45,98,102,49,101,48,100,57,98,98,99,53,54,0,0,117,48,0,0,234,96,0,0,0,8,99,111,110,115,117,109,101,114,0,0,0,1,0,12,65,115,115,105,103,110,101,114,78,97,109,101,0,0,0,86,0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,57,53,97,54,56,56,101,54,56,51,49,57,51,52,102,53,98,49,97,102,45,50,49,52,56,54,45,57,100,99,49,53,50,55,97,45,49,102,101,53,45,52,97,98,50,45,98,52,51,56,45,56,99,48,54,55,57,50,100,53,99,48,50,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v2_assignerMetadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,54,100,50,53,102,97,101,48,98,57,54,51,101,54,56,53,52,55,98,56,45,50,51,55,48,50,45,102,97,102,100,102,57,49,100,45,101,100,52,48,45,52,102,50,49,45,56,50,56,49,45,100,55,97,98,98,48,100,57,98,100,100,57,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,98,53,50,50,49,56,56,97,51,97,49,50,97,49,102,48,52,99,102,98,45,50,51,55,48,50,45,101,49,102,102,51,53,99,55,45,102,100,101,57,45,52,100,53,56,45,57,54,48,97,45,50,99,101,102,56,97,102,55,55,101,101,102,0,0,117,48,0,0,234,96,0,0,0,8,99,111,110,115,117,109,101,114,0,0,0,1,0,12,65,115,115,105,103,110,101,114,78,97,109,101,0,0,0,86,0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,54,100,50,53,102,97,101,48,98,57,54,51,101,54,56,53,52,55,98,56,45,50,51,55,48,50,45,102,97,102,100,102,57,49,100,45,101,100,52,48,45,52,102,50,49,45,56,50,56,49,45,100,55,97,98,98,48,100,57,98,100,100,57,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/fixtures/v5_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,98,53,50,50,49,56,56,97,51,97,49,50,97,49,102,48,52,99,102,98,45,50,51,55,48,50,45,101,49,102,102,51,53,99,55,45,102,100,101,57,45,52,100,53,56,45,57,54,48,97,45,50,99,101,102,56,97,102,55,55,101,101,102,0,0,117,48,0,0,234,96,0,0,0,17,103,114,111,117,112,45,105,110,115,116,97,110,99,101,45,105,100,0,8,99,111,110,115,117,109,101,114,0,0,0,1,0,12,65,115,115,105,103,110,101,114,78,97,109,101,0,0,0,86,0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,54,100,50,53,102,97,101,48,98,57,54,51,101,54,56,53,52,55,98,56,45,50,51,55,48,50,45,102,97,102,100,102,57,49,100,45,101,100,52,48,45,52,102,50,49,45,56,50,56,49,45,100,55,97,98,98,48,100,57,98,100,100,57,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | 5 | const parse = response.parse; 6 | const decode = response.decode; 7 | /** 8 | * JoinGroup Response (Version: 1) => error_code generation_id group_protocol leader_id member_id [members] 9 | * error_code => INT16 10 | * generation_id => INT32 11 | * group_protocol => STRING 12 | * leader_id => STRING 13 | * member_id => STRING 14 | * members => member_id member_metadata 15 | * member_id => STRING 16 | * member_metadata => BYTES 17 | */ 18 | 19 | export default { decode, parse }; 20 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/v2/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV1 from '../v1/request.ts'; 4 | 5 | /** 6 | * JoinGroup Request (Version: 2) => group_id session_timeout rebalance_timeout member_id protocol_type [group_protocols] 7 | * group_id => STRING 8 | * session_timeout => INT32 9 | * rebalance_timeout => INT32 10 | * member_id => STRING 11 | * protocol_type => STRING 12 | * group_protocols => protocol_name protocol_metadata 13 | * protocol_name => STRING 14 | * protocol_metadata => BYTES 15 | */ 16 | 17 | export default ({ 18 | groupId, 19 | sessionTimeout, 20 | rebalanceTimeout, 21 | memberId, 22 | protocolType, 23 | groupProtocols, 24 | }: any) => 25 | Object.assign( 26 | requestV1({ 27 | groupId, 28 | sessionTimeout, 29 | rebalanceTimeout, 30 | memberId, 31 | protocolType, 32 | groupProtocols, 33 | }), 34 | { apiVersion: 2 } 35 | ); 36 | -------------------------------------------------------------------------------- /src/protocol/requests/joinGroup/v3/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV2 from '../v2/request.ts'; 4 | 5 | /** 6 | * JoinGroup Request (Version: 3) => group_id session_timeout rebalance_timeout member_id protocol_type [group_protocols] 7 | * group_id => STRING 8 | * session_timeout => INT32 9 | * rebalance_timeout => INT32 10 | * member_id => STRING 11 | * protocol_type => STRING 12 | * group_protocols => protocol_name protocol_metadata 13 | * protocol_name => STRING 14 | * protocol_metadata => BYTES 15 | */ 16 | 17 | export default ({ 18 | groupId, 19 | sessionTimeout, 20 | rebalanceTimeout, 21 | memberId, 22 | protocolType, 23 | groupProtocols, 24 | }: any) => 25 | Object.assign( 26 | requestV2({ 27 | groupId, 28 | sessionTimeout, 29 | rebalanceTimeout, 30 | memberId, 31 | protocolType, 32 | groupProtocols, 33 | }), 34 | { apiVersion: 3 } 35 | ); 36 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,54,52,102,98,102,53,100,99,101,53,48,54,53,56,54,56,97,97,56,102,0,62,116,101,115,116,45,52,53,101,98,55,97,52,50,51,57,102,53,52,56,53,55,56,101,56,98,45,98,50,98,48,56,102,97,51,45,98,56,56,55,45,52,55,49,57,45,98,57,101,49,45,51,57,49,101,99,57,52,52,98,53,51,102]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,56,50,100,55,55,100,102,53,100,48,57,55,52,101,50,49,53,48,50,100,45,51,48,57,49,57,45,48,101,99,53,101,53,53,101,45,101,51,101,49,45,52,51,51,97,45,98,98,101,100,45,57,54,102,101,50,50,56,52,48,56,98,52,0,105,116,101,115,116,45,99,53,57,56,49,54,57,97,53,100,56,100,98,101,100,99,98,56,48,54,45,51,48,57,49,57,45,102,102,49,102,51,99,53,51,45,49,56,53,53,45,52,99,48,52,45,97,97,100,102,45,49,50,100,50,57,56,49,54,48,102,53,99,45,98,52,49,98,51,55,102,56,45,54,52,56,50,45,52,55,99,53,45,56,49,49,101,45,101,54,53,56,97,98,54,53,54,97,55,53]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,56,50,100,55,55,100,102,53,100,48,57,55,52,101,50,49,53,48,50,100,45,51,48,57,49,57,45,48,101,99,53,101,53,53,101,45,101,51,101,49,45,52,51,51,97,45,98,98,101,100,45,57,54,102,101,50,50,56,52,48,56,98,52,0,105,116,101,115,116,45,99,53,57,56,49,54,57,97,53,100,56,100,98,101,100,99,98,56,48,54,45,51,48,57,49,57,45,102,102,49,102,51,99,53,51,45,49,56,53,53,45,52,99,48,52,45,97,97,100,102,45,49,50,100,50,57,56,49,54,48,102,53,99,45,98,52,49,98,51,55,102,56,45,54,52,56,50,45,52,55,99,53,45,56,49,49,101,45,101,54,53,56,97,98,54,53,54,97,55,53]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v3_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,56,50,100,55,55,100,102,53,100,48,57,55,52,101,50,49,53,48,50,100,45,51,48,57,49,57,45,48,101,99,53,101,53,53,101,45,101,51,101,49,45,52,51,51,97,45,98,98,101,100,45,57,54,102,101,50,50,56,52,48,56,98,52,0,0,0,1,0,105,116,101,115,116,45,99,53,57,56,49,54,57,97,53,100,56,100,98,101,100,99,98,56,48,54,45,51,48,57,49,57,45,102,102,49,102,51,99,53,51,45,49,56,53,53,45,52,99,48,52,45,97,97,100,102,45,49,50,100,50,57,56,49,54,48,102,53,99,45,98,52,49,98,51,55,102,56,45,54,52,56,50,45,52,55,99,53,45,56,49,49,101,45,101,54,53,56,97,98,54,53,54,97,55,53,255,255]} -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,1,0,41,116,101,115,116,45,52,50,57,54,50,102,54,56,45,101,56,48,49,45,52,99,100,56,45,98,51,53,57,45,50,100,56,54,50,101,98,98,52,100,48,53,255,255,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/v0/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Encoder } from '../../../encoder.ts'; 4 | import apiKeys from '../../apiKeys.ts'; 5 | 6 | const apiKey = apiKeys.LeaveGroup; 7 | 8 | /** 9 | * LeaveGroup Request (Version: 0) => group_id member_id 10 | * group_id => STRING 11 | * member_id => STRING 12 | */ 13 | 14 | export default ({ groupId, memberId }: any) => ({ 15 | apiKey, 16 | apiVersion: 0, 17 | apiName: 'LeaveGroup', 18 | //deno-lint-ignore require-await 19 | encode: async () => { 20 | return new Encoder().writeString(groupId).writeString(memberId); 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/v0/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {Decoder} from '../../../decoder.ts'; 4 | import { 5 | failure, 6 | createErrorFromCode, 7 | failIfVersionNotSupported, 8 | } from '../../../error.ts'; 9 | 10 | /** 11 | * LeaveGroup Response (Version: 0) => error_code 12 | * error_code => INT16 13 | */ 14 | //deno-lint-ignore require-await 15 | const decode = async (rawData: any) => { 16 | const decoder = new Decoder(rawData); 17 | const errorCode = decoder.readInt16(); 18 | 19 | failIfVersionNotSupported(errorCode); 20 | 21 | return { errorCode }; 22 | }; 23 | //deno-lint-ignore require-await 24 | const parse = async (data: any) => { 25 | if (failure(data.errorCode)) { 26 | throw createErrorFromCode(data.errorCode); 27 | } 28 | 29 | return data; 30 | }; 31 | 32 | export default { 33 | decode, 34 | parse, 35 | }; 36 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * LeaveGroup Request (Version: 1) => group_id member_id 7 | * group_id => STRING 8 | * member_id => STRING 9 | */ 10 | 11 | export default ({ groupId, memberId }: any) => 12 | Object.assign(requestV0({ groupId, memberId }), { apiVersion: 1 }); 13 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Decoder } from '../../../decoder.ts'; 4 | import { failIfVersionNotSupported } from '../../../error.ts'; 5 | import response from '../v0/response.ts'; 6 | 7 | const parse = response.parse; 8 | 9 | /** 10 | * LeaveGroup Response (Version: 1) => throttle_time_ms error_code 11 | * throttle_time_ms => INT32 12 | * error_code => INT16 13 | */ 14 | //deno-lint-ignore require-await 15 | const decode = async (rawData: any) => { 16 | const decoder = new Decoder(rawData); 17 | const throttleTime = decoder.readInt32(); 18 | const errorCode = decoder.readInt16(); 19 | 20 | failIfVersionNotSupported(errorCode); 21 | 22 | return { throttleTime, errorCode }; 23 | }; 24 | 25 | export default { 26 | decode, 27 | parse, 28 | }; 29 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/v2/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV1 from '../v1/request.ts'; 4 | 5 | /** 6 | * LeaveGroup Request (Version: 2) => group_id member_id 7 | * group_id => STRING 8 | * member_id => STRING 9 | */ 10 | 11 | export default ({ groupId, memberId }: any) => 12 | Object.assign(requestV1({ groupId, memberId }), { apiVersion: 2 }); 13 | -------------------------------------------------------------------------------- /src/protocol/requests/leaveGroup/v2/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v1/response.ts'; 4 | const parse = response.parse; 5 | const decodeV1 = response.decode; 6 | /** 7 | * In version 2 on quota violation, brokers send out responses before throttling. 8 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 9 | * 10 | * LeaveGroup Response (Version: 2) => throttle_time_ms error_code 11 | * throttle_time_ms => INT32 12 | * error_code => INT16 13 | */ 14 | const decode = async (rawData: any) => { 15 | const decoded = await decodeV1(rawData); 16 | 17 | return { 18 | ...decoded, 19 | throttleTime: 0, 20 | clientSideThrottleTime: decoded.throttleTime, 21 | }; 22 | }; 23 | 24 | export default { 25 | decode, 26 | parse, 27 | }; 28 | -------------------------------------------------------------------------------- /src/protocol/requests/listGroups/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from './v0/request.ts'; 4 | import responseV0 from './v0/response.ts'; 5 | 6 | import requestV1 from './v1/request.ts'; 7 | import responseV1 from './v1/response.ts'; 8 | 9 | import requestV2 from './v2/request.ts'; 10 | import responseV2 from './v2/response.ts'; 11 | 12 | const versions: any = { 13 | 0: () => { 14 | const request = requestV0; 15 | const response = responseV0; 16 | return { request: request(), response }; 17 | }, 18 | 1: () => { 19 | const request = requestV1; 20 | const response = responseV1; 21 | return { request: request(), response }; 22 | }, 23 | 2: () => { 24 | const request = requestV2; 25 | const response = responseV2; 26 | return { request: request(), response }; 27 | }, 28 | }; 29 | 30 | export default { 31 | versions: Object.keys(versions), 32 | protocol: ({ version }: any) => versions[version], 33 | }; 34 | -------------------------------------------------------------------------------- /src/protocol/requests/listGroups/v0/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {Encoder} from '../../../encoder.ts'; 4 | import apiKeys from '../../apiKeys.ts'; 5 | const apiKey = apiKeys.ListGroups; 6 | /** 7 | * ListGroups Request (Version: 0) 8 | */ 9 | 10 | /** 11 | */ 12 | export default () => ({ 13 | apiKey, 14 | apiVersion: 0, 15 | apiName: 'ListGroups', 16 | //deno-lint-ignore require-await 17 | encode: async () => { 18 | return new Encoder(); 19 | }, 20 | }); 21 | -------------------------------------------------------------------------------- /src/protocol/requests/listGroups/v1/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * ListGroups Request (Version: 1) 7 | */ 8 | 9 | export default () => Object.assign(requestV0(), { apiVersion: 1 }); 10 | -------------------------------------------------------------------------------- /src/protocol/requests/listGroups/v1/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import {Buffer} from 'https://deno.land/std@0.110.0/node/buffer.ts' 3 | import responseV0 from '../v0/response.ts'; 4 | 5 | import {Decoder }from '../../../decoder.ts'; 6 | 7 | /** 8 | * ListGroups Response (Version: 1) => error_code [groups] 9 | * throttle_time_ms => INT32 10 | * error_code => INT16 11 | * groups => group_id protocol_type 12 | * group_id => STRING 13 | * protocol_type => STRING 14 | */ 15 | 16 | //deno-lint-ignore require-await 17 | const decode = async (rawData: Buffer) => { 18 | const decoder = new Decoder(rawData); 19 | const throttleTime = decoder.readInt32(); 20 | const errorCode = decoder.readInt16(); 21 | const groups = decoder.readArray(responseV0.decodeGroup); 22 | 23 | return { 24 | throttleTime, 25 | errorCode, 26 | groups, 27 | }; 28 | }; 29 | 30 | export default { 31 | decode, 32 | parse: responseV0.parse, 33 | }; 34 | -------------------------------------------------------------------------------- /src/protocol/requests/listGroups/v2/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV1 from '../v1/request.ts'; 4 | 5 | /** 6 | * ListGroups Request (Version: 2) 7 | */ 8 | 9 | export default () => Object.assign(requestV1(), { apiVersion: 2 }); 10 | -------------------------------------------------------------------------------- /src/protocol/requests/listGroups/v2/response.ts: -------------------------------------------------------------------------------- 1 | import {Buffer} from 'https://deno.land/std@0.110.0/node/buffer.ts' 2 | import _decode from '../v1/response.ts' 3 | const decodeV1 = _decode.decode 4 | const parse = _decode.parse 5 | /** 6 | * In version 2 on quota violation, brokers send out responses before throttling. 7 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 8 | * 9 | * ListGroups Response (Version: 2) => error_code [groups] 10 | * throttle_time_ms => INT32 11 | * error_code => INT16 12 | * groups => group_id protocol_type 13 | * group_id => STRING 14 | * protocol_type => STRING 15 | */ 16 | const decode = async (rawData: Buffer) => { 17 | const decoded = await decodeV1(rawData) 18 | 19 | return { 20 | ...decoded, 21 | throttleTime: 0, 22 | clientSideThrottleTime: decoded.throttleTime, 23 | } 24 | } 25 | 26 | export default { 27 | decode, 28 | parse, 29 | } 30 | -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,55,50,55,55,48,53,99,101,54,56,99,50,57,102,101,100,100,100,102,52,0,0,0,1,0,0,0,0,0,0,1,95,104,110,35,204,0,0,0,1]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,55,50,55,55,48,53,99,101,54,56,99,50,57,102,101,100,100,100,102,52,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,255,255,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,49,55,51,99,48,101,49,53,53,54,100,97,98,56,100,53,48,101,101,54,45,57,49,54,55,55,45,51,55,57,102,97,102,48,102,45,97,51,53,55,45,52,48,56,101,45,98,100,49,100,45,53,102,97,49,49,56,57,51,98,48,53,100,0,0,0,1,0,0,0,0,0,0,1,95,104,110,35,204]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,49,54,101,57,53,54,57,48,50,101,51,57,56,55,52,100,48,54,102,53,45,57,49,55,48,53,45,50,57,53,56,97,52,55,50,45,101,53,56,50,45,52,55,97,52,45,56,54,102,48,45,98,50,53,56,54,51,48,102,98,51,101,54,0,0,0,1,0,0,0,0,0,0,0,0,1,103,86,106,223,30,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"data": [255,255,255,255,0,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,55,50,55,55,48,53,99,101,54,56,99,50,57,102,101,100,100,100,102,52,0,0,0,1,0,0,0,0,0,0,1,95,104,110,35,204],"type": "Buffer"} -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,56,52,101,102,101,55,97,97,97,102,99,51,56,52,52,98,48,48,99,49,45,51,54,50,49,49,45,50,101,101,52,51,49,98,52,45,100,52,48,98,45,52,100,102,56,45,98,50,99,56,45,102,99,57,101,51,51,97,98,53,99,55,55,0,0,0,1,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,1]} -------------------------------------------------------------------------------- /src/protocol/requests/listOffsets/v3/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV2 from '../v2/request.ts'; 4 | 5 | /** 6 | * ListOffsets Request (Version: 3) => replica_id isolation_level [topics] 7 | * replica_id => INT32 8 | * isolation_level => INT8 9 | * topics => topic [partitions] 10 | * topic => STRING 11 | * partitions => partition timestamp 12 | * partition => INT32 13 | * timestamp => INT64 14 | */ 15 | export default ({ replicaId, isolationLevel, topics }: any) => 16 | Object.assign(requestV2({ replicaId, isolationLevel, topics }), { 17 | apiVersion: 3, 18 | }); 19 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,3,0,0,0,2,0,13,49,57,50,46,49,54,56,46,49,46,49,55,51,0,0,35,138,255,255,0,0,0,1,0,13,49,57,50,46,49,54,56,46,49,46,49,55,51,0,0,35,135,255,255,0,0,0,0,0,13,49,57,50,46,49,54,56,46,49,46,49,55,51,0,0,35,132,255,255,0,22,81,48,87,79,51,117,95,84,84,65,101,115,108,70,68,74,87,105,105,71,118,65,0,0,0,1,0,0,0,1,0,0,0,31,116,101,115,116,45,116,111,112,105,99,45,48,102,54,55,99,55,57,48,48,55,99,57,49,53,55,102,99,56,51,100,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/fixtures/v4_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,3,0,0,0,2,0,13,49,57,50,46,49,54,56,46,49,46,49,55,51,0,0,35,138,255,255,0,0,0,1,0,13,49,57,50,46,49,54,56,46,49,46,49,55,51,0,0,35,135,255,255,0,0,0,0,0,13,49,57,50,46,49,54,56,46,49,46,49,55,51,0,0,35,132,255,255,0,22,81,48,87,79,51,117,95,84,84,65,101,115,108,70,68,74,87,105,105,71,118,65,0,0,0,1,0,0,0,1,0,0,0,31,116,101,115,116,45,116,111,112,105,99,45,54,54,100,49,100,102,53,53,101,99,50,55,101,48,51,51,100,55,50,54,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/fixtures/v5_offline_replicas_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,2,0,0,0,1,0,12,49,48,46,51,46,50,50,51,46,49,50,49,0,0,35,135,255,255,0,0,0,0,0,12,49,48,46,51,46,50,50,51,46,49,50,49,0,0,35,132,255,255,0,22,116,68,114,52,68,103,70,115,83,57,54,115,79,69,90,117,54,101,45,78,45,81,0,0,0,1,0,0,0,2,0,0,0,10,116,111,112,105,99,45,116,101,115,116,0,0,0,0,6,0,5,0,0,0,2,255,255,255,255,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,2,0,5,0,0,0,5,255,255,255,255,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,16,116,101,115,116,45,116,111,112,105,99,45,116,111,109,109,121,0,0,0,0,1,0,5,0,0,0,0,255,255,255,255,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,2]} -------------------------------------------------------------------------------- /src/protocol/requests/metadata/fixtures/v5_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,3,0,0,0,2,0,11,49,48,46,51,46,50,50,48,46,56,57,0,0,35,138,255,255,0,0,0,1,0,11,49,48,46,51,46,50,50,48,46,56,57,0,0,35,135,255,255,0,0,0,0,0,11,49,48,46,51,46,50,50,48,46,56,57,0,0,35,132,255,255,0,22,119,121,79,69,107,48,109,55,84,110,45,48,56,111,71,90,106,116,86,103,69,103,0,0,0,2,0,0,0,1,0,0,0,74,116,101,115,116,45,116,111,112,105,99,45,102,53,101,49,55,97,56,54,56,57,54,101,98,102,100,101,98,52,50,57,45,56,48,56,50,57,45,97,51,55,98,54,100,100,101,45,49,97,100,99,45,52,54,56,55,45,56,49,51,100,45,53,50,100,55,53,97,48,97,48,102,55,56,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v0/request.ts: -------------------------------------------------------------------------------- 1 | import {Encoder} from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | 4 | const apiKey = apiKeys.Metadata; 5 | 6 | /** 7 | * Metadata Request (Version: 0) => [topics] 8 | * topics => STRING 9 | */ 10 | 11 | export default ({ 12 | topics 13 | }: any) => ({ 14 | apiKey, 15 | apiVersion: 0, 16 | apiName: 'Metadata', 17 | //deno-lint-ignore require-await 18 | encode: async () => { 19 | return new Encoder().writeArray(topics) 20 | }, 21 | }) 22 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * Metadata Request (Version: 1) => [topics] 5 | * topics => STRING 6 | */ 7 | 8 | export default ({ 9 | topics 10 | }: any) => Object.assign(requestV0({ topics }), { apiVersion: 1 }) 11 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * Metadata Request (Version: 2) => [topics] 5 | * topics => STRING 6 | */ 7 | 8 | export default ({ 9 | topics 10 | }: any) => Object.assign(requestV0({ topics }), { apiVersion: 2 }) 11 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v3/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV0 from '../v0/request.ts'; 4 | 5 | /** 6 | * Metadata Request (Version: 3) => [topics] 7 | * topics => STRING 8 | */ 9 | 10 | export default ({ topics }: any) => 11 | Object.assign(requestV0({ topics }), { apiVersion: 3 }); 12 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v4/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {Encoder} from '../../../encoder.ts'; 4 | import apiKeys from '../../apiKeys.ts'; 5 | 6 | const apiKey = apiKeys.Metadata; 7 | /** 8 | * Metadata Request (Version: 4) => [topics] allow_auto_topic_creation 9 | * topics => STRING 10 | * allow_auto_topic_creation => BOOLEAN 11 | */ 12 | 13 | export default ({ topics, allowAutoTopicCreation = true }: any) => ({ 14 | apiKey, 15 | apiVersion: 4, 16 | apiName: 'Metadata', 17 | //deno-lint-ignore require-await 18 | encode: async () => { 19 | return new Encoder() 20 | .writeNullableArray(topics) 21 | .writeBoolean(allowAutoTopicCreation); 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v5/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV4 from '../v4/request.ts'; 4 | 5 | /** 6 | * Metadata Request (Version: 5) => [topics] allow_auto_topic_creation 7 | * topics => STRING 8 | * allow_auto_topic_creation => BOOLEAN 9 | */ 10 | 11 | export default ({ topics, allowAutoTopicCreation = true }: any) => 12 | Object.assign(requestV4({ topics, allowAutoTopicCreation }), { 13 | apiVersion: 5, 14 | }); 15 | -------------------------------------------------------------------------------- /src/protocol/requests/metadata/v6/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV5 from '../v5/request.ts'; 4 | 5 | /** 6 | * Metadata Request (Version: 6) => [topics] allow_auto_topic_creation 7 | * topics => STRING 8 | * allow_auto_topic_creation => BOOLEAN 9 | */ 10 | 11 | export default ({ topics, allowAutoTopicCreation = true }: any) => 12 | Object.assign(requestV5({ topics, allowAutoTopicCreation }), { 13 | apiVersion: 6, 14 | }); 15 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,57,101,97,53,98,56,53,52,55,49,51,49,54,100,50,55,53,51,97,98,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,101,98,49,97,50,56,53,99,100,97,50,101,57,102,57,97,49,48,50,49,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v0_request_metadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,57,101,97,53,98,56,53,52,55,49,51,49,54,100,50,55,53,51,97,98,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,101,98,49,97,50,56,53,99,100,97,50,101,57,102,57,97,49,48,50,49,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,4,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,101,98,49,97,50,56,53,99,100,97,50,101,57,102,57,97,49,48,50,49,0,0,0,1,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,50,53,99,57,97,49,52,55,52,55,51,51,98,50,56,51,101,54,99,54,0,0,0,1,0,62,116,101,115,116,45,100,48,48,49,102,50,101,55,99,49,100,55,48,52,101,100,51,48,102,55,45,49,99,102,51,50,100,97,97,45,54,52,101,51,45,52,51,48,53,45,97,48,97,53,45,100,98,52,48,56,56,100,102,98,52,101,98,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,99,49,53,56,49,99,55,53,54,56,56,57,101,56,55,55,51,100,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,95,104,221,157,156,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v1_request_metadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,50,53,99,57,97,49,52,55,52,55,51,51,98,50,56,51,101,54,99,54,0,0,0,1,0,62,116,101,115,116,45,100,48,48,49,102,50,101,55,99,49,100,55,48,52,101,100,51,48,102,55,45,49,99,102,51,50,100,97,97,45,54,52,101,51,45,52,51,48,53,45,97,48,97,53,45,100,98,52,48,56,56,100,102,98,52,101,98,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,99,49,53,56,49,99,55,53,54,56,56,57,101,56,55,55,51,100,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,95,104,221,157,156,0,4,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,101,98,49,97,50,56,53,99,100,97,50,101,57,102,57,97,49,48,50,49,0,0,0,1,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,51,97,49,54,52,54,101,51,101,57,50,55,101,48,53,99,100,48,99,50,0,0,0,1,0,62,116,101,115,116,45,56,97,97,99,49,48,50,57,54,100,57,52,57,98,49,54,50,55,48,56,45,54,102,102,54,51,100,100,102,45,49,97,53,97,45,52,102,48,53,45,57,50,57,99,45,49,55,49,53,56,56,55,53,97,97,55,102,255,255,255,255,255,255,255,255,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,49,54,55,48,48,48,49,50,49,99,50,52,50,99,51,54,49,52,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v2_request_metadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,51,97,49,54,52,54,101,51,101,57,50,55,101,48,53,99,100,48,99,50,0,0,0,1,0,62,116,101,115,116,45,56,97,97,99,49,48,50,57,54,100,57,52,57,98,49,54,50,55,48,56,45,54,102,102,54,51,100,100,102,45,49,97,53,97,45,52,102,48,53,45,57,50,57,99,45,49,55,49,53,56,56,55,53,97,97,55,102,255,255,255,255,255,255,255,255,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,49,54,55,48,48,48,49,50,49,99,50,52,50,99,51,54,49,52,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,4,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,101,98,49,97,50,56,53,99,100,97,50,101,57,102,57,97,49,48,50,49,0,0,0,1,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v3_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,80,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,97,50,56,48,54,55,52,51,57,100,54,49,57,52,97,57,54,50,53,45,57,57,56,53,45,99,98,98,56,49,97,57,55,45,53,49,53,49,45,52,54,53,56,45,97,48,53,53,45,99,52,55,57,49,52,55,98,49,48,55,100,0,0,0,1,0,104,116,101,115,116,45,102,53,101,51,53,57,102,102,97,55,98,50,53,55,56,97,99,97,52,98,45,57,57,56,53,45,54,48,100,99,100,48,100,97,45,49,49,51,48,45,52,101,97,97,45,57,57,97,97,45,57,98,100,56,48,102,51,57,101,99,101,98,45,52,52,50,54,99,101,49,57,45,56,49,52,57,45,52,100,54,52,45,98,56,99,51,45,56,52,49,100,51,98,98,55,99,97,50,54,255,255,255,255,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v3_request_metadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,80,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,97,50,56,48,54,55,52,51,57,100,54,49,57,52,97,57,54,50,53,45,57,57,56,53,45,99,98,98,56,49,97,57,55,45,53,49,53,49,45,52,54,53,56,45,97,48,53,53,45,99,52,55,57,49,52,55,98,49,48,55,100,0,0,0,1,0,104,116,101,115,116,45,102,53,101,51,53,57,102,102,97,55,98,50,53,55,56,97,99,97,52,98,45,57,57,56,53,45,54,48,100,99,100,48,100,97,45,49,49,51,48,45,52,101,97,97,45,57,57,97,97,45,57,98,100,56,48,102,51,57,101,99,101,98,45,52,52,50,54,99,101,49,57,45,56,49,52,57,45,52,100,54,52,45,98,56,99,51,45,56,52,49,100,51,98,98,55,99,97,50,54,255,255,255,255,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,4,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v4_request.json.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,80,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,97,50,56,48,54,55,52,51,57,100,54,49,57,52,97,57,54,50,53,45,57,57,56,53,45,99,98,98,56,49,97,57,55,45,53,49,53,49,45,52,54,53,56,45,97,48,53,53,45,99,52,55,57,49,52,55,98,49,48,55,100,0,0,0,1,0,104,116,101,115,116,45,102,53,101,51,53,57,102,102,97,55,98,50,53,55,56,97,99,97,52,98,45,57,57,56,53,45,54,48,100,99,100,48,100,97,45,49,49,51,48,45,52,101,97,97,45,57,57,97,97,45,57,98,100,56,48,102,51,57,101,99,101,98,45,52,52,50,54,99,101,49,57,45,56,49,52,57,45,52,100,54,52,45,98,56,99,51,45,56,52,49,100,51,98,98,55,99,97,50,54,255,255,255,255,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v4_request_metadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,80,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,97,50,56,48,54,55,52,51,57,100,54,49,57,52,97,57,54,50,53,45,57,57,56,53,45,99,98,98,56,49,97,57,55,45,53,49,53,49,45,52,54,53,56,45,97,48,53,53,45,99,52,55,57,49,52,55,98,49,48,55,100,0,0,0,1,0,104,116,101,115,116,45,102,53,101,51,53,57,102,102,97,55,98,50,53,55,56,97,99,97,52,98,45,57,57,56,53,45,54,48,100,99,100,48,100,97,45,49,49,51,48,45,52,101,97,97,45,57,57,97,97,45,57,98,100,56,48,102,51,57,101,99,101,98,45,52,52,50,54,99,101,49,57,45,56,49,52,57,45,52,100,54,52,45,98,56,99,51,45,56,52,49,100,51,98,98,55,99,97,50,54,255,255,255,255,255,255,255,255,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,4,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v4_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v5_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,80,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,97,50,56,48,54,55,52,51,57,100,54,49,57,52,97,57,54,50,53,45,57,57,56,53,45,99,98,98,56,49,97,57,55,45,53,49,53,49,45,52,54,53,56,45,97,48,53,53,45,99,52,55,57,49,52,55,98,49,48,55,100,0,0,0,1,0,104,116,101,115,116,45,102,53,101,51,53,57,102,102,97,55,98,50,53,55,56,97,99,97,52,98,45,57,57,56,53,45,54,48,100,99,100,48,100,97,45,49,49,51,48,45,52,101,97,97,45,57,57,97,97,45,57,98,100,56,48,102,51,57,101,99,101,98,45,52,52,50,54,99,101,49,57,45,56,49,52,57,45,52,100,54,52,45,98,56,99,51,45,56,52,49,100,51,98,98,55,99,97,50,54,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v5_request_metadata.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,80,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,97,50,56,48,54,55,52,51,57,100,54,49,57,52,97,57,54,50,53,45,57,57,56,53,45,99,98,98,56,49,97,57,55,45,53,49,53,49,45,52,54,53,56,45,97,48,53,53,45,99,52,55,57,49,52,55,98,49,48,55,100,0,0,0,1,0,104,116,101,115,116,45,102,53,101,51,53,57,102,102,97,55,98,50,53,55,56,97,99,97,52,98,45,57,57,56,53,45,54,48,100,99,100,48,100,97,45,49,49,51,48,45,52,101,97,97,45,57,57,97,97,45,57,98,100,56,48,102,51,57,101,99,101,98,45,52,52,50,54,99,101,49,57,45,56,49,52,57,45,52,100,54,52,45,98,56,99,51,45,56,52,49,100,51,98,98,55,99,97,50,54,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,4,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/fixtures/v5_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,53,99,50,52,101,102,101,48,97,99,52,49,98,57,49,98,101,101,56,53,45,57,57,56,53,45,56,52,49,100,54,49,52,53,45,99,56,57,55,45,52,52,55,49,45,98,100,48,57,45,97,99,100,56,98,52,99,57,48,53,102,50,0,0,0,1,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/v1/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v0/response.ts' 2 | 3 | const parse = response.parse 4 | const decode = response.decode 5 | 6 | /** 7 | * OffsetCommit Response (Version: 1) => [responses] 8 | * responses => topic [partition_responses] 9 | * topic => STRING 10 | * partition_responses => partition error_code 11 | * partition => INT32 12 | * error_code => INT16 13 | */ 14 | 15 | export default { 16 | decode, 17 | parse, 18 | } 19 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/v2/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v0/response.ts'; 4 | const parse = response.parse; 5 | const decode = response.decode; 6 | /** 7 | * OffsetCommit Response (Version: 1) => [responses] 8 | * responses => topic [partition_responses] 9 | * topic => STRING 10 | * partition_responses => partition error_code 11 | * partition => INT32 12 | * error_code => INT16 13 | */ 14 | 15 | export default { 16 | decode, 17 | parse, 18 | }; 19 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/v3/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV2 from '../v2/request.ts'; 4 | 5 | /** 6 | * OffsetCommit Request (Version: 3) => group_id generation_id member_id retention_time [topics] 7 | * group_id => STRING 8 | * generation_id => INT32 9 | * member_id => STRING 10 | * retention_time => INT64 11 | * topics => topic [partitions] 12 | * topic => STRING 13 | * partitions => partition offset metadata 14 | * partition => INT32 15 | * offset => INT64 16 | * metadata => NULLABLE_STRING 17 | */ 18 | 19 | export default ({ 20 | groupId, 21 | groupGenerationId, 22 | memberId, 23 | retentionTime, 24 | topics, 25 | }: any) => 26 | Object.assign( 27 | requestV2({ groupId, groupGenerationId, memberId, retentionTime, topics }), 28 | { 29 | apiVersion: 3, 30 | } 31 | ); 32 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/v4/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import requestV3 from '../v3/request.ts'; 4 | 5 | /** 6 | * OffsetCommit Request (Version: 4) => group_id generation_id member_id retention_time [topics] 7 | * group_id => STRING 8 | * generation_id => INT32 9 | * member_id => STRING 10 | * retention_time => INT64 11 | * topics => topic [partitions] 12 | * topic => STRING 13 | * partitions => partition offset metadata 14 | * partition => INT32 15 | * offset => INT64 16 | * metadata => NULLABLE_STRING 17 | */ 18 | 19 | export default ({ 20 | groupId, 21 | groupGenerationId, 22 | memberId, 23 | retentionTime, 24 | topics, 25 | }: any) => 26 | Object.assign( 27 | requestV3({ groupId, groupGenerationId, memberId, retentionTime, topics }), 28 | { 29 | apiVersion: 4, 30 | } 31 | ); 32 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/v4/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v3/response.ts'; 4 | const parse = response.parse; 5 | const decodeV3 = response.decode; 6 | /** 7 | * Starting in version 4, on quota violation, brokers send out responses before throttling. 8 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 9 | * 10 | * OffsetCommit Response (Version: 4) => throttle_time_ms [responses] 11 | * throttle_time_ms => INT32 12 | * responses => topic [partition_responses] 13 | * topic => STRING 14 | * partition_responses => partition error_code 15 | * partition => INT32 16 | * error_code => INT16 17 | */ 18 | 19 | const decode = async (rawData: any) => { 20 | const decoded = await decodeV3(rawData); 21 | 22 | return { 23 | ...decoded, 24 | throttleTime: 0, 25 | clientSideThrottleTime: decoded.throttleTime, 26 | }; 27 | }; 28 | 29 | export default { decode, parse }; 30 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetCommit/v5/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import response from '../v4/response.ts'; 4 | 5 | const parse = response.parse; 6 | const decode = response.decode; 7 | 8 | /** 9 | * OffsetCommit Response (Version: 5) => throttle_time_ms [responses] 10 | * throttle_time_ms => INT32 11 | * responses => topic [partition_responses] 12 | * topic => STRING 13 | * partition_responses => partition error_code 14 | * partition => INT32 15 | * error_code => INT16 16 | */ 17 | export default { 18 | decode, 19 | parse, 20 | }; 21 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/fixtures/v1_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,55,100,99,98,50,52,55,51,98,54,97,49,49,57,54,98,50,98,50,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,102,57,98,48,55,52,48,53,55,97,99,100,52,51,51,53,57,52,54,0,0,0,1,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,102,57,98,48,55,52,48,53,55,97,99,100,52,51,51,53,57,52,54,0,0,0,1,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/fixtures/v2_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,38,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,99,55,100,99,98,50,52,55,51,98,54,97,49,49,57,54,98,50,98,50,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,102,57,98,48,55,52,48,53,55,97,99,100,52,51,51,53,57,52,54,0,0,0,1,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,50,99,98,98,100,54,101,54,51,54,50,102,49,97,54,51,56,99,57,52,0,0,0,1,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/fixtures/v3_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,81,99,111,110,115,117,109,101,114,45,103,114,111,117,112,45,105,100,45,100,49,52,57,50,100,55,97,51,99,49,52,97,56,51,56,97,50,56,102,45,50,48,49,49,55,45,97,101,56,50,55,56,49,98,45,56,54,51,100,45,52,102,50,51,45,57,51,55,55,45,100,49,54,53,99,97,53,56,53,102,51,49,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,100,102,52,56,50,52,49,99,52,98,102,50,102,99,97,57,100,49,54,98,45,50,48,49,49,55,45,97,102,102,57,98,54,52,99,45,54,57,97,50,45,52,52,53,54,45,98,101,55,98,45,100,101,53,98,99,100,55,56,57,56,52,101,0,0,0,1,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,100,102,52,56,50,52,49,99,52,98,102,50,102,99,97,57,100,49,54,98,45,50,48,49,49,55,45,97,102,102,57,98,54,52,99,45,54,57,97,50,45,52,52,53,54,45,98,101,55,98,45,100,101,53,98,99,100,55,56,57,56,52,101,0,0,0,1,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV1 from '../v1/request.ts' 2 | 3 | /** 4 | * OffsetFetch Request (Version: 2) => group_id [topics] 5 | * group_id => STRING 6 | * topics => topic [partitions] 7 | * topic => STRING 8 | * partitions => partition 9 | * partition => INT32 10 | */ 11 | 12 | export default ({ 13 | groupId, 14 | topics 15 | }: any) => 16 | Object.assign(requestV1({ groupId, topics }), { apiVersion: 2 }) 17 | -------------------------------------------------------------------------------- /src/protocol/requests/offsetFetch/v4/request.ts: -------------------------------------------------------------------------------- 1 | import requestV3 from '../v3/request.ts' 2 | 3 | /** 4 | * OffsetFetch Request (Version: 4) => group_id [topics] 5 | * group_id => STRING 6 | * topics => topic [partitions] 7 | * topic => STRING 8 | * partitions => partition 9 | * partition => INT32 10 | */ 11 | 12 | export default ({ 13 | groupId, 14 | topics 15 | }: any) => 16 | Object.assign(requestV3({ groupId, topics }), { apiVersion: 4 }) 17 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v2_request_gzip_darwin.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,0,0,117,48,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,52,51,51,57,53,102,54,49,56,97,56,56,53,57,50,48,50,51,56,99,0,0,0,1,0,0,0,0,0,0,0,229,0,0,0,0,0,0,0,0,0,0,0,217,62,126,31,104,1,1,0,0,1,95,142,187,58,12,255,255,255,255,0,0,0,195,31,139,8,0,0,0,0,0,0,19,101,204,77,10,194,48,16,5,224,214,181,7,112,215,19,20,146,76,50,201,120,4,161,103,144,252,76,54,42,10,162,32,130,23,16,188,128,91,193,67,184,114,227,41,60,140,45,20,23,237,91,61,120,188,175,40,254,105,206,215,199,179,108,75,185,188,189,230,211,182,204,86,124,170,147,178,89,41,43,179,209,218,102,70,101,4,180,91,181,223,110,184,62,250,245,129,107,70,237,1,128,201,161,51,64,134,80,65,143,118,94,115,95,124,63,99,24,2,99,22,193,49,70,114,54,9,207,41,14,96,171,12,9,141,49,39,239,132,9,66,90,197,61,60,233,224,221,251,82,141,97,159,201,57,37,131,134,246,149,208,123,205,110,0,147,14,196,22,137,35,176,22,50,228,100,236,15,160,153,83,117,11,1,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v2_request_gzip_linux.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[255,255,0,0,117,48,0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,52,51,51,57,53,102,54,49,56,97,56,56,53,57,50,48,50,51,56,99,0,0,0,1,0,0,0,0,0,0,0,229,0,0,0,0,0,0,0,0,0,0,0,217,17,117,86,246,1,1,0,0,1,95,142,187,58,12,255,255,255,255,0,0,0,195,31,139,8,0,0,0,0,0,0,3,101,204,77,10,194,48,16,5,224,214,181,7,112,215,19,20,146,76,50,201,120,4,161,103,144,252,76,54,42,10,162,32,130,23,16,188,128,91,193,67,184,114,227,41,60,140,45,20,23,237,91,61,120,188,175,40,254,105,206,215,199,179,108,75,185,188,189,230,211,182,204,86,124,170,147,178,89,41,43,179,209,218,102,70,101,4,180,91,181,223,110,184,62,250,245,129,107,70,237,1,128,201,161,51,64,134,80,65,143,118,94,115,95,124,63,99,24,2,99,22,193,49,70,114,54,9,207,41,14,96,171,12,9,141,49,39,239,132,9,66,90,197,61,60,233,224,221,251,82,141,97,159,201,57,37,131,134,246,149,208,123,205,110,0,147,14,196,22,137,35,176,22,50,228,100,236,15,160,153,83,117,11,1,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,57,49,57,102,98,52,52,101,57,49,50,97,99,48,100,99,50,54,57,51,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,255,255,255,255,255,255,255,255,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v2_response_gzip.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,98,99,54,55,52,99,51,48,53,55,50,101,56,100,101,100,56,56,54,97,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,255,255,255,255,255,255,255,255,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,31,116,101,115,116,45,116,111,112,105,99,45,101,98,98,97,54,56,56,55,57,99,54,102,53,48,56,49,100,56,99,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v4_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,53,51,55,48,99,101,50,99,56,49,51,54,54,51,102,99,101,51,99,97,45,57,57,55,53,56,45,52,100,57,101,97,55,51,49,45,53,97,50,51,45,52,100,53,98,45,97,98,98,100,45,56,51,57,48,53,56,56,100,54,53,53,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v5_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,72,116,101,115,116,45,116,111,112,105,99,45,49,99,56,97,99,101,48,101,99,102,98,51,99,98,50,56,49,50,52,51,45,55,48,54,45,98,57,102,50,52,97,99,49,45,54,97,49,101,45,52,52,53,56,45,98,97,53,102,45,53,102,99,48,99,53,49,97,52,54,99,55,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v6_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,73,116,101,115,116,45,116,111,112,105,99,45,51,57,48,56,53,48,52,53,51,98,49,99,48,48,52,48,51,57,101,97,45,49,52,49,55,45,49,99,51,50,97,53,48,55,45,101,100,98,98,45,52,56,49,100,45,57,100,57,99,45,101,50,56,55,55,52,51,102,52,98,55,52,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/produce/fixtures/v7_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,1,0,72,116,101,115,116,45,116,111,112,105,99,45,57,50,51,48,51,48,98,57,57,55,97,54,50,54,99,50,51,49,53,56,45,53,49,55,45,98,100,97,102,56,55,102,102,45,54,97,98,51,45,52,98,97,54,45,97,99,50,51,45,97,100,52,54,51,100,53,50,51,48,99,100,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/produce/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | // Produce Request on or after v1 indicates the client can parse the quota throttle time 4 | // in the Produce Response. 5 | 6 | export default ({ 7 | acks, 8 | timeout, 9 | topicData 10 | }: any) => { 11 | return Object.assign(requestV0({ acks, timeout, topicData }), { apiVersion: 1 }) 12 | } 13 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/v4/request.ts: -------------------------------------------------------------------------------- 1 | import requestV3 from '../v3/request.ts' 2 | 3 | /** 4 | * Produce Request (Version: 4) => transactional_id acks timeout [topic_data] 5 | * transactional_id => NULLABLE_STRING 6 | * acks => INT16 7 | * timeout => INT32 8 | * topic_data => topic [data] 9 | * topic => STRING 10 | * data => partition record_set 11 | * partition => INT32 12 | * record_set => RECORDS 13 | */ 14 | 15 | export default ({ 16 | acks, 17 | timeout, 18 | transactionalId, 19 | producerId, 20 | producerEpoch, 21 | compression, 22 | topicData 23 | }: any) => 24 | Object.assign( 25 | requestV3({ 26 | acks, 27 | timeout, 28 | transactionalId, 29 | producerId, 30 | producerEpoch, 31 | compression, 32 | topicData, 33 | }), 34 | { apiVersion: 4 } 35 | ) 36 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/v4/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v3/response.ts' 2 | 3 | const {parse, decode} = response; 4 | 5 | /** 6 | * Produce Response (Version: 4) => [responses] throttle_time_ms 7 | * responses => topic [partition_responses] 8 | * topic => STRING 9 | * partition_responses => partition error_code base_offset log_append_time 10 | * partition => INT32 11 | * error_code => INT16 12 | * base_offset => INT64 13 | * log_append_time => INT64 14 | * throttle_time_ms => INT32 15 | */ 16 | 17 | export default{ 18 | decode, 19 | parse, 20 | } 21 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/v5/request.ts: -------------------------------------------------------------------------------- 1 | import requestV3 from '../v3/request.ts' 2 | 3 | /** 4 | * Produce Request (Version: 5) => transactional_id acks timeout [topic_data] 5 | * transactional_id => NULLABLE_STRING 6 | * acks => INT16 7 | * timeout => INT32 8 | * topic_data => topic [data] 9 | * topic => STRING 10 | * data => partition record_set 11 | * partition => INT32 12 | * record_set => RECORDS 13 | */ 14 | 15 | export default ({ 16 | acks, 17 | timeout, 18 | transactionalId, 19 | producerId, 20 | producerEpoch, 21 | compression, 22 | topicData 23 | }: any) => 24 | Object.assign( 25 | requestV3({ 26 | acks, 27 | timeout, 28 | transactionalId, 29 | producerId, 30 | producerEpoch, 31 | compression, 32 | topicData, 33 | }), 34 | { apiVersion: 5 } 35 | ) 36 | -------------------------------------------------------------------------------- /src/protocol/requests/produce/v7/response.ts: -------------------------------------------------------------------------------- 1 | 2 | import response from '../v6/response.ts' 3 | 4 | const {parse, decode} = response; 5 | 6 | /** 7 | * Produce Response (Version: 7) => [responses] throttle_time_ms 8 | * responses => topic [partition_responses] 9 | * topic => STRING 10 | * partition_responses => partition error_code base_offset log_append_time log_start_offset 11 | * partition => INT32 12 | * error_code => INT16 13 | * base_offset => INT64 14 | * log_append_time => INT64 15 | * log_start_offset => INT64 16 | * throttle_time_ms => INT32 17 | */ 18 | 19 | export default { 20 | decode, 21 | parse, 22 | } 23 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/plain_bytes.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,14,0,116,101,115,116,0,116,101,115,116,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/scram256_bytes.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,39,110,44,44,110,61,116,101,115,116,115,99,114,97,109,44,114,61,75,121,120,110,102,72,51,108,65,122,87,102,78,77,114,104,75,98,80,112,49,103]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/scram256_firstRequest_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,96,114,61,75,121,120,110,102,72,51,108,65,122,87,102,78,77,114,104,75,98,80,112,49,103,49,97,52,122,122,99,105,113,122,51,118,52,116,53,109,119,103,50,56,100,122,56,117,103,107,50,44,115,61,77,87,111,121,77,50,120,53,89,87,100,53,98,72,111,49,78,50,120,122,99,71,100,115,97,50,70,106,90,51,108,105,77,106,103,61,44,105,61,56,49,57,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/scram256_firstRequest_response_v1.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,96,114,61,76,108,116,84,78,112,89,71,122,98,121,108,118,100,103,66,74,108,57,114,111,119,49,55,104,106,114,119,106,99,120,108,122,55,108,116,112,57,113,119,117,98,109,50,112,99,51,55,44,115,61,77,110,100,118,78,50,111,51,77,106,81,120,101,106,86,114,101,71,53,119,77,110,82,114,99,110,65,48,98,87,99,121,77,65,61,61,44,105,61,56,49,57,50]} -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/v0_request_plain.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,14,0,116,101,115,116,0,116,101,115,116,116,101,115,116]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/v0_request_scram256.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,39,110,44,44,110,61,116,101,115,116,115,99,114,97,109,44,114,61,75,121,120,110,102,72,51,108,65,122,87,102,78,77,114,104,75,98,80,112,49,103]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/v0_response_plain.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,255,255,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/v0_response_scram256.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,255,255,0,0,0,96,114,61,75,121,120,110,102,72,51,108,65,122,87,102,78,77,114,104,75,98,80,112,49,103,49,97,52,122,122,99,105,113,122,51,118,52,116,53,109,119,103,50,56,100,122,56,117,103,107,50,44,115,61,77,87,111,121,77,50,120,53,89,87,100,53,98,72,111,49,78,50,120,122,99,71,100,115,97,50,70,106,90,51,108,105,77,106,103,61,44,105,61,56,49,57,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/v1_response_plain.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,255,255,0,0,0,0,0,0,0,0,0,5,126,64]} -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/fixtures/v1_response_scram256.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,255,255,0,0,0,96,114,61,76,108,116,84,78,112,89,71,122,98,121,108,118,100,103,66,74,108,57,114,111,119,49,55,104,106,114,119,106,99,120,108,122,55,108,116,112,57,113,119,117,98,109,50,112,99,51,55,44,115,61,77,110,100,118,78,50,111,51,77,106,81,120,101,106,86,114,101,71,53,119,77,110,82,114,99,110,65,48,98,87,99,121,77,65,61,61,44,105,61,56,49,57,50,0,0,0,0,0,5,126,64]} -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v0/response.ts' 3 | import requestV1 from './v1/request.ts' 4 | import responseV1 from './v1/response.ts' 5 | 6 | 7 | 8 | const versions : Record = { 9 | 0: ({ 10 | authBytes 11 | }: any) => { 12 | const request = requestV0 13 | const response = responseV0 14 | return { request: request({ authBytes }), response } 15 | }, 16 | 1: ({ 17 | authBytes 18 | }: any) => { 19 | const request = requestV1 20 | const response = responseV1 21 | return { request: request({ authBytes }), response } 22 | }, 23 | } 24 | 25 | export default { 26 | versions: Object.keys(versions), 27 | protocol: ({ 28 | version 29 | }: any) => versions[version], 30 | } 31 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/v0/request.ts: -------------------------------------------------------------------------------- 1 | import { Encoder } from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | const apiKey = apiKeys.SaslAuthenticate; 4 | /** 5 | * SaslAuthenticate Request (Version: 0) => sasl_auth_bytes 6 | * sasl_auth_bytes => BYTES 7 | */ 8 | 9 | /** 10 | * @param {Buffer} authBytes - SASL authentication bytes from client as defined by the SASL mechanism 11 | */ 12 | export default ({ 13 | authBytes 14 | }: any) => ({ 15 | apiKey, 16 | apiVersion: 0, 17 | apiName: 'SaslAuthenticate', 18 | //deno-lint-ignore require-await 19 | encode: async () => { 20 | return new Encoder().writeBuffer(authBytes) 21 | }, 22 | }) 23 | -------------------------------------------------------------------------------- /src/protocol/requests/saslAuthenticate/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * SaslAuthenticate Request (Version: 1) => sasl_auth_bytes 5 | * sasl_auth_bytes => BYTES 6 | */ 7 | 8 | /** 9 | * @param {Buffer} authBytes - SASL authentication bytes from client as defined by the SASL mechanism 10 | */ 11 | export default ({ 12 | authBytes 13 | }: any) => Object.assign(requestV0({ authBytes }), { apiVersion: 1 }) 14 | -------------------------------------------------------------------------------- /src/protocol/requests/saslHandshake/index.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from './v0/request.ts' 2 | import responseV0 from './v1/response.ts' 3 | import requestV1 from './v1/request.ts' 4 | import responseV1 from './v1/response.ts' 5 | 6 | const versions: Record = { 7 | 0: ({ 8 | mechanism 9 | }: any) => { 10 | const request = requestV0 11 | const response = responseV0 12 | return { request: request({ mechanism }), response } 13 | }, 14 | 1: ({ 15 | mechanism 16 | }: any) => { 17 | const request = requestV1 18 | const response = responseV1 19 | return { request: request({ mechanism }), response } 20 | }, 21 | } 22 | 23 | export default{ 24 | versions: Object.keys(versions), 25 | protocol: ({ 26 | version 27 | }: any) => versions[version], 28 | } 29 | -------------------------------------------------------------------------------- /src/protocol/requests/saslHandshake/v0/request.ts: -------------------------------------------------------------------------------- 1 | import { Encoder } from '../../../encoder.ts' 2 | import apiKeys from '../../apiKeys.ts' 3 | 4 | const apiKey = apiKeys.SaslHandshake; 5 | 6 | /** 7 | * SaslHandshake Request (Version: 0) => mechanism 8 | * mechanism => STRING 9 | */ 10 | 11 | /** 12 | * @param {string} mechanism - SASL Mechanism chosen by the client 13 | */ 14 | export default ({ 15 | mechanism 16 | }: any) => ({ 17 | apiKey, 18 | apiVersion: 0, 19 | apiName: 'SaslHandshake', 20 | //deno-lint-ignore require-await 21 | encode: async () => new Encoder().writeString(mechanism), 22 | }) 23 | -------------------------------------------------------------------------------- /src/protocol/requests/saslHandshake/v0/response.ts: -------------------------------------------------------------------------------- 1 | import { Decoder } from '../../../decoder.ts' 2 | import { failure, createErrorFromCode, failIfVersionNotSupported } from '../../../error.ts' 3 | 4 | /** 5 | * SaslHandshake Response (Version: 0) => error_code [enabled_mechanisms] 6 | * error_code => INT16 7 | * enabled_mechanisms => STRING 8 | */ 9 | //deno-lint-ignore require-await 10 | const decode = async (rawData: any) => { 11 | const decoder = new Decoder(rawData) 12 | const errorCode = decoder.readInt16() 13 | 14 | failIfVersionNotSupported(errorCode) 15 | 16 | return { 17 | errorCode, 18 | enabledMechanisms: decoder.readArray((decoder: Decoder) => decoder.readString()), 19 | }; 20 | } 21 | //deno-lint-ignore require-await 22 | const parse = async (data: any) => { 23 | if (failure(data.errorCode)) { 24 | throw createErrorFromCode(data.errorCode) 25 | } 26 | 27 | return data 28 | } 29 | 30 | export { 31 | decode, 32 | parse, 33 | } 34 | -------------------------------------------------------------------------------- /src/protocol/requests/saslHandshake/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | export default ({ 4 | mechanism 5 | }: any) => ({ ...requestV0({ mechanism }), apiVersion: 1 }) 6 | -------------------------------------------------------------------------------- /src/protocol/requests/saslHandshake/v1/response.ts: -------------------------------------------------------------------------------- 1 | import {decode} from '../v0/response.ts' 2 | import {parse} from '../v0/response.ts' 3 | 4 | export default { 5 | decode, 6 | parse 7 | } 8 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"data":[0,10,116,101,115,116,45,103,114,111,117,112,0,0,0,1,0,53,101,120,97,109,112,108,101,45,99,111,110,115,117,109,101,114,45,97,55,51,56,52,52,50,50,45,53,56,102,102,45,52,55,54,100,45,98,98,48,49,45,55,101,52,101,99,99,51,55,54,53,55,56,0,0,0,1,0,53,101,120,97,109,112,108,101,45,99,111,110,115,117,109,101,114,45,97,55,51,56,52,52,50,50,45,53,56,102,102,45,52,55,54,100,45,98,98,48,49,45,55,101,52,101,99,99,51,55,54,53,55,56,0,0,0,15,91,111,98,106,101,99,116,32,79,98,106,101,99,116,93],"type":"Buffer"} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,28,123,34,116,111,112,105,99,45,116,101,115,116,34,58,91,50,44,53,44,52,44,49,44,51,44,48,93,125]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v0_response_empty_member_assignment.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v1_memberAssignment.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,49,52,57,49,56,57,57,52,101,102,100,102,98,101,101,50,99,49,49,52,45,50,52,52,57,53,45,49,48,50,97,53,57,57,97,45,100,54,100,54,45,52,101,98,52,45,56,53,55,99,45,97,99,98,54,53,49,101,98,99,55,51,48,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v1_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,94,0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,49,52,57,49,56,57,57,52,101,102,100,102,98,101,101,50,99,49,49,52,45,50,52,52,57,53,45,49,48,50,97,53,57,57,97,45,100,54,100,54,45,52,101,98,52,45,56,53,55,99,45,97,99,98,54,53,49,101,98,99,55,51,48,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v2_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,94,0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,49,52,57,49,56,57,57,52,101,102,100,102,98,101,101,50,99,49,49,52,45,50,52,52,57,53,45,49,48,50,97,53,57,57,97,45,100,54,100,54,45,52,101,98,52,45,56,53,55,99,45,97,99,98,54,53,49,101,98,99,55,51,48,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/fixtures/v3_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,94,0,1,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,49,52,57,49,56,57,57,52,101,102,100,102,98,101,101,50,99,49,49,52,45,50,52,52,57,53,45,49,48,50,97,53,57,57,97,45,100,54,100,54,45,52,101,98,52,45,56,53,55,99,45,97,99,98,54,53,49,101,98,99,55,51,48,0,0,0,1,0,0,0,0,0,0,0,0]} 2 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/v0/response.ts: -------------------------------------------------------------------------------- 1 | import { Decoder } from '../../../decoder.ts' 2 | import { failure, createErrorFromCode, failIfVersionNotSupported } from '../../../error.ts' 3 | 4 | /** 5 | * SyncGroup Response (Version: 0) => error_code member_assignment 6 | * error_code => INT16 7 | * member_assignment => BYTES 8 | */ 9 | //deno-lint-ignore require-await 10 | const decode = async (rawData: any) => { 11 | const decoder = new Decoder(rawData) 12 | const errorCode = decoder.readInt16() 13 | 14 | failIfVersionNotSupported(errorCode) 15 | 16 | return { 17 | errorCode, 18 | memberAssignment: decoder.readBytes(), 19 | } 20 | } 21 | //deno-lint-ignore require-await 22 | const parse = async (data: any) => { 23 | if (failure(data.errorCode)) { 24 | throw createErrorFromCode(data.errorCode) 25 | } 26 | 27 | return data 28 | } 29 | 30 | export default { 31 | decode, 32 | parse, 33 | } 34 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * SyncGroup Request (Version: 1) => group_id generation_id member_id [group_assignment] 5 | * group_id => STRING 6 | * generation_id => INT32 7 | * member_id => STRING 8 | * group_assignment => member_id member_assignment 9 | * member_id => STRING 10 | * member_assignment => BYTES 11 | */ 12 | 13 | export default({ 14 | groupId, 15 | generationId, 16 | memberId, 17 | groupAssignment 18 | }: any) => 19 | Object.assign(requestV0({ groupId, generationId, memberId, groupAssignment }), { apiVersion: 1 }) 20 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/v1/response.ts: -------------------------------------------------------------------------------- 1 | import { Decoder } from '../../../decoder.ts' 2 | import { failIfVersionNotSupported } from '../../../error.ts' 3 | import response from '../v0/response.ts' 4 | 5 | const { parse } = response; 6 | 7 | /** 8 | * SyncGroup Response (Version: 1) => throttle_time_ms error_code member_assignment 9 | * throttle_time_ms => INT32 10 | * error_code => INT16 11 | * member_assignment => BYTES 12 | */ 13 | //deno-lint-ignore require-await 14 | const decode = async (rawData: any) => { 15 | const decoder = new Decoder(rawData) 16 | const throttleTime = decoder.readInt32() 17 | const errorCode = decoder.readInt16() 18 | 19 | failIfVersionNotSupported(errorCode) 20 | 21 | return { 22 | throttleTime, 23 | errorCode, 24 | memberAssignment: decoder.readBytes(), 25 | } 26 | } 27 | 28 | export default { 29 | decode, 30 | parse 31 | } 32 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/v2/request.ts: -------------------------------------------------------------------------------- 1 | import requestV1 from '../v1/request.ts' 2 | 3 | /** 4 | * SyncGroup Request (Version: 2) => group_id generation_id member_id [group_assignment] 5 | * group_id => STRING 6 | * generation_id => INT32 7 | * member_id => STRING 8 | * group_assignment => member_id member_assignment 9 | * member_id => STRING 10 | * member_assignment => BYTES 11 | */ 12 | 13 | export default ({ 14 | groupId, 15 | generationId, 16 | memberId, 17 | groupAssignment 18 | }: any) => 19 | Object.assign(requestV1({ groupId, generationId, memberId, groupAssignment }), { apiVersion: 2 }) 20 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/v2/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v1/response.ts' 2 | 3 | const parse = response.parse 4 | const decodeV1 = response.decode 5 | /** 6 | * In version 2, on quota violation, brokers send out responses before throttling. 7 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 8 | * 9 | * SyncGroup Response (Version: 2) => throttle_time_ms error_code member_assignment 10 | * throttle_time_ms => INT32 11 | * error_code => INT16 12 | * member_assignment => BYTES 13 | */ 14 | 15 | const decode = async (rawData: any) => { 16 | const decoded = await decodeV1(rawData) 17 | 18 | return { 19 | ...decoded, 20 | throttleTime: 0, 21 | clientSideThrottleTime: decoded.throttleTime, 22 | } 23 | } 24 | 25 | export default { 26 | decode, 27 | parse, 28 | } 29 | -------------------------------------------------------------------------------- /src/protocol/requests/syncGroup/v3/response.ts: -------------------------------------------------------------------------------- 1 | import response from '../v2/response.ts' 2 | const parse = response.parse 3 | const decode = response.decode 4 | /** 5 | * SyncGroup Response (Version: 2) => throttle_time_ms error_code member_assignment 6 | * throttle_time_ms => INT32 7 | * error_code => INT16 8 | * member_assignment => BYTES 9 | */ 10 | export default{ 11 | decode, 12 | parse, 13 | } 14 | -------------------------------------------------------------------------------- /src/protocol/requests/txnOffsetCommit/fixtures/v0_request.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,21,116,101,115,116,45,116,114,97,110,115,97,99,116,105,111,110,97,108,45,105,100,0,13,116,101,115,116,45,103,114,111,117,112,45,105,100,0,0,0,0,0,0,78,32,0,0,0,0,0,1,0,10,116,101,115,116,45,116,111,112,105,99,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,0,255,255,0,0,0,2,0,0,0,0,0,0,0,0,255,255]} -------------------------------------------------------------------------------- /src/protocol/requests/txnOffsetCommit/fixtures/v0_response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,74,116,101,115,116,45,116,111,112,105,99,45,48,98,97,51,51,49,55,51,102,55,54,54,52,100,55,53,99,54,98,50,45,54,51,54,51,50,45,97,48,100,97,98,48,55,57,45,49,99,57,97,45,52,52,98,97,45,98,101,50,53,45,99,97,51,100,53,48,100,102,53,48,48,51,0,0,0,2,0,0,0,1,0,0,0,0,0,2,0,0]} -------------------------------------------------------------------------------- /src/protocol/requests/txnOffsetCommit/v1/request.ts: -------------------------------------------------------------------------------- 1 | import requestV0 from '../v0/request.ts' 2 | 3 | /** 4 | * TxnOffsetCommit Request (Version: 1) => transactional_id group_id producer_id producer_epoch [topics] 5 | * transactional_id => STRING 6 | * group_id => STRING 7 | * producer_id => INT64 8 | * producer_epoch => INT16 9 | * topics => topic [partitions] 10 | * topic => STRING 11 | * partitions => partition offset metadata 12 | * partition => INT32 13 | * offset => INT64 14 | * metadata => NULLABLE_STRING 15 | */ 16 | 17 | export default ({ 18 | transactionalId, 19 | groupId, 20 | producerId, 21 | producerEpoch, 22 | topics 23 | }: any) => 24 | Object.assign(requestV0({ transactionalId, groupId, producerId, producerEpoch, topics }), { 25 | apiVersion: 1, 26 | }) 27 | -------------------------------------------------------------------------------- /src/protocol/requests/txnOffsetCommit/v1/response.ts: -------------------------------------------------------------------------------- 1 | 2 | import response from '../v0/response.ts' 3 | 4 | const {parse} = response 5 | const decodeV1 = response.decode 6 | /** 7 | * In version 1, on quota violation, brokers send out responses before throttling. 8 | * @see https://cwiki.apache.org/confluence/display/KAFKA/KIP-219+-+Improve+quota+communication 9 | * 10 | * TxnOffsetCommit Response (Version: 1) => throttle_time_ms [topics] 11 | * throttle_time_ms => INT32 12 | * topics => topic [partitions] 13 | * topic => STRING 14 | * partitions => partition error_code 15 | * partition => INT32 16 | * error_code => INT16 17 | */ 18 | 19 | const decode = async (rawData: any) => { 20 | const decoded = await decodeV1(rawData) 21 | 22 | return { 23 | ...decoded, 24 | throttleTime: 0, 25 | clientSideThrottleTime: decoded.throttleTime, 26 | } 27 | } 28 | 29 | export default { 30 | decode, 31 | parse, 32 | } 33 | -------------------------------------------------------------------------------- /src/protocol/resourceTypes.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import ACLResourceTypes from './aclResourceTypes.ts'; 4 | 5 | /** 6 | * @deprecated 7 | * @see https://github.com/tulios/kafkajs/issues/649 8 | * 9 | * Use ConfigResourceTypes or AclResourceTypes instead. 10 | */ 11 | export default { ACLResourceTypes }; 12 | -------------------------------------------------------------------------------- /src/protocol/sasl/awsIam/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import request from './request.ts'; 4 | import response from './response.ts'; 5 | 6 | export default { request, response }; 7 | -------------------------------------------------------------------------------- /src/protocol/sasl/awsIam/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Encoder } from '../../encoder.ts'; 4 | 5 | const US_ASCII_NULL_CHAR = '\u0000'; 6 | 7 | export default ({ 8 | authorizationIdentity, 9 | accessKeyId, 10 | secretAccessKey, 11 | sessionToken = '', 12 | }: any) => ({ 13 | encode: async () => { 14 | return new Encoder().writeBytes( 15 | [authorizationIdentity, accessKeyId, secretAccessKey, sessionToken].join( 16 | US_ASCII_NULL_CHAR 17 | ) 18 | ); 19 | }, 20 | }); 21 | -------------------------------------------------------------------------------- /src/protocol/sasl/awsIam/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | export default { 4 | decode: async () => true, 5 | parse: async () => true, 6 | }; 7 | -------------------------------------------------------------------------------- /src/protocol/sasl/oauthBearer/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import request from './request.ts'; 3 | import response from './response.ts'; 4 | 5 | export default { request, response }; 6 | -------------------------------------------------------------------------------- /src/protocol/sasl/oauthBearer/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | export default { 4 | decode: async () => true, 5 | parse: async () => true, 6 | }; 7 | -------------------------------------------------------------------------------- /src/protocol/sasl/plain/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import request from './request.ts'; 4 | import response from './response.ts'; 5 | 6 | export default { request, response }; 7 | -------------------------------------------------------------------------------- /src/protocol/sasl/plain/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | export default { 4 | decode: async () => true, 5 | parse: async () => true, 6 | }; 7 | -------------------------------------------------------------------------------- /src/protocol/sasl/scram/finalMessage/request.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { Encoder } from '../../../encoder.ts'; 4 | 5 | export default ({ finalMessage }: any) => ({ 6 | encode: async () => new Encoder().writeBytes(finalMessage), 7 | }); 8 | -------------------------------------------------------------------------------- /src/protocol/sasl/scram/finalMessage/response.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import firstMessage from '../firstMessage/response.ts'; 4 | export default { finalMessageResponse: firstMessage }; 5 | 6 | //HI GUYS!!!! I'm SO HAPPY TO BE HERE 7 | //SORA IS IN SUPER SMASH BROS THE WORLD MAKESSENSE 8 | 9 | // Oh hello there 10 | // Are you? 11 | // Are you really?!?!?!??!?!?!?! 12 | -------------------------------------------------------------------------------- /src/protocol/sasl/scram/firstMessage/fixtures/response.json: -------------------------------------------------------------------------------- 1 | {"type":"Buffer","data":[0,0,0,96,114,61,73,81,105,48,48,69,90,119,117,115,75,119,48,73,111,55,70,111,66,102,113,103,49,99,55,105,109,55,56,99,110,104,53,54,54,99,119,116,48,119,97,116,108,115,112,119,52,112,44,115,61,98,72,99,121,77,51,112,53,98,87,107,53,97,88,70,52,79,87,77,51,99,109,115,119,90,72,77,53,78,50,119,48,99,65,61,61,44,105,61,56,49,57,50]} 2 | -------------------------------------------------------------------------------- /src/protocol/sasl/scram/firstMessage/request.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * https://tools.ietf.org/html/rfc5802 3 | * 4 | * First, the client sends the "client-first-message" containing: 5 | * 6 | * -> a GS2 header consisting of a flag indicating whether channel 7 | * binding is supported-but-not-used, not supported, or used, and an 8 | * optional SASL authorization identity; 9 | * 10 | * -> SCRAM username and a random, unique nonce attributes. 11 | * 12 | * Note that the client's first message will always start with "n", "y", 13 | * or "p"; otherwise, the message is invalid and authentication MUST 14 | * fail. This is important, as it allows for GS2 extensibility (e.g., 15 | * to add support for security layers). 16 | * 17 | * @format 18 | */ 19 | 20 | import { Encoder } from '../../../encoder.ts'; 21 | 22 | export default ({ clientFirstMessage }: any) => ({ 23 | encode: async () => new Encoder().writeBytes(clientFirstMessage), 24 | }); 25 | -------------------------------------------------------------------------------- /src/protocol/sasl/scram/firstMessage/response.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }] 3 | * 4 | * @format 5 | */ 6 | 7 | import { Decoder } from '../../../decoder.ts'; 8 | 9 | const ENTRY_REGEX = /^([rsiev])=(.*)$/; 10 | 11 | export default { 12 | //@ts-ignore 13 | decode: async (rawData: any) => { 14 | return new Decoder(rawData).readBytes(); 15 | }, 16 | parse: async (data: any) => { 17 | const processed = data 18 | .toString() 19 | .split(',') 20 | .map((str: any) => { 21 | const [_, key, value] = str.match(ENTRY_REGEX); 22 | return [key, value]; 23 | }) 24 | .reduce( 25 | (obj: any, entry: any) => ({ 26 | ...obj, 27 | [entry[0]]: entry[1], 28 | }), 29 | {} 30 | ); 31 | 32 | return { original: data.toString(), ...processed }; 33 | }, 34 | }; 35 | -------------------------------------------------------------------------------- /src/protocol/sasl/scram/index.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | import firstRequest from './firstMessage/request.ts'; 3 | import firstResponse from './firstMessage/response.ts'; 4 | import finalRequest from './finalMessage/request.ts'; 5 | import finalResponse from './finalMessage/response.ts'; 6 | 7 | export default { 8 | firstMessage: { 9 | request: firstRequest, 10 | response: firstResponse, 11 | }, 12 | finalMessage: { 13 | request: finalRequest, 14 | response: finalResponse, 15 | }, 16 | }; 17 | -------------------------------------------------------------------------------- /src/protocol/timestampTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Enum for timestamp types 3 | * 4 | * @format 5 | * @readonly 6 | * @enum {TimestampType} 7 | */ 8 | 9 | export default { 10 | // Timestamp type is unknown 11 | NO_TIMESTAMP: -1, 12 | 13 | // Timestamp relates to message creation time as set by a Kafka client 14 | CREATE_TIME: 0, 15 | 16 | // Timestamp relates to the time a message was appended to a Kafka log 17 | LOG_APPEND_TIME: 1, 18 | }; 19 | -------------------------------------------------------------------------------- /src/retry/defaults.ts: -------------------------------------------------------------------------------- 1 | 2 | type defaultObj = { 3 | maxRetryTime: number; 4 | initialRetryTime: number; 5 | factor: number; // randomization factor 6 | multiplier: number; // exponential factor 7 | retries: number; 8 | } 9 | 10 | const defaultObj = { 11 | maxRetryTime: 30 * 1000, 12 | initialRetryTime: 300, 13 | factor: 0.2, // randomization factor 14 | multiplier: 2, // exponential factor 15 | retries: 5, // max retries 16 | } 17 | 18 | export default defaultObj -------------------------------------------------------------------------------- /src/testHelpers/certs/ca-cert.srl: -------------------------------------------------------------------------------- 1 | CE13974A68F776DA 2 | -------------------------------------------------------------------------------- /src/testHelpers/certs/kafka.server.keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/kafkaSaur/c08b197b6fcbab827bc883bbbaf45d37e53d77bf/src/testHelpers/certs/kafka.server.keystore.jks -------------------------------------------------------------------------------- /src/testHelpers/certs/kafka.server.truststore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/kafkaSaur/c08b197b6fcbab827bc883bbbaf45d37e53d77bf/src/testHelpers/certs/kafka.server.truststore.jks -------------------------------------------------------------------------------- /src/testHelpers/certs/keystore_creds: -------------------------------------------------------------------------------- 1 | testtest -------------------------------------------------------------------------------- /src/testHelpers/certs/sslkey_creds: -------------------------------------------------------------------------------- 1 | testtest -------------------------------------------------------------------------------- /src/testHelpers/certs/truststore_creds: -------------------------------------------------------------------------------- 1 | testtest -------------------------------------------------------------------------------- /src/testHelpers/kafka/server-jaas_oauth.conf: -------------------------------------------------------------------------------- 1 | KafkaServer { 2 | org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required 3 | unsecuredLoginStringClaim_sub="admin"; 4 | }; 5 | KafkaClient { 6 | org.apache.kafka.common.security.plain.PlainLoginModule required 7 | username="test" 8 | password="testtest" 9 | user_test="testtest"; 10 | }; 11 | Server { 12 | org.apache.kafka.common.security.plain.PlainLoginModule required 13 | username="test" 14 | password="testtest" 15 | user_test="testtest"; 16 | }; 17 | Client { 18 | org.apache.kafka.common.security.plain.PlainLoginModule required 19 | username="test" 20 | password="testtest" 21 | user_test="testtest"; 22 | }; -------------------------------------------------------------------------------- /src/utils/arrayDiff.ts: -------------------------------------------------------------------------------- 1 | export default (a: any, b: any) => { 2 | const result = [] 3 | const length = a.length 4 | let i = 0 5 | 6 | while (i < length) { 7 | if (b.indexOf(a[i]) === -1) { 8 | result.push(a[i]) 9 | } 10 | i += 1 11 | } 12 | 13 | return result 14 | } 15 | -------------------------------------------------------------------------------- /src/utils/flatten.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Flatten the given arrays into a new array 3 | * 4 | * @param {Array>} arrays 5 | * @returns {Array} 6 | * @template T 7 | */ 8 | function flatten(arrays: any) { 9 | return [].concat.apply([], arrays) 10 | } 11 | 12 | export default flatten 13 | -------------------------------------------------------------------------------- /src/utils/groupBy.ts: -------------------------------------------------------------------------------- 1 | export default async (array: any, groupFn: any) => { 2 | const result = new Map() 3 | 4 | for (const item of array) { 5 | const group = await Promise.resolve(groupFn(item)) 6 | result.set(group, result.has(group) ? [...result.get(group), item] : [item]) 7 | } 8 | 9 | return result 10 | } 11 | -------------------------------------------------------------------------------- /src/utils/promisify.ts: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | /** Promisifies a given function that has a final callback argument. */ 4 | export function promisify< 5 | // deno-lint-ignore no-explicit-any 6 | T extends (...args: any[]) => any, 7 | $FirstParams extends unknown[] = Parameters extends [ 8 | ...infer $FirstParams, 9 | infer _ 10 | ] 11 | ? $FirstParams 12 | : // deno-lint-ignore no-explicit-any 13 | any[] 14 | >( 15 | fn: T 16 | ): (...args: $FirstParams) => // deno-lint-ignore no-explicit-any 17 | Promise extends [...infer _, infer $Last] ? $Last : any> { 18 | return (...args: $FirstParams) => { 19 | return new Promise((resolve, reject) => { 20 | try { 21 | fn(...args, resolve); 22 | } catch (err) { 23 | reject(err); 24 | } 25 | }); 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /src/utils/sharedPromiseTo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @template T 3 | * @param { (...args: any) => Promise } [asyncFunction] 4 | * Promise returning function that will only ever be invoked sequentially. 5 | * @returns { (...args: any) => Promise } 6 | * Function that may invoke asyncFunction if there is not a currently executing invocation. 7 | * Returns promise from the currently executing invocation. 8 | */ 9 | export default (asyncFunction: any) => { 10 | let promise: any = null 11 | 12 | return (...args: any[]) => { 13 | if (promise == null) { 14 | promise = asyncFunction(...args).finally(() => (promise = null)) 15 | } 16 | return promise 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/utils/shuffle.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {T[]} array 3 | * @returns T[] 4 | * @template T 5 | */ 6 | export default (array: any) => { 7 | if (!Array.isArray(array)) { 8 | throw new TypeError("'array' is not an array") 9 | } 10 | 11 | if (array.length < 2) { 12 | return array 13 | } 14 | 15 | const copy = array.slice() 16 | 17 | for (let i = copy.length - 1; i > 0; i--) { 18 | const j = Math.floor(Math.random() * (i + 1)) 19 | const temp = copy[i] 20 | copy[i] = copy[j] 21 | copy[j] = temp 22 | } 23 | 24 | return copy 25 | } 26 | -------------------------------------------------------------------------------- /src/utils/sleep.ts: -------------------------------------------------------------------------------- 1 | export default (timeInMs: any) => new Promise((resolve: any) => { 2 | setTimeout(resolve, timeInMs) 3 | }) 4 | -------------------------------------------------------------------------------- /src/utils/swapObject.ts: -------------------------------------------------------------------------------- 1 | const { keys } = Object 2 | export default (object: any) => keys(object).reduce((result, key) => ({ ...result, [object[key]]: key }), {}) 3 | -------------------------------------------------------------------------------- /src/utils/websiteUrl.ts: -------------------------------------------------------------------------------- 1 | const BASE_URL = 'https://kafka.js.org' 2 | 3 | export default (path: any, hash: any) => `${BASE_URL}/${path}${hash ? '#' + hash : ''}` 4 | -------------------------------------------------------------------------------- /static_images/03365-glow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/kafkaSaur/c08b197b6fcbab827bc883bbbaf45d37e53d77bf/static_images/03365-glow.png -------------------------------------------------------------------------------- /static_images/sirdeno-modified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oslabs-beta/kafkaSaur/c08b197b6fcbab827bc883bbbaf45d37e53d77bf/static_images/sirdeno-modified.png --------------------------------------------------------------------------------