View Source kpro_batch (kafka_protocol v4.2.4)

Summary

Functions

Decode received message-set into a batch list. Ensured by kpro:decode_batches/1, the input binary should contain at least one mssage.

Encode a list of batch inputs into byte stream.

Encode a batch of magic version 2. RecordBatch => FirstOffset => int64 Length => int32 PartitionLeaderEpoch => int32 # client set whatever Magic => int8 # The 17th byte as in v0 and v1 CRC => int32 Attributes => int16 LastOffsetDelta => int32 FirstTimestamp => int64 MaxTimestamp => int64 ProducerId => int64 ProducerEpoch => int16 FirstSequence => int32 Records => [Record]

Return true if it is a control batch.

Types

batch_input/0

-type batch_input() :: kpro:batch_input().

batch_meta/0

-type batch_meta() :: kpro:batch_meta().

compress_option/0

-type compress_option() :: kpro:compress_option().

headers/0

-type headers() :: kpro:headers().

magic/0

-type magic() :: kpro:magic().

message/0

-type message() :: kpro:message().

msg_input/0

-type msg_input() :: kpro:msg_input().

msg_ts/0

-type msg_ts() :: kpro:msg_ts().

offset/0

-type offset() :: kpro:offset().

seqno/0

-type seqno() :: kpro:seqno().

ts_type/0

-type ts_type() :: kpro:timestamp_type().

txn_ctx/0

-type txn_ctx() :: kpro:txn_ctx().

Functions

decode(Bin)

-spec decode(binary()) -> [{batch_meta(), [message()]}].

Decode received message-set into a batch list. Ensured by kpro:decode_batches/1, the input binary should contain at least one mssage.

encode(MagicVsn, Batch, Compression)

-spec encode(magic(), batch_input(), compress_option()) -> iodata().

Encode a list of batch inputs into byte stream.

encode_tx(Batch, Compression, FirstSequence, _)

-spec encode_tx(batch_input(), compress_option(), seqno(), txn_ctx()) -> iodata().

Encode a batch of magic version 2. RecordBatch => FirstOffset => int64 Length => int32 PartitionLeaderEpoch => int32 # client set whatever Magic => int8 # The 17th byte as in v0 and v1 CRC => int32 Attributes => int16 LastOffsetDelta => int32 FirstTimestamp => int64 MaxTimestamp => int64 ProducerId => int64 ProducerEpoch => int16 FirstSequence => int32 Records => [Record]

is_control(_)

-spec is_control(batch_meta()) -> boolean().

Return true if it is a control batch.