GdlrCommandPipeline¶
Inherits: RefCounted < Object
Runs one command type through prioritized middleware callbacks.
Description¶
Internal. The bundled CapGdlrCommandHandlers service creates one pipeline per command class. Register callbacks through that capability.
The pipeline works like GdlrMiddlewarePipeline with a fixed argument list. Callback signatures:
core, before, and core override:
func(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context).around:
func(next: Callable, envelope, ctx). Callnextwith the envelope and the context to continue.after:
func(envelope, ctx, result). Return the result to pass on.should_run:
func(envelope, ctx) -> bool.
The core and around callbacks can await. The others run without await.
Before and after callbacks run by ascending priority, then by insertion order. Around callbacks form layers with the lowest priority as the outer layer. Among core overrides whose predicate matches, the one with the highest priority replaces the core.
Tutorials¶
Methods¶
void |
|
void |
set_core_override(fn: Callable, priority: int = 0, should_run: Callable = Callable()) |
void |
use_before(fn: Callable, priority: int = 0, should_run: Callable = Callable()) |
void |
use_around(fn: Callable, priority: int = 0, should_run: Callable = Callable()) |
void |
use_after(fn: Callable, priority: int = 0, should_run: Callable = Callable()) |
void |
use(middleware: GdlrCommandMiddleware, priority: int = 0) |
void |
|
run(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context) |
Method Descriptions¶
Sets the callable that handles the command.
void set_core_override(fn: Callable, priority: int = 0, should_run: Callable = Callable()) 🔗
Adds a callable that replaces the core when should_run returns true. An override without a predicate always matches.
void use_before(fn: Callable, priority: int = 0, should_run: Callable = Callable()) 🔗
Adds a callback that runs before the handler.
void use_around(fn: Callable, priority: int = 0, should_run: Callable = Callable()) 🔗
Adds a callback that wraps the handler.
void use_after(fn: Callable, priority: int = 0, should_run: Callable = Callable()) 🔗
Adds a callback that runs after the handler and can replace the result.
void use(middleware: GdlrCommandMiddleware, priority: int = 0) 🔗
Registers every callback that middleware implements with the same priority. See GdlrCommandMiddleware for the method names. Reports an error when the middleware implements none of them.
void remove_by_callback(fn: Callable) 🔗
Removes every callback and override that uses fn.
Variant run(envelope: CapGdlrCommandBus.CommandEnvelope, ctx: CapGdlrCommandHandlers.Context) 🔗
Runs envelope through the pipeline and returns the final result. Fails when no core is set.