usecase

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package usecase implements the outbox business logic and orchestrates outbox domain operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval      time.Duration
	BatchSize     int
	MaxRetries    int
	RetryInterval time.Duration
}

Config holds outbox use case configuration

type DefaultEventProcessor

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

DefaultEventProcessor is a default implementation of EventProcessor

func NewDefaultEventProcessor

func NewDefaultEventProcessor(logger *slog.Logger) *DefaultEventProcessor

NewDefaultEventProcessor creates a new DefaultEventProcessor

func (*DefaultEventProcessor) Process

func (p *DefaultEventProcessor) Process(ctx context.Context, event *domain.OutboxEvent) error

Process handles event processing with basic logging

type EventProcessor

type EventProcessor interface {
	Process(ctx context.Context, event *domain.OutboxEvent) error
}

EventProcessor defines the interface for processing different event types

type OutboxEventRepository

type OutboxEventRepository interface {
	Create(ctx context.Context, event *domain.OutboxEvent) error
	GetPendingEvents(ctx context.Context, limit int) ([]*domain.OutboxEvent, error)
	Update(ctx context.Context, event *domain.OutboxEvent) error
}

OutboxEventRepository defines outbox event repository operations

type OutboxUseCase

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

OutboxUseCase implements business logic for processing outbox events

func NewOutboxUseCase

func NewOutboxUseCase(
	config Config,
	txManager database.TxManager,
	outboxRepo OutboxEventRepository,
	eventProcessor EventProcessor,
	logger *slog.Logger,
) *OutboxUseCase

NewOutboxUseCase creates a new OutboxUseCase

func (*OutboxUseCase) ProcessEvents

func (uc *OutboxUseCase) ProcessEvents(ctx context.Context) error

ProcessEvents retrieves and processes pending events from the outbox in a transaction

func (*OutboxUseCase) Start

func (uc *OutboxUseCase) Start(ctx context.Context) error

Start starts the outbox event processing loop

type UseCase

type UseCase interface {
	Start(ctx context.Context) error
	ProcessEvents(ctx context.Context) error
}

UseCase defines the interface for outbox use cases

Jump to

Keyboard shortcuts

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