kafka

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	// Subscribe consumes the events of a topic and passes the event to the
	// informed callback function. The method call blocks until an error occurs.
	// The program may also specify a context to asynchronously cancel the blocking operation.
	Subscribe(ctx context.Context, callbackFn func(event *Event, err error))

	// Close closes the stream, preventing the program from reading any more
	// events from it.
	Close()
}

Consumer provide methods for consuming events on a given topic.

type Event

type Event struct {
	Topic  string
	Key    []byte
	Value  []byte
	Header map[string]string
	Time   time.Time
}

Event structure that represents a Kafka event.

type Kafka

type Kafka interface {

	// NewProducer creates a new Producer to produce events on a topic.
	NewProducer(topic string) Producer

	// NewConsumer creates a new Consumer to consume events from a topic.
	NewConsumer(groupID, topic string) Consumer

	// Debug enables logging of incoming events.
	Debug(debug bool)
}

Kafka it is an abstraction to send and consume events from an event kafka service.

func New

func New(kafkaBrokerUrls []string, clientId string) Kafka

NewKafka creates a new instance of Kafka.

type Producer

type Producer interface {
	// Publish produces and sends an event for a kafka topic.
	// The context passed as first argument may also be used to asynchronously
	// cancel the operation.
	Publish(ctx context.Context, key []byte, values ...[]byte) error

	// Close flushes pending writes, and waits for all writes to complete before
	// returning.
	Close()
}

Producer provide methods for producing events for a given topic.

Jump to

Keyboard shortcuts

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