Skip to content

GHM.Pipeline is a nuget package with the aim of pipeline management in parts. One pipeline has many stages. One stage has many steps.

License

Notifications You must be signed in to change notification settings

GustavoM96/GHM.Pipeline

Repository files navigation

logo

GHM.Pipeline

Build & Test

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 has 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>
{
    public RequestedStage(EcommerceData data)
        : base(data) { }
}

public class ValidationStage : Stage<EcommerceData>
{
    public RequestedStage(EcommerceData data)
        : base(data) { }
}

public class EcommerceData { }

In services code

using GHM.Pipeline;

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

        RequestedStage stage = EcommercePipeline.CreateRequestedStage(data);
        try
        {
            stage.AddInformation("processing request stage") // this step is only a information

            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
        }
    }
}

Classes

Stage

Stage has:

  • Many steps
  • Data to execute the stage process
  • Status more critical in step list

Step

Step has many Status. The following list is ordered by more critical desc:

  • Canceled
  • Error
  • InProgress
  • InAdjustment
  • Success
  • Information
  • Default
Step step = Step.Success("success test","Step Name")

step.Status // Success
step.IsSuccess // true
step.IsError // false
step.IsCanceled // false

Star

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

About

GHM.Pipeline is a nuget package with the aim of pipeline management in parts. One pipeline has many stages. One stage has many steps.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages