boltprojection

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package boltprojection provides utilities for building BoltDB-based projections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New returns a new dogma.ProjectionMessageHandler that binds a BoltDB-specific MessageHandler to a BoltDB database.

Types

type MessageHandler

type MessageHandler interface {
	// Configure declares the handler's configuration by calling methods on c.
	//
	// The configuration includes the handler's identity and message routes.
	//
	// The engine calls this method at least once during startup. It must
	// produce the same configuration each time it's called.
	Configure(c dogma.ProjectionConfigurer)

	// HandleEvent updates the projection to reflect the occurrence of a
	// [dogma.Event].
	//
	// Changes to the projection's data must be performed within the supplied
	// transaction.
	HandleEvent(ctx context.Context, tx *bbolt.Tx, s dogma.ProjectionEventScope, m dogma.Event) error

	// Compact reduces the projection's size by removing or consolidating data.
	//
	// The handler might delete obsolete entries or merge fine-grained data into
	// summaries. The specific strategy depends on the projection's purpose and
	// access patterns.
	//
	// The implementation should perform compaction incrementally to make some
	// progress even if ctx reaches its deadline.
	//
	// The engine may call this method at any time, including in parallel with
	// handling an event.
	//
	// Not all projections need compaction. Embed [NoCompactBehavior] in the
	// handler to indicate compaction not required.
	Compact(ctx context.Context, db *bbolt.DB, s dogma.ProjectionCompactScope) error

	// Reset clears all projection data.
	//
	// Changes to the projection's data must be performed within the supplied
	// transaction.
	//
	// Not all projections can be reset. Embed [NoResetBehavior] in the handler
	// to indicate that reset is not supported.
	Reset(ctx context.Context, tx *bbolt.Tx, s dogma.ProjectionResetScope) error
}

MessageHandler is a specialization of dogma.ProjectionMessageHandler that persists to a BoltDB (or, more correctly, a bbolt) database.

type NoCompactBehavior

type NoCompactBehavior struct{}

NoCompactBehavior is an embeddable type for MessageHandler implementations that don't require compaction.

Embed this type in a MessageHandler when projection data doesn't grow unbounded or when an external system handles compaction.

func (NoCompactBehavior) Compact

Compact returns nil without performing any operations.

type NoResetBehavior added in v0.9.0

type NoResetBehavior struct{}

NoResetBehavior is an embeddable type for MessageHandler implementations that don't support resetting their state.

Embed this type in a MessageHandler when resetting projection data isn't feasible or required.

func (NoResetBehavior) Reset added in v0.9.0

Reset returns an error indicating that reset is not supported.

Directories

Path Synopsis
internal
fixtures
Package fixtures is a set of test fixtures and mocks for BoltDB projections.
Package fixtures is a set of test fixtures and mocks for BoltDB projections.

Jump to

Keyboard shortcuts

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