writer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *kafka.Writer

DefaultConfig returns the default configuration for a Kafka writer.

func NewWriter

func NewWriter(opts ...Opt) *kafka.Writer

NewWriter creates a new Kafka writer.

Types

type Opt

type Opt func(*kafka.Writer)

Opt defines an option for a Kafka writer.

func WithBalancer

func WithBalancer(b kafka.Balancer) Opt

WithBalancer configures the balancing mechanism for the writer.

func WithBatchSize

func WithBatchSize(batchSize int) Opt

WithBatchSize configures the batch size for the writer.

func WithBatchTimeout

func WithBatchTimeout(timeout time.Duration) Opt

WithBatchTimeout configures the batch timeout for the writer.

func WithBrokers

func WithBrokers(brokers ...string) Opt

WithBrokers configures the brokers for the writer.

func WithTopic

func WithTopic(topic string) Opt

WithTopic configures the topic for the writer.

func WithTransport

func WithTransport(transport *kafka.Transport) Opt

WithTransport configures the transport for the writer.

type Writer

type Writer interface {
	// Close closes the writer.
	Close() error

	// Stats returns the writer statistics.
	Stats() kafka.WriterStats

	// WriteMessage writes a message to Kafka.
	WriteMessages(ctx context.Context, msgs ...kafka.Message) error
}

Writer is a Kafka writer.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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