projection

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package projection provides engine components that orchestrate the execution of projection message handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeHandler

func InitializeHandler(
	ctx context.Context,
	db *sql.DB,
	handlerConfig *config.Projection,
) error

InitializeHandler initializes the state of a projection message handler.

It is called by the engine on startup, before any components are started.

Types

type Compactor

type Compactor struct {
	DB       *sql.DB
	Handler  dogma.ProjectionMessageHandler
	Identity *identitypb.Identity
	Interval time.Duration
	Logger   *slog.Logger
}

Compactor is an engine component that periodically attempts to compact a projection by invoking dogma.ProjectionMessageHandler.Compact().

func (*Compactor) Run

func (c *Compactor) Run(ctx context.Context)

Run executes the compactor until ctx is canceled.

type EventPump

type EventPump struct {
	DB           *sql.DB
	Handler      dogma.ProjectionMessageHandler
	Identity     *identitypb.Identity
	Concurrency  dogma.ConcurrencyPreference
	EventTypeIDs *uuidpb.Set
	Logger       *slog.Logger
}

EventPump is a messagepump.Driver that delivers pending events to a projection message handler.

func (*EventPump) AcquireDelivery

func (p *EventPump) AcquireDelivery(
	ctx context.Context,
	tx *sql.Tx,
) (messagepump.Delivery, bool, error)

AcquireDelivery attempts to acquire the next pending event for the handler on one of its tracked event streams.

If there are no relevant events available on the chosen stream, it advances the checkpoint offset to the end of the stream so that the stream is not re-acquired until new events arrive.

func (*EventPump) HandleDelivery

func (p *EventPump) HandleDelivery(
	ctx context.Context,
	tx *sql.Tx,
	delivery messagepump.Delivery,
	envelope *envelopepb.Envelope,
	logger *slog.Logger,
) error

HandleDelivery dispatches an event to the projection handler.

func (*EventPump) PostponeDelivery

func (p *EventPump) PostponeDelivery(
	ctx context.Context,
	tx *sql.Tx,
	delivery messagepump.Delivery,
	delay time.Duration,
) error

PostponeDelivery reschedules consumption of the stream after delay.

Jump to

Keyboard shortcuts

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