-
Notifications
You must be signed in to change notification settings - Fork 284
Support class-based durable function invocations #3229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| --> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" OutputItemType="Analyzer" /> | ||
| <PackageReference Include="Microsoft.DurableTask.Generators" OutputItemType="Analyzer" /> | ||
| <!-- <PackageReference Include="Microsoft.DurableTask.Generators" OutputItemType="Analyzer" /> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source generator will need follow up work after this before it can be included back. Primarily, it will need work to remove generating the class-based shims:
Basically, all this /AzureFunctions folder can be removed: https://github.com/microsoft/durabletask-dotnet/tree/main/src/Generators/AzureFunctions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we tracking this work and when will it be done? The source generators have been available and included in samples for a very long time, and I'm concerned that we might be releasing an update that breaks these existing use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing tracking, will need it.
This class-based change is opt-in (classes need to be manually registered to DurableTaskRegistry), so it won't outright break customers that use the generators package without some action by them. But yes, it is incompatible with the generators package (it will cause duplicate functions).
I have a branch here: https://github.com/microsoft/durabletask-dotnet/tree/u/jviau/generator-refactor which overhauls the generator to address this. But it also drops some existing features, like the strongly-typed extension methods for running orchestrations & activities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but I consider the strongly typed extension methods (which also works for regular orchestrator and activity function definitions) to be more important than supporting class-based syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can definitely be added back into my branch. My personal opinion is that the sourge-gen approach for strongly typing is an implementation dead end, as it won't work on interface derived types. I recommend investing in mediator style APIs instead. Gives you type safety plus more, and no source gen reliance needed.
418acca to
4d6ad2a
Compare
src/Worker.Extensions.DurableTask/Execution/DurableWorkerBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
471c154 to
2eabfae
Compare
2eabfae to
6c70461
Compare
src/Worker.Extensions.DurableTask/Execution/DurableFunctionExecutor.Activity.cs
Outdated
Show resolved
Hide resolved
src/Worker.Extensions.DurableTask/Execution/DurableWorkerBuilderExtensions.cs
Show resolved
Hide resolved
src/Worker.Extensions.DurableTask/Execution/DurableFunctionExecutor.Activity.cs
Show resolved
Hide resolved
test/Worker.Extensions.DurableTask.Tests/DurableFunctionMetadataTests.cs
Outdated
Show resolved
Hide resolved
This change set adds support for: 1. Invoking class-based orchestration, entity, and activities directly. No source generator needed. 2. Moves handling invoking or func-based tasks out of the middleware and into a dedicated executor.
Signed-off-by: Hal Spang <[email protected]>
Signed-off-by: Hal Spang <[email protected]>
6c70461 to
e798793
Compare
src/Worker.Extensions.DurableTask/Execution/DurableFunctionExecutor.cs
Outdated
Show resolved
Hide resolved
Signed-off-by: Hal Spang <[email protected]>
src/Worker.Extensions.DurableTask/Execution/DurableTaskRegistryExtensions.cs
Show resolved
Hide resolved
| --> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" OutputItemType="Analyzer" /> | ||
| <PackageReference Include="Microsoft.DurableTask.Generators" OutputItemType="Analyzer" /> | ||
| <!-- <PackageReference Include="Microsoft.DurableTask.Generators" OutputItemType="Analyzer" /> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we tracking this work and when will it be done? The source generators have been available and included in samples for a very long time, and I'm concerned that we might be releasing an update that breaks these existing use cases.
This change set adds support for:
This PR really is two in one, may consider breaking into separate PRs.
Issue 1 - Solving Asynchronous Middleware Breaking Orchestrations
This PR solves orchestrations not support asynchronous middleware by moving the orchestration invocation handling to a custom
IFunctionExector, which will always be ran at the very end of the middleware pipeline. So any async middleware will not be captured as part of the orchestration invocation.NOTE: this PR moves activities and entities to be invoked the same way as well. This does have implications where some bindings are no longer prepared in the middleware. It might be a 'breaking' change for some customers if they tried to access that directly, but we could argue that behavior was never officially supported.
Issue 2 - Fully Support Class Based Tasks
Today class-based tasks are only supported via the source generator and require disabling the functions worker source generator. This is a poor experience for customers. Instead, this PR leverages a new extensibility point from functions allowing durable to supply function definitions directly. Now we can take existing durabletask-dotnet configuration and apply it to functions. No source generation needed - customers directly declare their class-based tasks during startup.
To further improve this experience, durable can adjust how to register implementations to the
DurableTaskRegistry. This could be a great use of source-gen. Durable generator (still in preview) can generate a method which registers all discovered types toDurableTaskRegistry. In function projects a startup hook could also be emitted to automatically register those toDurableTaskRegistry.TODO
Issue describing the changes in this PR
resolves #2720
resolve #2876
resolves microsoft/durabletask-dotnet#158
Pull request checklist
pending_docs.mdrelease_notes.md/src/Worker.Extensions.DurableTask/AssemblyInfo.csdevandmainbranches and will not be merged into thev2.xbranch.