Class PipelineBuilder
- Namespace
- Excalibur.Dispatch.Configuration
- Assembly
- Excalibur.Dispatch.dll
Fluent builder for configuring message processing pipelines.
public sealed class PipelineBuilder : IPipelineBuilder
- Inheritance
-
PipelineBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
PipelineBuilder(string, IServiceProvider, IMiddlewareApplicabilityStrategy?)
Initializes a new instance of the PipelineBuilder class. Creates a new pipeline builder.
public PipelineBuilder(string name, IServiceProvider serviceProvider, IMiddlewareApplicabilityStrategy? applicabilityStrategy = null)
Parameters
namestringserviceProviderIServiceProviderapplicabilityStrategyIMiddlewareApplicabilityStrategy
Properties
Name
Gets the name of this pipeline builder.
public string Name { get; }
Property Value
- string
The name assigned to the pipeline builder.
Methods
Build()
Builds the configured pipeline.
public IDispatchPipeline Build()
Returns
- IDispatchPipeline
The built dispatch pipeline.
Remarks
Composition happens inside a dependency-injection scope. Every middleware this framework seats is
registered Scoped, and the provider a pipeline is composed from is
the root -- a singleton factory is handed the root by definition. Resolving a scoped service there
is refused outright under ValidateScopes and succeeds silently
without it, which is the worse half: one middleware graph, and everything it was constructed with,
shared by every dispatch for the life of the process.
Probe dependencies must support synchronous disposal. For async-only disposable dependencies,
register through UseDeferred with explicit stage and message-kind metadata instead.
Clear()
Clears all configured middleware from the pipeline.
public IPipelineBuilder Clear()
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
ForMessageKinds(MessageKinds)
Configures which message kinds this pipeline should process.
public IPipelineBuilder ForMessageKinds(MessageKinds messageKinds)
Parameters
messageKindsMessageKindsThe message kinds to process.
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
Use(Func<IServiceProvider, IDispatchMiddleware>)
Adds middleware using a factory function to the pipeline.
public IPipelineBuilder Use(Func<IServiceProvider, IDispatchMiddleware> middlewareFactory)
Parameters
middlewareFactoryFunc<IServiceProvider, IDispatchMiddleware>The middleware factory function.
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
UseAt<TMiddleware>(DispatchMiddlewareStage)
Adds middleware of the specified type at a specific stage in the pipeline.
public IPipelineBuilder UseAt<TMiddleware>(DispatchMiddlewareStage stage) where TMiddleware : IDispatchMiddleware
Parameters
stageDispatchMiddlewareStageThe stage where the middleware should be inserted.
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
Type Parameters
TMiddlewareThe middleware type. Its public constructors are preserved under trimming so the pipeline can activate it and inspect its dependencies.
UseProfile(IPipelineProfile)
Uses a pipeline profile with predefined middleware configuration.
public IPipelineBuilder UseProfile(IPipelineProfile profile)
Parameters
profileIPipelineProfileThe profile to use.
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
UseProfile(string)
Uses a named pipeline profile with predefined middleware configuration.
public IPipelineBuilder UseProfile(string profileName)
Parameters
profileNamestringThe name of the profile to use.
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
UseWhen<TMiddleware>(Func<IServiceProvider, bool>)
Conditionally adds middleware of the specified type to the pipeline.
public IPipelineBuilder UseWhen<TMiddleware>(Func<IServiceProvider, bool> condition) where TMiddleware : IDispatchMiddleware
Parameters
conditionFunc<IServiceProvider, bool>The condition function that determines if middleware should be added.
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
Type Parameters
TMiddlewareThe middleware type. Its public constructors are preserved under trimming so the pipeline can activate it and inspect its dependencies.
Use<TMiddleware>()
Adds middleware of the specified type to the pipeline.
public IPipelineBuilder Use<TMiddleware>() where TMiddleware : IDispatchMiddleware
Returns
- IPipelineBuilder
The pipeline builder for method chaining.
Type Parameters
TMiddlewareThe middleware type. Its public constructors are preserved under trimming so the pipeline can activate it and inspect its dependencies.