WIP: docs(pipeline): add design plan for PipelineExecutor class #3

Draft
maxp wants to merge 13 commits from feature/pipeline-executor into main
Owner

🧩 Plan: PipelineExecutor<TContext>

🎯 Ziel

Eine eigenständige, testbare Klasse zur Ausführung einer Middleware- und Handler-Pipeline, die:

  • Linear und sauber das next()-Verhalten abbildet
  • Typvalidierung durchführt (isMiddleware, isHandler)
  • Fehler behandelt und an konfigurierbare Handler weiterleitet
  • Optionale Hooks zur Tracing-Integration bietet (z. B. für Zeitmessung, Logging)
  • Am Ende eine dekorierte Response zurückliefert

🧩 Schnittstelle (API)

class PipelineExecutor<TContext extends IContext> {
    constructor(cfg: IHttpKernelConfig<TContext>);

    run(
        ctx: TContext,
        middleware: Middleware<TContext>[],
        handler: Handler<TContext>,
        hooks?: IPipelineHooks<TContext>, // optional
    ): Promise<Response>;
}

🪝 Hook-Schnittstelle (IPipelineHooks)

interface IPipelineHooks<TContext> {
    onPipelineStart?(ctx: TContext): void;
    onStepStart?(name: string | undefined, ctx: TContext): void;
    onStepEnd?(name: string | undefined, ctx: TContext, duration: number): void;
    onPipelineEnd?(ctx: TContext, totalDuration: number): void;
}
  • name ist undefined, wenn keine .name am Handler/Middleware gesetzt ist
  • Diese Hooks ermöglichen später Logging, Zeitmessung, Statistiken etc.
  • Der TraceManager wird dieses Interface implementieren

🛠️ Interne Aufgaben / Ablauf

  1. run(...) beginnt mit Aufruf onPipelineStart(ctx)
  2. Zeitmessung (performance.now())
  3. Dispatcher-Funktion führt jede Middleware mit next()-Kette aus
  4. Vor jedem Aufruf: onStepStart(name, ctx)
  5. Nach jedem Aufruf: onStepEnd(name, ctx, duration)
  6. Nach letztem Handler: onPipelineEnd(ctx, totalDuration)
  7. Ergebnis wird durch cfg.decorateResponse(res, ctx) geschickt
  8. Im Fehlerfall: cfg.httpErrorHandlers[500](ctx, error)

Vorteile

  • HttpKernel ist von Ausführungsdetails entkoppelt
  • Tracing-/Logging-System kann ohne Invasivität angeschlossen werden
  • Sehr gut testbar (z. B. Middleware-Mock + Hook-Aufrufe prüfen)
  • Erweiterbar für Timeout, Async-Context, Abbruchlogik etc.

📦 Dateiname-Vorschlag

  • src/Core/PipelineExecutor.ts oder
  • src/HttpKernel/PipelineExecutor.ts
# 🧩 Plan: `PipelineExecutor<TContext>` ## 🎯 Ziel Eine eigenständige, testbare Klasse zur Ausführung einer Middleware- und Handler-Pipeline, die: - Linear und sauber das `next()`-Verhalten abbildet - Typvalidierung durchführt (`isMiddleware`, `isHandler`) - Fehler behandelt und an konfigurierbare Handler weiterleitet - Optionale Hooks zur Tracing-Integration bietet (z. B. für Zeitmessung, Logging) - Am Ende eine dekorierte `Response` zurückliefert --- ## 🧩 Schnittstelle (API) ```ts class PipelineExecutor<TContext extends IContext> { constructor(cfg: IHttpKernelConfig<TContext>); run( ctx: TContext, middleware: Middleware<TContext>[], handler: Handler<TContext>, hooks?: IPipelineHooks<TContext>, // optional ): Promise<Response>; } ``` --- ## 🪝 Hook-Schnittstelle (`IPipelineHooks`) ```ts interface IPipelineHooks<TContext> { onPipelineStart?(ctx: TContext): void; onStepStart?(name: string | undefined, ctx: TContext): void; onStepEnd?(name: string | undefined, ctx: TContext, duration: number): void; onPipelineEnd?(ctx: TContext, totalDuration: number): void; } ``` - `name` ist `undefined`, wenn keine `.name` am Handler/Middleware gesetzt ist - Diese Hooks ermöglichen später Logging, Zeitmessung, Statistiken etc. - Der `TraceManager` wird dieses Interface implementieren --- ## 🛠️ Interne Aufgaben / Ablauf 1. `run(...)` beginnt mit Aufruf `onPipelineStart(ctx)` 2. Zeitmessung (`performance.now()`) 3. Dispatcher-Funktion führt jede Middleware mit `next()`-Kette aus 4. Vor jedem Aufruf: `onStepStart(name, ctx)` 5. Nach jedem Aufruf: `onStepEnd(name, ctx, duration)` 6. Nach letztem Handler: `onPipelineEnd(ctx, totalDuration)` 7. Ergebnis wird durch `cfg.decorateResponse(res, ctx)` geschickt 8. Im Fehlerfall: `cfg.httpErrorHandlers[500](ctx, error)` --- ## ✅ Vorteile - `HttpKernel` ist von Ausführungsdetails entkoppelt - Tracing-/Logging-System kann ohne Invasivität angeschlossen werden - Sehr gut testbar (z. B. Middleware-Mock + Hook-Aufrufe prüfen) - Erweiterbar für Timeout, Async-Context, Abbruchlogik etc. --- ## 📦 Dateiname-Vorschlag - `src/Core/PipelineExecutor.ts` oder - `src/HttpKernel/PipelineExecutor.ts`
maxp added 1 commit 2025-05-08 22:06:11 +02:00
docs(pipeline): add design plan for PipelineExecutor class
All checks were successful
Test http-kernel / Run Tests (pull_request) Successful in 10s
0846dbb758
- Introduce a detailed plan for the PipelineExecutor class
- Describe its purpose, interface, hooks, and internal workflow
- Highlight advantages such as decoupling, testability, and extensibility
- Will be removed before merge
maxp added this to the Plan: `PipelineExecutor<TContext>` milestone 2025-05-08 22:11:43 +02:00
maxp added 2 commits 2025-05-10 16:34:55 +02:00
- Introduce `IPipelineExecutorConfig` to enable customizable pipeline behavior
- Add `IPipelineHooks` interface for tracing and monitoring lifecycle events
- Define callback types for pipeline start, step execution, and completion
- Export new types and interfaces for broader integration within the system
chore(workflows): refine branch handling in release process
All checks were successful
Test http-kernel / Run Tests (pull_request) Successful in 16s
Auto Changelog & Release / detect-version-change (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Has been skipped
8f94cc915c
- Adjusts workflow to support pushes from all branches
- Ensures main branch-specific conditions for version detection
- Modifies changelog and release steps for non-main branch handling
maxp added 1 commit 2025-05-10 16:50:44 +02:00
feat(interfaces): add pipeline executor interface
All checks were successful
Auto Changelog & Release / detect-version-change (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Has been skipped
Test http-kernel / Run Tests (pull_request) Successful in 13s
927a9081d4
- Introduce `IPipelineExecutor` to define pipeline execution
- Add `PipelineExecutorFactory` for instantiating pipeline executors
- Export new types in the interfaces module for external use
maxp added 1 commit 2025-05-10 17:01:02 +02:00
fix(workflows): ensure version detection output is always set
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 4s
Auto Changelog & Release / release (push) Has been skipped
Test http-kernel / Run Tests (pull_request) Successful in 13s
Auto Changelog & Release / changelog-only (push) Successful in 10s
abd2d6e840
- Move VERSION file change detection behind a branch guard (main only)
- Use a fallback in the output step to ensure 'version_changed' is always defined
- Prevent job skipping and output access errors in feature branches
gitea-actionsbot added 1 commit 2025-05-10 17:01:19 +02:00
maxp added 2 commits 2025-05-10 17:28:26 +02:00
chore(changelog): update unreleased changelog
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / release (push) Has been skipped
Test http-kernel / Run Tests (pull_request) Successful in 14s
Auto Changelog & Release / changelog-only (push) Successful in 9s
2ab74b9859
gitea-actionsbot added 1 commit 2025-05-10 17:28:42 +02:00
maxp added 1 commit 2025-05-10 17:42:43 +02:00
feat(workflows): conditionally generate changelog
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 4s
Auto Changelog & Release / release (push) Has been skipped
Test http-kernel / Run Tests (pull_request) Successful in 12s
Auto Changelog & Release / changelog-only (push) Successful in 13s
2ab6f1b8db
- Add logic to generate changelog only if the file exists or on the main branch
- Prevent unnecessary changelog generation in other contexts
gitea-actionsbot added 1 commit 2025-05-10 17:43:02 +02:00
maxp added 1 commit 2025-05-10 17:50:57 +02:00
docs(release): update guidelines for handling changelog
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 4s
Auto Changelog & Release / release (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Successful in 8s
Test http-kernel / Run Tests (pull_request) Successful in 14s
6ce73c14fa
- Add instructions to avoid merge conflicts in `CHANGELOG.md`
- Provide steps for using `.gitattributes` to automate conflict resolution
- Clarify recommended workflows for feature branches and merging
gitea-actionsbot added 1 commit 2025-05-10 17:51:11 +02:00
This pull request has changes conflicting with the target branch.
  • .gitea/workflows/release.yml
  • CHANGELOG.md
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/pipeline-executor:feature/pipeline-executor
git checkout feature/pipeline-executor
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: maxp/http-kernel#3
No description provided.