chain

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: GPL-2.0 Imports: 1 Imported by: 4

Documentation

Overview

Package chain provides interfaces for ordered processing of data through stages. Chains allow modifications to be applied in a predictable order, making complex game mechanics composable and testable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain[T any] interface {
	// Add registers a modifier at the specified stage with a unique ID.
	// Returns an error if the ID already exists.
	Add(stage Stage, id string, modifier func(context.Context, T) (T, error)) error

	// Remove unregisters a modifier by its ID.
	// Returns an error if the ID does not exist.
	Remove(id string) error

	// Execute runs all modifiers in stage order, transforming the data.
	Execute(ctx context.Context, data T) (T, error)
}

Chain processes data through ordered stages of modifications. Each modification transforms the data and passes it to the next.

type Stage

type Stage string

Stage represents a processing stage in a chain. Stages determine the order of execution for modifications.

Jump to

Keyboard shortcuts

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