runner

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package runner provides optional tooling for running multiple projections and scaling them safely. This package is designed to be explicit, deterministic, and CLI-friendly without imposing framework behavior or automatic scheduling.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoProjections indicates that no projections were provided to run.
	ErrNoProjections = errors.New("no projections provided")

	// ErrInvalidPartitionConfig indicates invalid partition configuration.
	ErrInvalidPartitionConfig = errors.New("invalid partition configuration")
)

Functions

This section is empty.

Types

type ProjectionRunner

type ProjectionRunner struct {
	Projection projection.Projection
	Processor  projection.ProcessorRunner
}

ProjectionRunner pairs a projection with its processor. The processor is adapter-specific (postgres.Processor, mysql.Processor, etc.) and knows how to manage transactions and checkpoints for that storage type.

type Runner

type Runner struct{}

Runner orchestrates multiple projections concurrently. It is storage-agnostic and works with any processor implementation.

Example with PostgreSQL:

store := postgres.NewStore(postgres.DefaultStoreConfig()) processor1 := postgres.NewProcessor(db, store, &config1) processor2 := postgres.NewProcessor(db, store, &config2)

runner := runner.New()

err := runner.Run(ctx, []runner.ProjectionRunner{
   {Projection: &MyProjection{}, Processor: processor1},
   {Projection: &MyOtherProjection{}, Processor: processor2},
})

func New

func New() *Runner

New creates a new projection runner.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, runners []ProjectionRunner) error

Run runs multiple projections concurrently until the context is canceled. Each projection runs in its own goroutine with its processor. Returns when the context is canceled or when any projection returns an error.

If a projection returns an error, all other projections are canceled and the error is returned. This ensures fail-fast behavior.

This method is safe to call from CLIs and does not assume single-process ownership. Coordination happens via the processor's checkpoint management.

Jump to

Keyboard shortcuts

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