kafkago

package
v0.0.0-...-160e237 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderKey = "_key"
View Source
const NoSleep time.Duration = -1
View Source
const UUIDHeaderKey = "_watermill_message_uuid"

Variables

This section is empty.

Functions

func NewPublisher

func NewPublisher(config PublisherConfig, logger watermill.LoggerAdapter) message.Publisher

func NewSubscriber

func NewSubscriber(config SubscriberConfig, logger watermill.LoggerAdapter) (message.Subscriber, error)

func TCP4

func TCP4(address ...string) net.Addr

Types

type DefaultMarshaler

type DefaultMarshaler struct {
}

func (DefaultMarshaler) Marshal

func (d DefaultMarshaler) Marshal(topic string, msg *message.Message) (*kafka.Message, error)

func (DefaultMarshaler) Unmarshal

func (DefaultMarshaler) Unmarshal(kmsg *kafka.Message) (*message.Message, error)

type Marshaler

type Marshaler interface {
	Marshal(topic string, msg *message.Message) (*kafka.Message, error)
}

type MarshalerUnmarshaler

type MarshalerUnmarshaler interface {
	Marshaler
	Unmarshaler
}

type Publisher

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

func (*Publisher) Close

func (p *Publisher) Close() error

func (*Publisher) Publish

func (p *Publisher) Publish(topic string, msgs ...*message.Message) error

type PublisherConfig

type PublisherConfig struct {
	Writer *kafka.Writer

	Brokers []string

	Async bool

	// Marshaler is used to marshal messages from Watermill format into Kafka format.
	Marshaler Marshaler

	// If true then each sent message will be wrapped with Opentelemetry tracing, provided by otelsarama.
	OTELEnabled bool
	Ipv4Only    bool
	Timeout     time.Duration
}

func (*PublisherConfig) Validate

func (c *PublisherConfig) Validate() error

type Subscriber

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

func (*Subscriber) Close

func (s *Subscriber) Close() error

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)

type SubscriberConfig

type SubscriberConfig struct {
	Brokers []string

	Unmarshaler Unmarshaler

	OverrideReaderConfig kafka.ReaderConfig

	ConsumerGroup string

	NackResendSleep time.Duration

	ReconnectRetrySleep time.Duration

	OTELEnabled bool
}

func (SubscriberConfig) Validate

func (c SubscriberConfig) Validate() error

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(*kafka.Message) (*message.Message, error)
}

Jump to

Keyboard shortcuts

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