Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jviau/durabletask-hosting
A Microsoft.Extensions.Hosting wrapper around the Microsoft.Azure.DurableTask framework.
https://github.com/jviau/durabletask-hosting
azure dependency-injection durabletask hosting orchestrations
Last synced: 3 months ago
JSON representation
A Microsoft.Extensions.Hosting wrapper around the Microsoft.Azure.DurableTask framework.
- Host: GitHub
- URL: https://github.com/jviau/durabletask-hosting
- Owner: jviau
- License: apache-2.0
- Created: 2020-04-13T18:27:47.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T19:54:05.000Z (10 months ago)
- Last Synced: 2024-04-27T05:04:00.190Z (9 months ago)
- Topics: azure, dependency-injection, durabletask, hosting, orchestrations
- Language: C#
- Homepage:
- Size: 615 KB
- Stars: 27
- Watchers: 4
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DurableTask-Hosting
[![Build](https://github.com/jviau/durabletask-hosting/workflows/.NET%20Core/badge.svg)](https://github.com/jviau/durabletask-hosting/actions?query=workflow%3A%22.NET+Core%22)
Hosting:
[![Nuget Preview](https://img.shields.io/nuget/vpre/Vio.DurableTask.Hosting.svg)](https://www.nuget.org/packages/Vio.DurableTask.Hosting)Dependency Injection:
[![Nuget Preview](https://img.shields.io/nuget/vpre/Vio.DurableTask.DependencyInjection.svg)](https://www.nuget.org/packages/Vio.DurableTask.DependencyInjection)A [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) wrapper around the [azure/durabletask](https://github.com/azure/durabletask) framework.
## Getting Started
See [Samples](./samples/DurableTask.Samples) for a quick start example.
1. Add nuget package: `dotnet add package Vio.DurableTask.Hosting`
2. Add to your host builder:``` CSharp
await Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
// Can configure orchestrations, activities, and middleware in the service
// container with any scope desired.
services.AddSingleton();
services.AddScoped(); // 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();// will be fetched from service provider.
builder.AddOrchestration();// will be fetched from service provider.
builder.UseOrchestrationMiddleware();// same as orchestration: can be part of the services or not.
builder.AddActivity();
})
.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`.