Skip to content

A Microsoft.Extensions.Hosting wrapper around the Microsoft.Azure.DurableTask framework.

License

Notifications You must be signed in to change notification settings

jviau/durabletask-hosting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

344cb54 · Jul 12, 2022
Apr 22, 2022
Apr 22, 2022
Apr 23, 2022
Apr 22, 2022
Apr 29, 2022
Apr 22, 2022
Apr 13, 2020
Apr 16, 2020
Apr 16, 2020
Apr 22, 2022
Apr 13, 2020
Apr 23, 2022
Apr 17, 2020
Apr 22, 2022
Apr 22, 2022
Jul 12, 2022
Apr 13, 2020
Apr 23, 2021

Repository files navigation

DurableTask-Hosting

Build

Hosting: Nuget Preview

Dependency Injection: Nuget Preview

A Microsoft.Extensions.Hosting wrapper around the azure/durabletask framework.

Getting Started

See Samples for a quick start example.

  1. Add nuget package: dotnet add package Vio.DurableTask.Hosting
  2. Add to your host builder:
Host.CreateDefaultBuilder()
    .ConfigureServices(services =>
    {
        // Can configure orchestrations, activities, and middleware in the service
        // container with any scope desired.
        services.AddSingleton<MySingletonOrchestration>();
        services.AddScoped<MyScopedMiddleware>(); // must implement "ITaskMiddleware"
    })
    .ConfigureTaskHubWorker((context, builder) =>
    {
        // add orchestration service
        builder.WithOrchestrationService(new LocalOrchestrationService());

        // add orchestration directly _not_ in service container. Will be treated as transient.
        builder.AddOrchestration<MyTransientOrchestration>();

        // will be fetched from service provider.
        builder.AddOrchestration<MySingletonOrchestration>();

        // will be fetched from service provider.
        builder.UseOrchestrationMiddleware<MyScopedMiddleware>();

        // same as orchestration: can be part of the services or not.
        builder.AddActivity<MyTransientActivity>();
    })
    .RunConsoleAsync(); // starts the worker.

All orchestrations, activities, and middleware will now be constructed via dependency injection.

Service Scope

A new IServiceScope is created for the duration of every OrchestrationInstance run. This scope will be used for all actions, middleware, and the orchestration itself and disposed after both the middleware & orchestration pipeline has finished execution. Scopes are not preserved between runs of the same OrchestrationInstance.