Module: Kafka::Protocol

Defined in:
lib/kafka/protocol.rb,
lib/kafka/protocol/encoder.rb,
lib/kafka/protocol/decoder.rb,
lib/kafka/protocol/message.rb,
lib/kafka/protocol/message_set.rb,
lib/kafka/protocol/fetch_request.rb,
lib/kafka/protocol/fetch_response.rb,
lib/kafka/protocol/request_message.rb,
lib/kafka/protocol/produce_request.rb,
lib/kafka/protocol/produce_response.rb,
lib/kafka/protocol/heartbeat_request.rb,
lib/kafka/protocol/metadata_response.rb,
lib/kafka/protocol/member_assignment.rb,
lib/kafka/protocol/heartbeat_response.rb,
lib/kafka/protocol/sync_group_request.rb,
lib/kafka/protocol/join_group_request.rb,
lib/kafka/protocol/leave_group_request.rb,
lib/kafka/protocol/sync_group_response.rb,
lib/kafka/protocol/list_offset_request.rb,
lib/kafka/protocol/join_group_response.rb,
lib/kafka/protocol/list_offset_response.rb,
lib/kafka/protocol/leave_group_response.rb,
lib/kafka/protocol/offset_fetch_request.rb,
lib/kafka/protocol/offset_commit_request.rb,
lib/kafka/protocol/offset_fetch_response.rb,
lib/kafka/protocol/offset_commit_response.rb,
lib/kafka/protocol/topic_metadata_request.rb,
lib/kafka/protocol/consumer_group_protocol.rb,
lib/kafka/protocol/group_coordinator_request.rb,
lib/kafka/protocol/group_coordinator_response.rb

Defined Under Namespace

Classes: ConsumerGroupProtocol, Decoder, Encoder, FetchRequest, FetchResponse, GroupCoordinatorRequest, GroupCoordinatorResponse, HeartbeatRequest, HeartbeatResponse, JoinGroupRequest, JoinGroupResponse, LeaveGroupRequest, LeaveGroupResponse, ListOffsetRequest, ListOffsetResponse, MemberAssignment, Message, MessageSet, MetadataResponse, OffsetCommitRequest, OffsetCommitResponse, OffsetFetchRequest, OffsetFetchResponse, ProduceRequest, ProduceResponse, RequestMessage, SyncGroupRequest, SyncGroupResponse, TopicMetadataRequest

Constant Summary collapse

REPLICA_ID =

The replica id of non-brokers is always -1.

-1
APIS =
{
  0 => :produce,
  1 => :fetch,
  2 => :list_offset,
  3 => :topic_metadata,
  8 => :offset_commit,
  9 => :offset_fetch,
  10 => :group_coordinator,
  11 => :join_group,
  12 => :heartbeat,
  13 => :leave_group,
  14 => :sync_group,
}
ERRORS =
{
  -1 => UnknownError,
  1 => OffsetOutOfRange,
  2 => CorruptMessage,
  3 => UnknownTopicOrPartition,
  4 => InvalidMessageSize,
  5 => LeaderNotAvailable,
  6 => NotLeaderForPartition,
  7 => RequestTimedOut,
  8 => BrokerNotAvailable,
  9 => ReplicaNotAvailable,
  10 => MessageSizeTooLarge,
  12 => OffsetMetadataTooLarge,
  15 => GroupCoordinatorNotAvailable,
  16 => NotCoordinatorForGroup,
  17 => InvalidTopic,
  18 => RecordListTooLarge,
  19 => NotEnoughReplicas,
  20 => NotEnoughReplicasAfterAppend,
  21 => InvalidRequiredAcks,
  22 => IllegalGeneration,
  25 => UnknownMemberId,
  26 => InvalidSessionTimeout,
  27 => RebalanceInProgress,
}

Class Method Summary collapse

Class Method Details

.api_name(api_key) ⇒ Object


56
57
58
# File 'lib/kafka/protocol.rb', line 56

def self.api_name(api_key)
  APIS.fetch(api_key, :unknown)
end

.handle_error(error_code) ⇒ Object


46
47
48
49
50
51
52
53
54
# File 'lib/kafka/protocol.rb', line 46

def self.handle_error(error_code)
  if error_code == 0
    # No errors, yay!
  elsif error = ERRORS[error_code]
    raise error
  else
    raise UnknownError, "Unknown error with code #{error_code}"
  end
end