router

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyLogger        string = "context_key_logger"
	ContextKeyKafkaConsumer        = "router_context_key_kafka_consumer"
	ContextKeyEventHandlers        = "router_context_key_event_handlers"
)

Variables

View Source
var ErrUnsupportedEventVersion = errors.New("unsupported event version")

ErrUnsupportedEventVersion is returned when the detected version of the event is not supported by any of the existing handlers.

Functions

func ConsumeMessages

func ConsumeMessages(ctx context.Context)

ConsumeMessages fetches messages from a Kafka topic, detects events, and routes the events to the appropriate handler. The handlers are expected to continue retrying on temporary errors, while permanent errors are expected to be written to a dead letter queue.

func GetLogger

func GetLogger(ctx context.Context) *zap.Logger

Types

type EventHandlers

type EventHandlers interface {
	PermanentErrorHandler(ctx context.Context, event kafkamsgs.Event, err error)
	CapabilityCreatedHandler(ctx context.Context, event kafkamsgs.Event)
}

func GetEventHandlers

func GetEventHandlers(ctx context.Context) EventHandlers

type KafkaConsumer

type KafkaConsumer interface {
	FetchMessage(ctx context.Context) (kafka.Message, error)
	CommitMessages(ctx context.Context, msgs ...kafka.Message) error
}

func GetKafkaConsumer

func GetKafkaConsumer(ctx context.Context) KafkaConsumer

Jump to

Keyboard shortcuts

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