Microsoft.Extensions.Hosting/DependencyInjection wrappers available
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 335
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 6
Description
I have created wrapper libraries for using DurableTask with the Microsoft.Extensions.Hosting & DependencyInjection pattern. This allows all orchestrations, task activities, and middleware to be DI'd. It also adds a builder pattern for configuring a task hub worker. This is all done without any modifications to the DurableTask.Core framework.
The preview packages are available on nuget:
https://www.nuget.org/packages/Vio.DurableTask.Hosting
https://www.nuget.org/packages/Vio.DurableTask.DependencyInjection
See the repo, including instructions and samples here: [jviau/durabletask-hosting](https://github.com/jviau/durabletask-hosting)
Quick sample:
``` CSharp
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.
```
Feel free to open issues on that repo for feature requests, or to discuss.
If plugs like this are not allowed or an issue is not the appropriate place to announce this, please close/remove this issue.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.