kafka

package module
v0.0.0-...-7af37e1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KafkaConfig

type KafkaConfig struct {
	Brokers []string
	Topic   string
	GroupID string // Used for consumers
}

type KafkaConsumer

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

func NewConsumer

func NewConsumer(config KafkaConfig) *KafkaConsumer

NewConsumer creates a new KafkaConsumer instance.

func (*KafkaConsumer) Close

func (c *KafkaConsumer) Close() error

Close closes the Kafka consumer.

func (*KafkaConsumer) Consume

func (c *KafkaConsumer) Consume(ctx context.Context, handler func(key, value []byte) error)

Consume starts consuming messages and calls the handler for each message.

type KafkaProducer

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

func NewProducer

func NewProducer(config KafkaConfig) *KafkaProducer

NewProducer creates a new KafkaProducer instance.

func (*KafkaProducer) Close

func (p *KafkaProducer) Close() error

Close closes the Kafka producer.

func (*KafkaProducer) Publish

func (p *KafkaProducer) Publish(ctx context.Context, event *events.Event) error

Publish sends a message to the Kafka topic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳