kafka

package
v2.0.0-...-1c13370 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used to configure the Kafka producer

func WithErrorHandler

func WithErrorHandler(errorHandler func(error)) Option

WithErrorHandler specifies a custom error handler for the Kafka producer

func WithFlushInterval

func WithFlushInterval(interval time.Duration) Option

WithFlushInterval specifies a flush interval for the Kafka producer

func WithMaxRetries

func WithMaxRetries(maxRetries int) Option

WithMaxRetries specifies the total number of times to retry sending a message

func WithVersion

func WithVersion(version sarama.KafkaVersion) Option

WithVersion specified the kafka cluster version to connect to

type Producer

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

Producer is a Kafka producer based on Sarama

func NewProducer

func NewProducer(brokers []string, opts ...Option) (*Producer, error)

NewProducer creates a Kafka producer

func (*Producer) Close

func (p *Producer) Close() error

Close stops the producer from accepting and sending any new messages

func (*Producer) Produce

func (p *Producer) Produce(ctx context.Context, topic string, key []byte, msg []byte) error

Produce sends a message to a particular Kafka topic

func (*Producer) Run

func (p *Producer) Run()

Run tells the producer to start accepting messages to publish to Kafka

Jump to

Keyboard shortcuts

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