kafkacommon

package module
v0.0.0-...-1764f6e Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 7 Imported by: 0

README

kafkacommon

Wrapper for segmentio/kafka-go writer with retries and metrics

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Write(ctx context.Context, messages []kafka.Message) error
}

type Client

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

func NewClient

func NewClient(config *Config, metrics promcommon.BrokerIncrementObserver) (*Client, error)

func (*Client) Write

func (c *Client) Write(ctx context.Context, message kafka.Message) error

type Config

type Config struct {
	Addresses               []string      `env:"ADDRESSES" yaml:"addresses"`
	WriteTopic              string        `env:"WRITE_TOPIC" yaml:"write_topic"`
	WriteBatchSize          int           `env:"WRITE_BATCH_SIZE" yaml:"write_batch_size"`
	WriteBatchTimeout       time.Duration `env:"WRITE_BATCH_TIMEOUT" yaml:"write_batch_timeout"`
	WriteMaxRetryCount      uint64        `env:"WRITE_MAX_RETRY_COUNT" yaml:"write_max_retry_count"`
	WriteRetryJitterPercent uint64        `env:"WRITE_RETRY_JITTER_PERCENT" yaml:"write_retry_jitter_percent"`
	WriteRetryTimeout       time.Duration `env:"WRITE_RETRY_TIMEOUT" yaml:"write_retry_timeout"`
}

func (*Config) WithDefaults

func (c *Config) WithDefaults() (*Config, error)

Jump to

Keyboard shortcuts

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