httphandleroptions

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPHandler

type HTTPHandler struct {
	Logger               *slog.Logger
	KafkaProducer        sarama.AsyncProducer
	ProducerMessageQueue chan *sarama.ProducerMessage
}

HTTPHandler represents http handler functionality.

func New

func New(options ...Option) (*HTTPHandler, error)

New instantiates new http handler.

func (HTTPHandler) MessageWorker

func (h HTTPHandler) MessageWorker(workedID int)

MessageWorker consumes produced messages.

func (HTTPHandler) Shutdown

func (h HTTPHandler) Shutdown()

Shutdown closes producer message queue channel.

type Handler

type Handler interface {
	MessageWorker(workedID int)
}

Handler defines http handler behaviours.

type Option

type Option func(*HTTPHandler) error

Option represents option function type.

func WithKafkaProducer

func WithKafkaProducer(kp sarama.AsyncProducer) Option

WithKafkaProducer sets kafka producer.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets logger.

func WithProducerMessageQueue

func WithProducerMessageQueue(mq chan *sarama.ProducerMessage) Option

WithProducerMessageQueue sets kafka producer message queue.

Jump to

Keyboard shortcuts

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