worker

package
v0.0.0-...-ffdedf7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BatchSize int           `env:"BATCH_SIZE"` // default: 100
	Interval  time.Duration `env:"INTERVAL"`   // default: 1s
	Timeout   time.Duration `env:"TIMEOUT"`    // default: 10s
}

Config holds the worker configuration. The zero value is a valid configuration.

type Worker

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

Worker is a worker that sends messages from the outbox to Kafka. It should be created with NewWorker.

func NewWorker

func NewWorker(cfg Config, log *slog.Logger, kafkaWriter *kafka.Writer, postgresPool *pgxpool.Pool) *Worker

NewWorker creates a new Worker.

func (*Worker) Run

func (w *Worker) Run(done <-chan struct{})

Run runs the worker. It sends messages from the outbox to Kafka in batches every interval. It stops when done is closed.

Jump to

Keyboard shortcuts

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