kafka

package
v1.64.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package kafka provides a simple abstraction to send and pull Apache Kafka messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

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

Consumer represents a wrapper around kafka.Consumer.

func NewConsumer

func NewConsumer(brokers []string, topic, groupID string, opts ...Option) (*Consumer, error)

NewConsumer creates a new instance of Consumer. Please call the HealthCheck() method to check if the connection is working.

func (*Consumer) Close

func (c *Consumer) Close() error

Close cleans up Consumer's internal resources.

func (*Consumer) HealthCheck added in v1.36.0

func (c *Consumer) HealthCheck(ctx context.Context) error

HealthCheck checks if the consumer is working.

func (*Consumer) Receive added in v1.33.0

func (c *Consumer) Receive(ctx context.Context) ([]byte, error)

Receive reads one message from the Kafka; blocks if there are no messages in the queue.

type Option

type Option func(*config)

Option is a type alias for a function that configures Kafka client.

func WithFirstOffset added in v1.35.0

func WithFirstOffset() Option

WithFirstOffset tells Kafka consumer to read from the beginning of uncommitted offset. By default it will read from the end of the queue.

func WithSessionTimeout

func WithSessionTimeout(t time.Duration) Option

WithSessionTimeout sets the timeout used to detect client failures when using Kafka's group management facility. The client sends periodic heartbeats to indicate its liveness to the broker. If no heartbeats are received by the broker before the expiration of this session timeout, then the broker will remove this client from the group and initiate a rebalance.

type Producer

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

Producer represents a wrapper around kafka.Producer.

func NewProducer

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

NewProducer creates a new instance of Producer.

func (*Producer) Close

func (p *Producer) Close() error

Close cleans up Producer's internal resources.

func (*Producer) Send added in v1.33.0

func (p *Producer) Send(ctx context.Context, msg []byte) error

Send sends a message to Kafka topic.

Jump to

Keyboard shortcuts

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