internal

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetryHeaderKey              = "x-retry-count"
	MessageProduceTimeHeaderKey = "x-produce-time"
)

Variables

This section is empty.

Functions

func FromHeaders added in v0.6.2

func FromHeaders(sh []segmentio.Header) []kafka.Header

func Mechanism

func Mechanism(sasl kafka.SASLConfig) sasl.Mechanism

TODO: we can support `plain` authentication type link: https://github.com/segmentio/kafka-go#plain

func NewCronsumer

func NewCronsumer(cfg *kafka.Config, fn kafka.ConsumeFn) kafka.Cronsumer

func NewTLSConfig

func NewTLSConfig(sasl kafka.SASLConfig) *tls.Config

func ToHeaders added in v0.6.2

func ToHeaders(h []kafka.Header) []segmentio.Header

Types

type Consumer

type Consumer interface {
	ReadMessage(ctx context.Context) (*MessageWrapper, error)
	Stop()
}

type MessageWrapper

type MessageWrapper struct {
	kafka.Message
	RetryCount  int
	ProduceTime int64 // Nano time
}

func NewMessageWrapper

func NewMessageWrapper(msg segmentio.Message) *MessageWrapper

func (*MessageWrapper) GetHeaders

func (m *MessageWrapper) GetHeaders() map[string][]byte

func (*MessageWrapper) IncreaseRetryCount

func (m *MessageWrapper) IncreaseRetryCount()

func (*MessageWrapper) IsExceedMaxRetryCount

func (m *MessageWrapper) IsExceedMaxRetryCount(maxRetry int) bool

func (*MessageWrapper) NewProduceTime

func (m *MessageWrapper) NewProduceTime()

func (*MessageWrapper) RouteMessageToTopic

func (m *MessageWrapper) RouteMessageToTopic(topic string)

func (*MessageWrapper) To

func (m *MessageWrapper) To(increaseRetry bool) segmentio.Message

type Producer

type Producer interface {
	ProduceWithRetryOption(message MessageWrapper, increaseRetry bool) error
	Produce(message kafka.Message) error
	ProduceBatch(messages []kafka.Message) error
	Close()
}

Jump to

Keyboard shortcuts

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