GHM.Pipeline 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package GHM.Pipeline --version 2.0.1
NuGet\Install-Package GHM.Pipeline -Version 2.0.1
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="GHM.Pipeline" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GHM.Pipeline --version 2.0.1
#r "nuget: GHM.Pipeline, 2.0.1"
#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 GHM.Pipeline as a Cake Addin
#addin nuget:?package=GHM.Pipeline&version=2.0.1

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

<p align="center"> <img src="logo.png" alt="logo" width="200px"/> </p>

<h1 align="center"> GHM.HTTPResult </h1>

GHM.Pipeline is a nuget package aims to manage pipelines in parts, where a pipeline has many stages and a stage has many steps.

Install Package

.NET CLI

dotnet add package GHM.Pipeline

Package Manager

NuGet\Install-Package GHM.Pipeline

Example

As an example, we will use an e-commerce pipeline in which the order is requested, validated, processed, shipped, and finalized. Within each stage, there are one or more steps.

Stages:

  • Requested (STAGE)
    • requested by customer (STEP)
    • to insert in DataBase (STEP)
  • Validation (STAGE)
    • customer has all data has been successfully validated (STEP)
    • seller as all data has been successfully validated (STEP)
  • Processing (STAGE)
    • to Process credit card (STEP)
  • Sending (STAGE)
    • to send the product (STEP)
  • Finish (STAGE)
    • confirmation of product to customer's localization (STEP)
using GHM.Pipeline;

public static class EcommercePipeline{

    public RequestedStage CreateRequestStage(EcommerceData data) => new(data);
    public ValidationStage CreateValidationStage(EcommerceData data) => new(data)
}

public class RequestedStage : Stage<EcommerceData, EcommerceStageEnum>
{
    public RequestedStage(EcommerceData data)
        : base(data, EcommerceStageEnum.Requested) { }
}

public class ValidationStage : Stage<EcommerceData, EcommerceStageEnum>
{
    public RequestedStage(EcommerceData data)
        : base(data, EcommerceStageEnum.Validation) { }
}

public class EcommerceData { }

public enum EcommerceStageEnum
{
    Requested,
    Validation,
    Processing,
    Sending,
    Finish
}

In services code

using GHM.Pipeline;

public class EcommerceService
{
    public void Request(EcommerceData data)
    {

        RequestedStage stage = EcommercePipeline.CreateRequestedStage(data);
        try
        {
            if(data is null)
            {
                stage.AddCanceled("has no data to request") // this step canceled the stage
            }

            stage.AddSuccess("add data") // // this step validated the stage
        }
        catch (Exception ex)
        {
            stage.AddError("internal error: " + ex.Message) // // this step create a error to the stage
        }Default

        return
    }
}

Classes

Step

Step has many Status:

  • Success
  • Error
  • Canceled
  • InProgress
  • InAdjustment
  • Default
var step = Step.Success("success test","Step Name")
step.Status // Success
step.IsSuccess // true

Stage

Stage has:

  • Many steps
  • Name as Enum
  • Data to execute the stage process
  • Status more critical in step list
using GHM.Pipeline;

public class FirstStageExemple : Stage<DataExemple, StageNameExemple>
{
    public FirstStageExemple(DataExemple dataExemple)
        : base(dataExemple, StageNameExemple.FirstStage) { }
}

public class DataExemple { }

public enum StageNameExemple
{
    FirstStage,
    SecongStage,
    ThirdSatge
}
using GHM.Pipeline;

public class StageService
{
    public CreateStage()
    {
        var data = new DataExemple();
        FirstStageExemple stage = new FirstStageExemple(data);
    }
}

Star

if you enjoy, don't forget the ⭐ and install the package 😊.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.2 86 6/2/2024
2.0.1 143 1/12/2024
1.0.2 164 12/6/2023
1.0.1 116 11/22/2023
1.0.0 90 11/16/2023