Skip to content

Simple fully async workflow engine using .NETSTANDARD.

License

Notifications You must be signed in to change notification settings

alefgroup/AleFIT.Workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AleFIT Workflow

AleFIT Workflow is a simple yet effective solution for execution code blocks in certain flow. Library supports multiple blocks as described below, it follows fluent API principles and contains comprehensive test suite.

Features

  • Full async support
  • Immutable API making it thread-safe
  • Fluent API design
  • No dependencies other than .NETSTARDARD 1.2
  • Dependency injection friendly (could be improved)
  • Type-safety using generics
  • Documented code (could be improved)

Requirements

  • .NETSTARDARD 1.2
  • .NETCORE Runtime (just to run unit tests)

ToDo

  • Ability to serialize the workflow to make it persistable
  • Integration with some DI containers
  • Better code documentation and examples
  • Any ideas?

Examples

Simple workflow is starting by conditional node checking whether registration email is unique. If it is, it inserts user in database and sends him some email about the result. If the email is not unique, it just logs somewhere what happened.

var workflow = WorkflowBuilder<RegistrationContext>.Create()
    .If(new CheckUserEmail())
        .Then(WorkflowBuilder<RegistrationContext>.Create()
            .Do(new InsertUserInDatabase())
            .Do(new NotifyCompleteRegistartion())
            .Build())
    .Else(new LogIncorrectRegistration())
.Build();

var context = await workflow.ExecuteAsync(new RegistrationContext("test@email.com"));

Same workflow using lambda syntax. These two syntaxes can be mixed together without any limitations.

var workflow = WorkflowBuilder<RegistrationContext>.Create()
    .If(async context => await someService.IsEmailUnique(context.Email))
    .Then(WorkflowBuilder<RegistrationContext>.Create()
        .Do(async context => await repository.InsertAsync(context.UserData))
        .Do(async context => await notificationService.SendAsync(context.UserData))
        .Build())
    .Else(context =>
    {
        logger.Info($"Email {context.Email} is already registered.");
        return Task.CompletedTask;
    })
.Build();

var context = await workflow.ExecuteAsync(new RegistrationContext("test@email.com"));

For more examples check out unit tests

About

Simple fully async workflow engine using .NETSTANDARD.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages