github.com/QuangHoangHao/kafka-go@v0.4.36/record.go (about)

     1  package kafka
     2  
     3  import (
     4  	"github.com/QuangHoangHao/kafka-go/protocol"
     5  )
     6  
     7  // Header is a key/value pair type representing headers set on records.
     8  type Header = protocol.Header
     9  
    10  // Bytes is an interface representing a sequence of bytes. This abstraction
    11  // makes it possible for programs to inject data into produce requests without
    12  // having to load in into an intermediary buffer, or read record keys and values
    13  // from a fetch response directly from internal buffers.
    14  //
    15  // Bytes are not safe to use concurrently from multiple goroutines.
    16  type Bytes = protocol.Bytes
    17  
    18  // NewBytes constructs a Bytes value from a byte slice.
    19  //
    20  // If b is nil, nil is returned.
    21  func NewBytes(b []byte) Bytes { return protocol.NewBytes(b) }
    22  
    23  // ReadAll reads b into a byte slice.
    24  func ReadAll(b Bytes) ([]byte, error) { return protocol.ReadAll(b) }
    25  
    26  // Record is an interface representing a single kafka record.
    27  //
    28  // Record values are not safe to use concurrently from multiple goroutines.
    29  type Record = protocol.Record
    30  
    31  // RecordReader is an interface representing a sequence of records. Record sets
    32  // are used in both produce and fetch requests to represent the sequence of
    33  // records that are sent to or receive from kafka brokers.
    34  //
    35  // RecordReader values are not safe to use concurrently from multiple goroutines.
    36  type RecordReader = protocol.RecordReader
    37  
    38  // NewRecordReade reconstructs a RecordSet which exposes the sequence of records
    39  // passed as arguments.
    40  func NewRecordReader(records ...Record) RecordReader {
    41  	return protocol.NewRecordReader(records...)
    42  }