Skip to content

Workflow engine designed to create, manage, and execute complex workflows in a modular and extensible manner. It provides a fluent interface for defining workflows, allowing for clear and intuitive workflow definitions.

License

Notifications You must be signed in to change notification settings

override-dev/flexflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlexFlox Workflow Engine built with C#

Overview

This workflow engine is a powerful and flexible tool designed to create, manage, and execute complex workflows in a modular and extensible manner. It provides a fluent interface for defining workflows, allowing for clear and intuitive workflow definitions.

Key Features

1. Modular Workflow Construction

  • StartWith: Initiates the workflow with a specified step.
  • Then: Chains subsequent steps in the workflow.

2. Branching and Conditional Logic

  • Branch: Allows the workflow to diverge based on conditions, with separate paths for true and false outcomes.
  • If: Provides a simplified conditional branching for scenarios with only a 'true' branch.

3. Error Handling and Resilience

  • Catch: Captures and handles specific exceptions, allowing for graceful error management.
  • Retry: Automatically retries failed steps a specified number of times with a configurable delay between attempts.

4. Iterative Processing

  • While: Enables repetitive execution of a set of steps while a condition is met.

5. Data Transformation

  • Map: Allows for transformation of the workflow's output data.

6. Logging and Monitoring

  • WithLogging: Integrates logging capabilities into the workflow for better visibility and debugging.

7. Composability

  • SubWorkflow: Supports nesting of workflows, allowing for complex workflow compositions.

8. Asynchronous Execution

  • All steps in the workflow support asynchronous operations, leveraging Task<Result<T>> for results.

9. Dependency Injection Support

  • IWorkflowStep Interface: Supports creation of individual workflow steps as separate classes, enabling dependency injection and promoting better separation of concerns.

Usage Example

public class SampleWorkflow : IWorkflow<Input, Output>
{
    private readonly IStepOne _stepOne;
    private readonly IStepTwo _stepTwo;

    public SampleWorkflow(IStepOne stepOne, IStepTwo stepTwo)
    {
        _stepOne = stepOne;
        _stepTwo = stepTwo;
    }

    public void Build(IWorkflowBuilder<Input, Output> builder)
    {
        builder
            .StartWith(_stepOne.Execute)
            .Then(_stepTwo.Execute)
            .Branch(
                condition: CheckCondition,
                trueBranch: branch => branch.Then(TrueBranchStep),
                falseBranch: branch => branch.Then(FalseBranchStep)
            )
            .Catch<CustomException>(HandleException)
            .Retry(3, TimeSpan.FromSeconds(1))
            .While(ShouldContinue, loopBuilder => loopBuilder.Then(LoopStep))
            .Map(TransformResult)
            .WithLogging(logger);
    }
    
    // Other step implementations...
}

public interface IStepOne : IWorkflowStep<Input, IntermediateResult> { }
public interface IStepTwo : IWorkflowStep<IntermediateResult, Output> { }

public class StepOne : IStepOne
{
    public Task<Result<IntermediateResult>> Execute(Input input)
    {
        // Step implementation
    }
}

public class StepTwo : IStepTwo
{
    public Task<Result<Output>> Execute(IntermediateResult input)
    {
        // Step implementation
    }
}

Functional Approach

This workflow engine adopts a functional programming approach, which offers several benefits:

  1. Immutability: Each step in the workflow is designed to be a pure function, taking an input and producing an output without side effects. This makes the workflow more predictable and easier to reason about.

  2. Composability: The functional approach allows for easy composition of workflow steps. Complex workflows can be built by combining simpler, reusable steps.

  3. Testability: Pure functions are easier to test as they always produce the same output for a given input, regardless of external state.

  4. Parallelism: The absence of shared mutable state makes it easier to parallelize parts of the workflow when appropriate.

  5. Error Handling: The use of Result<T> as a return type for each step provides a clean way to handle and propagate errors throughout the workflow.

Use Cases

This workflow engine is versatile and can be applied to a wide range of scenarios. Here are some potential use cases:

  1. Order Processing Systems:

    • Handle complex order fulfillment processes including inventory checks, payment processing, and shipping.
    • Use branching to manage different types of orders or shipping methods.
    • Implement retry logic for external service calls (e.g., payment gateways).
  2. Document Approval Workflows:

    • Model multi-step approval processes with conditional branches based on document type or approval level.
    • Use the While feature to implement revision cycles.
    • Leverage sub-workflows for department-specific approval steps.
  3. Data ETL (Extract, Transform, Load) Processes:

    • Create workflows for data extraction from various sources, transformation, and loading into target systems.
    • Use the Map feature for data transformation steps.
    • Implement error handling and retries for network-related operations.
  4. Customer Onboarding:

    • Model the customer registration process, including form validation, credit checks, and account setup.
    • Use branching to handle different customer types or service levels.
    • Implement KYC (Know Your Customer) processes as sub-workflows.
  5. IoT Device Management:

    • Create workflows for device provisioning, firmware updates, and telemetry processing.
    • Use retry logic to handle intermittent connectivity issues.
    • Implement branching for different device types or firmware versions.
  6. Financial Trading Systems:

    • Model complex trading strategies as workflows.
    • Use branching for different market conditions.
    • Implement risk checks and approvals as separate workflow steps.
  7. Content Publishing Pipelines:

    • Create workflows for content creation, review, approval, and publishing processes.
    • Use the While feature for revision cycles.
    • Implement different sub-workflows for various content types (articles, videos, podcasts).
  8. HR Processes:

    • Model employee onboarding, performance review, or offboarding processes.
    • Use branching for different departments or employee levels.
    • Implement document generation steps using the Map feature.

These use cases demonstrate the flexibility and power of the workflow engine. Its functional approach and rich feature set make it adaptable to a wide range of business processes across various industries.

About

Workflow engine designed to create, manage, and execute complex workflows in a modular and extensible manner. It provides a fluent interface for defining workflows, allowing for clear and intuitive workflow definitions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages