Skip to content

About

.NET CORE 3.1 library that defines HTTP workflow steps for the WorkflowCore workflow engine

Topics

Resources

Contributing

Stars

1 star

Watchers

2 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorkflowCore.Http

.NET CORE 3.1 library that defines HTTP workflow steps for the WorkflowCore workflow engine

Usage

Nuget Package

  dotnet add package WorkflowCore.Http

Sample code

Configuration

public class Startup
{

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddHttpClient();
        services.AddWorkflow();
        services.AddHttpWorkflow();
        services.AddControllers();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IWorkflowHost workflowHost)
    {
        if (env.IsDevelopment())
            app.UseDeveloperExceptionPage();
        app.UseRouting();
        app.UseHttpWorkflow();
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
        workflowHost.Start();
    }

}

Workflow usage

builder.StartWith(context =>
{
    Console.WriteLine("Begining saga");
})
    .Saga(saga =>
    {
        saga
            .StartWith(context => Console.WriteLine("Saga started"))
            .Then<SendHttpRequest>(setup =>
            {
                setup.Input(step => step.Method, data => HttpMethod.Post);
                setup.Input(step => step.Uri, data => "http://localhost/workflow/execute");
                setup.Input(step => step.RetryPolicy, data => Policy
                    .Handle<HttpRequestException>(ex => ex.Message.Contains("400"))
                    .RetryAsync(4, (ex, attempts) => Console.WriteLine($"Attempt n°{attempts}")));
                setup.Input(step => step.Content, data => new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, MediaTypeNames.Application.Json));
            })
                .CompensateWith<SendHttpRequest>(setup =>
                    {
                        setup.Input(step => step.Method, data => HttpMethod.Get);
                        setup.Input(step => step.Uri, data => "http://localhost:56832/workflow/compensate");
                    })
            .Then<ReceiveHttpRequest>(setup =>
            {
                setup.Input(step => step.Method, data => HttpMethod.Get);
                setup.Input(step => step.Path, data => "/test/go");
            })
            .Then(context => Console.WriteLine("Saga ended"));
    });

Contributing

Please see CONTRIBUTING.md for instructions on how to contribute.

About

.NET CORE 3.1 library that defines HTTP workflow steps for the WorkflowCore workflow engine

Topics

Resources

Contributing

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages