Skip to content

A simple, fast and generic implementation of the pipeline design pattern.

License

Notifications You must be signed in to change notification settings

lawrence-laz/generic-pipeline

Repository files navigation

NuGet Version NuGet Downloads Build Codacy Badge Codacy Badge

GenericPipeline

A general purpose dependency free pipeline builder. https://en.wikipedia.org/wiki/Pipeline_(software)

🌟 Features

  • Simplicity: Designed with simplicity in mind, the library offers a straightforward and easy-to-use pipeline implementation.
  • High Performance: The library boasts exceptional performance, as demonstrated by its benchmark results.
  • No Dispatch-Time Allocations: With the exception of async Task, the library makes no dispatch-time allocations, thus providing a highly efficient pipeline implementation.
  • No Dependencies: The library has zero external dependencies, making it lightweight and easy to integrate with other projects.

📦️ Get started

Download from nuget.org:

dotnet add package GenericPipeline

⚖️ Feature parity

GenericPipeline MediatR MessagePipe PipelineNet Mediator
Usable without dependency injection ✔️ ✔️
Usable with dependency injection ✔️ ✔️ ✔️ ✔️¹ ✔️
.NET framework support ✔️ ✔️ ✔️ ✔️
Allocation-free dispatching ✔️ ✔️ ✔️
Generic request handling ✔️ ✔️ ✔️ ✔️
Async and sync handlers/behaviors ✔️ ✔️ ✔️
Change handlers at runtime ✔️ ✔️²
Behaviors ✔️ ✔️ ✔️ ✔️ ✔️
Streams ✔️ ✔️
Notifications ✔️ ✔️ ✔️

¹ - Unity container only, ² - add only, cannot remove

⚡️ Benchmarks

Overhead per invocation for each library. Scenario contains a call to a behavior and a handler.

Sync:

Method Mean Allocated
Simple method call 5.7 ns -
GenericPipeline 31.2 ns -
MediatR 502.8 ns 600 B
PipelineNet 95.4 ns 152 B

Awaited async:

Method Mean Allocated
Simple method call 4 863 ns 560 B
GenericPipeline 5 906 ns 864 B
MediatR 6 662 ns 1160 B
PipelineNet 7 017 ns 1184 B
Pipe icons created by Smashicons - Flaticon