Hyperbee.Pipeline 1.2.0

dotnet add package Hyperbee.Pipeline --version 1.2.0                
NuGet\Install-Package Hyperbee.Pipeline -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hyperbee.Pipeline" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hyperbee.Pipeline --version 1.2.0                
#r "nuget: Hyperbee.Pipeline, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hyperbee.Pipeline as a Cake Addin
#addin nuget:?package=Hyperbee.Pipeline&version=1.2.0

// Install Hyperbee.Pipeline as a Cake Tool
#tool nuget:?package=Hyperbee.Pipeline&version=1.2.0                

Hyperbee Pipeline

Hyperbee.Pipeline allows you to construct asynchronous fluent pipelines in .NET. A pipeline, in this context, refers to a sequence of data processing elements arranged in series, where the output of one element serves as the input for the subsequent element.

Hyperbee pipelines are composable, reusable, and easy to test. They are designed to be used in a variety of scenarios, such as data processing, message handling, and workflow automation.

Some key features are:

  • Middleware
  • Hooks
  • Wraps
  • Conditional flows
  • Loops
  • Parallel processing
  • Dependency injection
  • Early returns and cancellation
  • Child pipelines

Why Use Pipelines

Pipelines provide a structured approach to managing complex processes, promoting SOLID principles, including Inversion of Control (IoC) and Separation of Concerns (SoC). They enable composability, making it easier to build, test, and maintain your code. By extending the benefits of middleware and request-response pipelines throughout your application, you achieve greater modularity, scalability, and flexibility. This is especially critical in domains such as healthcare, compliance auditing, identity and roles, and high-security environments where clear boundaries and responsibilities are essential. Hyperbee.Pipeline ensures that the advantages of pipelines and middleware are not abandoned at the controller implementation, addressing a common gap in many frameworks. By using a functional approach, Hyperbee.Pipeline ensures that your pipelines are not only robust and maintainable but also highly adaptable to changing requirements.

Getting Started

To get started with Hyperbee.Json, refer to the documentation for detailed instructions and examples.

Install via NuGet:

dotnet add package Hyperbee.Pipeline

Building and Executing Pipelines

Pipelines are built using PipelineFactory. Once built, a pipeline is just an async function that takes a PipelineContext and an optional input value as parameters, and returns a result.

    var command = PipelineFactory
        .Start<string>()
        .Pipe( ( ctx, arg ) => $"hello {arg}" )
        .Build();

    var result = await command( new PipelineContext(), "pipeline" );

    Assert.AreEqual( "hello pipeline", result );

Dependency Injection

Sometimes Pipelines and Pipeline middleware need access to specific container services. This can be accomplished by registering services with the PipelineContextFactory. This can be done through DI configuration, or manually through the PipelineContextFactoryProvider if you are not using DI.

Pipelines manage dependencies with a specialized container. This allows the implementor to control the services that are exposed through the pipeline. If you want to expose all application services then you can call AddPipeline and pass includeAllServices: true.

Register pipelines with DI and provide Pipeline dependencies using the application container.

services.AddPipeline( includeAllServices: true );

Register Pipelines with DI and provide Pipeline dependencies using a specialized container.

services.AddPipeline( (factoryServices, rootProvider) =>
{
    factoryServices.AddTransient<IThing>()
    factoryServices.ProxyService<IPrincipalProvider>( rootProvider ); // pull from root container
} );

Pipeline of Pipelines

The PipelineFactory library allows you to use pipelines together. Since pipelines are just functions, they can be used as input to other pipelines. This allows you to create complex data processing flows by reusing and chaining together multiple pipelines.

Here's an example of how to use pipelines together:

var pipeline2 = PipelineFactory
    .Start<string>()
    .Pipe( ( ctx, arg ) => $"{arg} again!" )
    .Build();

var pipeline1 = PipelineFactory
    .Start<string>()
    .Pipe( ( ctx, arg ) => $"hello {arg}" )
    .PipeAsync( pipeline2 )
    .Build();

var result = await pipeline1( new PipelineContext(), "you" );

Assert.AreEqual( "hello you again!", result );

Conditional Flow and Advanced Features

The PipelineFactory library provides a variety of builders that allow you to customize the behavior of your pipelines. These methods provide powerful functionality for manipulating data as it passes through the pipeline.

  • Functions
  • Procedures
  • Conditional Flow
  • Iterators
  • Reduce
  • Parallel execution

Credits

Hyperbee.Pipeline is built upon the great work of several open-source projects. Special thanks to:

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Hyperbee.Pipeline:

Package Downloads
Hyperbee.Pipeline.Caching

Caching for Hyperbee.Pipelines async pipelines

Hyperbee.Pipeline.Auth

Auth for Hyperbee.Pipelines async pipelines

GitHub repositories

This package is not used by any popular GitHub repositories.