kafka

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package kafka provides a client with included tracing capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultProducerSaramaConfig added in v0.74.0

func DefaultProducerSaramaConfig(name string, idempotent bool) (*sarama.Config, error)

DefaultProducerSaramaConfig creates a default Sarama configuration with idempotency enabled. See also: * https://pkg.go.dev/github.com/Shopify/sarama#RequiredAcks * https://pkg.go.dev/github.com/Shopify/sarama#Config

Types

type AsyncProducer

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

AsyncProducer is an asynchronous Kafka producer.

func (*AsyncProducer) ActiveBrokers

func (p *AsyncProducer) ActiveBrokers() []string

ActiveBrokers returns a list of active brokers' addresses.

func (*AsyncProducer) Close

func (ap *AsyncProducer) Close() error

Close shuts down the producer and waits for any buffered messages to be flushed. You must call this function before a producer object passes out of scope, as it may otherwise leak memory.

func (*AsyncProducer) Send

Send a message to a topic, asynchronously. Producer errors are queued on the channel obtained during the AsyncProducer creation.

type Builder added in v0.41.0

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

Builder definition for creating sync and async producers.

func New added in v0.74.0

func New(brokers []string, saramaConfig *sarama.Config) *Builder

New initiates the AsyncProducer/SyncProducer builder chain with the specified Sarama configuration.

func (*Builder) Create added in v0.74.0

func (b *Builder) Create() (*SyncProducer, error)

Create a new synchronous producer.

func (*Builder) CreateAsync added in v0.41.0

func (b *Builder) CreateAsync() (*AsyncProducer, <-chan error, error)

CreateAsync a new asynchronous producer.

type SyncProducer added in v0.41.0

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

SyncProducer is a synchronous Kafka producer.

func (*SyncProducer) ActiveBrokers added in v0.41.0

func (p *SyncProducer) ActiveBrokers() []string

ActiveBrokers returns a list of active brokers' addresses.

func (*SyncProducer) Close added in v0.41.0

func (p *SyncProducer) Close() error

Close shuts down the producer and waits for any buffered messages to be flushed. You must call this function before a producer object passes out of scope, as it may otherwise leak memory.

func (*SyncProducer) Send added in v0.41.0

Send a message to a topic.

func (*SyncProducer) SendBatch added in v0.74.0

func (p *SyncProducer) SendBatch(ctx context.Context, messages []*sarama.ProducerMessage) error

SendBatch sends a batch to a topic.

Jump to

Keyboard shortcuts

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