Skip to content

feat: add Pipeline grouping and PipeInterface#9

Closed
DerManoMann wants to merge 3 commits into
feat/spec-dtofrom
feat/pipeline-groups
Closed

feat: add Pipeline grouping and PipeInterface#9
DerManoMann wants to merge 3 commits into
feat/spec-dtofrom
feat/pipeline-groups

Conversation

@DerManoMann

Copy link
Copy Markdown
Owner

Summary

Enhances the existing Pipeline utility with ordered group execution, enabling staged processing pipelines (e.g. resolve → reduce → augment). Adds PipeInterface as an optional contract for
pipes that declare their group.

Depends on zircote#2054.

Design

Grouped execution

When constructed with a groups array, the pipeline executes pipes in group order rather than insertion order. This enables multi-stage processing where pipes from different groups can be
registered in any order but always execute in the correct sequence.

$pipeline = new Pipeline(
    [$augmentPipe, $resolvePipe],
    groups: ['resolve', 'reduce', 'augment'],
    defaultGroup: 'augment',
);
// resolvePipe runs first, augmentPipe second — regardless of insertion order

PipeInterface

Optional interface for pipes that declare their group:

interface PipeInterface
{
    public function group(): string|\BackedEnum;
    public function __invoke(mixed $payload): mixed;
}

Pipes without PipeInterface are placed in the pipeline's default group. Both string and BackedEnum group keys are supported.

Other additions

- get(class-string): ?T — retrieve a pipe by class for typed configuration access
- LoggerAwareInterface support — logger injected into pipes during process()
- walk() now reflects grouped execution order (not insertion order)
- process() uses ?? (not ?:) to preserve falsy return values from pipes

Backwards compatible

Without groups configured, insertion order is preserved — existing behavior unchanged.

@DerManoMann DerManoMann force-pushed the feat/pipeline-groups branch from e2d1b10 to e051743 Compare July 12, 2026 08:21
DerManoMann and others added 3 commits July 12, 2026 20:29
Enhance Pipeline with ordered group execution for staged processing:

- PipeInterface: optional contract for pipes that declare their group
- Constructor accepts groups (ordered execution buckets) and defaultGroup
- process() executes pipes in group order when groups are configured
- get() retrieves a pipe by class-string for typed configuration access
- LoggerAwareInterface support: logger injected into pipes during process()
- BackedEnum support for group keys

Backwards compatible: without groups, insertion order is preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DerManoMann DerManoMann force-pushed the feat/pipeline-groups branch from e051743 to 3858ff0 Compare July 12, 2026 21:33
@DerManoMann

Copy link
Copy Markdown
Owner Author

Moved to zircote#2056 (base branch updated to master now that spec-dto is merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant