producer

package
v0.0.0-...-2de5c43 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 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 Client

type Client interface {
	Topic() string
	Publish(ctx context.Context, value []byte, key []byte) error
	PublishWithoutKey(ctx context.Context, value []byte) error
	PublishWithEvent(ctx context.Context, value []byte, key []byte, event chan kafka.Event) error
	PublishRaw(ctx context.Context, msg *kafka.Message, event chan kafka.Event) error
	Close()
}

func NewProducer

func NewProducer(cfg Config, opts ...Option) (Client, error)

type Config

type Config struct {
	Topic            string                       `json:"topic"`
	BootstrapServers string                       `json:"bootstrap.servers"`
	SecurityProtocol string                       `json:"security.protocol"`
	SslCaLocation    string                       `json:"ssl.ca.location"`
	SaslMechanism    string                       `json:"sasl.mechanism"`
	SaslUsername     string                       `json:"sasl.username"`
	SaslPassword     string                       `json:"sasl.password"`
	ConfigMap        map[string]kafka.ConfigValue `json:"config.map"`
}

type EventHandlerFunc

type EventHandlerFunc func(event kafka.Event)

type Option

type Option func(opts *Options)

func EventHandler

func EventHandler(handler EventHandlerFunc) Option

func IsDebug

func IsDebug(isDebug bool) Option

type Options

type Options struct {
	Topic        string
	EventHandler EventHandlerFunc
	IsDebug      bool
}

Jump to

Keyboard shortcuts

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