lib/kafka/protocol.rb in ruby-kafka-0.7.0 vs lib/kafka/protocol.rb in ruby-kafka-0.7.1.beta1
- old
+ new
@@ -12,50 +12,56 @@
# the protocol.
module Protocol
# The replica id of non-brokers is always -1.
REPLICA_ID = -1
- PRODUCE_API = 0
- FETCH_API = 1
- LIST_OFFSET_API = 2
- TOPIC_METADATA_API = 3
- OFFSET_COMMIT_API = 8
- OFFSET_FETCH_API = 9
- FIND_COORDINATOR_API = 10
- JOIN_GROUP_API = 11
- HEARTBEAT_API = 12
- LEAVE_GROUP_API = 13
- SYNC_GROUP_API = 14
- DESCRIBE_GROUPS_API = 15
- LIST_GROUPS_API = 16
- SASL_HANDSHAKE_API = 17
- API_VERSIONS_API = 18
- CREATE_TOPICS_API = 19
- DELETE_TOPICS_API = 20
- DESCRIBE_CONFIGS_API = 32
- ALTER_CONFIGS_API = 33
- CREATE_PARTITIONS_API = 37
+ PRODUCE_API = 0
+ FETCH_API = 1
+ LIST_OFFSET_API = 2
+ TOPIC_METADATA_API = 3
+ OFFSET_COMMIT_API = 8
+ OFFSET_FETCH_API = 9
+ FIND_COORDINATOR_API = 10
+ JOIN_GROUP_API = 11
+ HEARTBEAT_API = 12
+ LEAVE_GROUP_API = 13
+ SYNC_GROUP_API = 14
+ DESCRIBE_GROUPS_API = 15
+ LIST_GROUPS_API = 16
+ SASL_HANDSHAKE_API = 17
+ API_VERSIONS_API = 18
+ CREATE_TOPICS_API = 19
+ DELETE_TOPICS_API = 20
+ INIT_PRODUCER_ID_API = 22
+ ADD_PARTITIONS_TO_TXN_API = 24
+ END_TXN_API = 26
+ DESCRIBE_CONFIGS_API = 32
+ ALTER_CONFIGS_API = 33
+ CREATE_PARTITIONS_API = 37
# A mapping from numeric API keys to symbolic API names.
APIS = {
- PRODUCE_API => :produce,
- FETCH_API => :fetch,
- LIST_OFFSET_API => :list_offset,
- TOPIC_METADATA_API => :topic_metadata,
- OFFSET_COMMIT_API => :offset_commit,
- OFFSET_FETCH_API => :offset_fetch,
- FIND_COORDINATOR_API => :find_coordinator,
- JOIN_GROUP_API => :join_group,
- HEARTBEAT_API => :heartbeat,
- LEAVE_GROUP_API => :leave_group,
- SYNC_GROUP_API => :sync_group,
- SASL_HANDSHAKE_API => :sasl_handshake,
- API_VERSIONS_API => :api_versions,
- CREATE_TOPICS_API => :create_topics,
- DELETE_TOPICS_API => :delete_topics,
- DESCRIBE_CONFIGS_API => :describe_configs_api,
- CREATE_PARTITIONS_API => :create_partitions
+ PRODUCE_API => :produce,
+ FETCH_API => :fetch,
+ LIST_OFFSET_API => :list_offset,
+ TOPIC_METADATA_API => :topic_metadata,
+ OFFSET_COMMIT_API => :offset_commit,
+ OFFSET_FETCH_API => :offset_fetch,
+ FIND_COORDINATOR_API => :find_coordinator,
+ JOIN_GROUP_API => :join_group,
+ HEARTBEAT_API => :heartbeat,
+ LEAVE_GROUP_API => :leave_group,
+ SYNC_GROUP_API => :sync_group,
+ SASL_HANDSHAKE_API => :sasl_handshake,
+ API_VERSIONS_API => :api_versions,
+ CREATE_TOPICS_API => :create_topics,
+ DELETE_TOPICS_API => :delete_topics,
+ INIT_PRODUCER_ID_API => :init_producer_id_api,
+ ADD_PARTITIONS_TO_TXN_API => :add_partitions_to_txn_api,
+ END_TXN_API => :end_txn_api,
+ DESCRIBE_CONFIGS_API => :describe_configs_api,
+ CREATE_PARTITIONS_API => :create_partitions
}
# A mapping from numeric error codes to exception classes.
ERRORS = {
-1 => UnknownError,
@@ -93,28 +99,36 @@
37 => InvalidPartitions,
38 => InvalidReplicationFactor,
39 => InvalidReplicaAssignment,
40 => InvalidConfig,
41 => NotController,
- 42 => InvalidRequest
+ 42 => InvalidRequest,
+ 45 => OutOfOrderSequenceNumberError,
+ 46 => DuplicateSequenceNumberError,
+ 47 => InvalidProducerEpochError,
+ 48 => InvalidTxnStateError,
+ 49 => InvalidProducerIDMappingError,
+ 50 => InvalidTransactionTimeoutError,
+ 51 => ConcurrentTransactionError,
+ 52 => TransactionCoordinatorFencedError
}
# A mapping from int to corresponding resource type in symbol.
# https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/resource/ResourceType.java
- RESOURCE_TYPE_UNKNOWN = 0
- RESOURCE_TYPE_ANY = 1
- RESOURCE_TYPE_TOPIC = 2
- RESOURCE_TYPE_GROUP = 3
- RESOURCE_TYPE_CLUSTER = 4
+ RESOURCE_TYPE_UNKNOWN = 0
+ RESOURCE_TYPE_ANY = 1
+ RESOURCE_TYPE_TOPIC = 2
+ RESOURCE_TYPE_GROUP = 3
+ RESOURCE_TYPE_CLUSTER = 4
RESOURCE_TYPE_TRANSACTIONAL_ID = 5
RESOURCE_TYPE_DELEGATION_TOKEN = 6
RESOURCE_TYPES = {
- RESOURCE_TYPE_UNKNOWN => :unknown,
- RESOURCE_TYPE_ANY => :any,
- RESOURCE_TYPE_TOPIC => :topic,
- RESOURCE_TYPE_GROUP => :group,
- RESOURCE_TYPE_CLUSTER => :cluster,
+ RESOURCE_TYPE_UNKNOWN => :unknown,
+ RESOURCE_TYPE_ANY => :any,
+ RESOURCE_TYPE_TOPIC => :topic,
+ RESOURCE_TYPE_GROUP => :group,
+ RESOURCE_TYPE_CLUSTER => :cluster,
RESOURCE_TYPE_TRANSACTIONAL_ID => :transactional_id,
RESOURCE_TYPE_DELEGATION_TOKEN => :delegation_token,
}
# Coordinator types. Since Kafka 0.11.0, there are types of coordinators:
@@ -186,5 +200,11 @@
require "kafka/protocol/create_partitions_response"
require "kafka/protocol/list_groups_request"
require "kafka/protocol/list_groups_response"
require "kafka/protocol/describe_groups_request"
require "kafka/protocol/describe_groups_response"
+require "kafka/protocol/init_producer_id_request"
+require "kafka/protocol/init_producer_id_response"
+require "kafka/protocol/add_partitions_to_txn_request"
+require "kafka/protocol/add_partitions_to_txn_response"
+require "kafka/protocol/end_txn_request"
+require "kafka/protocol/end_txn_response"