client

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicPlaceholder     string = "%t"
	PartitionPlaceholder string = "%p"
	OffsetPlaceholder    string = "%o"
	TimestampPlaceholder string = "%e"
	KeyPlaceholder       string = "%k"
	ValuePlaceholder     string = "%v"
)

Valid format string placeholders.

View Source
const MessageBufferSize = 256

MessageBufferSize is the default buffer size for consuming/producing.

Variables

This section is empty.

Functions

func FormatterHelp

func FormatterHelp() string

FormatterHelp returns a message describing format tokens.

func ParseStart

func ParseStart(s string) (int64, error)

ParseStart returns a start offset parsed from s.

Types

type Consumer

type Consumer struct {
	// contains filtered or unexported fields
}

Consumer is a high level API for a Kafka consumer.

func NewConsumer

func NewConsumer(broker string) (Consumer, error)

NewConsumer returns a Consumer for the given broker.

func (Consumer) Close

func (c Consumer) Close() error

Close shuts the consumer down.

func (Consumer) Consume

func (c Consumer) Consume(ctx context.Context, topic string, startOffset int64, messages chan<- Message) error

Consume reads messages from topic and sends them to the given chan until ctx is done.

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter describes a way of printing Kafka messages.

func NewFormatter

func NewFormatter(format string) Formatter

NewFormatter returns a Formatter initialized with a format string.

func (Formatter) Format

func (f Formatter) Format(m Message) string

Format returns a copy of the Formatter format string with the placeholders replaced with values from the Message.

type Message

type Message struct {
	Topic     string
	Partition int32
	Offset    int64
	Timestamp time.Time
	Key       string
	Value     string
}

Message represents a Kafka message.

type Producer

type Producer struct {
	// contains filtered or unexported fields
}

Producer is a high level API for a Kafka producer.

func NewProducer

func NewProducer(broker string) (Producer, error)

NewProducer returns a Producer for the given broker.

func (Producer) Close

func (p Producer) Close() error

Close shuts the producer down.

func (Producer) Produce

func (p Producer) Produce(m Message) error

Produce sends a Message to Kafka.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL