-
Notifications
You must be signed in to change notification settings - Fork 273
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
Add WaitForCompletionOrCreateCheckStatusResponseAsync to Microsoft.Azure.Functions.Worker.DurableTaskClientExtensions #2875
Conversation
@microsoft-github-policy-service agree company="pitt&sherry" |
Catch-up merge
This would be very handy to have merged and released |
@dixonte One thing though, in InProc we used to deal with HttpResponseMessage as return type, I see you went for HttpResponseData. Any particular reason for that? |
@MarioMajcicaAtABNAMRO That's what the main library was using for isolated worker. |
For the InProcess mode, lib is using the objects from ASP.NET Core integration. Which by the way are supported also in the isolated mode. https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=windows#http-trigger HTTP triggers allow a function to be invoked by an HTTP request. There are two different approaches that can be used: An ASP.NET Core integration model that uses concepts familiar to ASP.NET Core developers Seems that ASP.NET Core integration model is the way to go forward if no compatibility issues are present. Should there be 2 versions of this extension, to deal with both? |
@MarioMajcicaAtABNAMRO To me it makes sense to use HttpResponseData as that is part of the Microsoft.Azure.Functions.Worker.Http namespace, which you are most likely going to be using if you're using DurableTaskClientExtensions from the Microsoft.Azure.Functions.Worker namespace. Though admittedly I just followed suit with the class as it existed before my changes; there are other functions returning HttpResponseData in this class prior to my changes. |
The fact is that the built in model seems there for legacy reasons: |
I'm okay with depending on |
Hey @dixonte thanks for your contributions and for opening this PR! To help get this merged, would you mind if I make some direct changes here? I’d like to add unit tests and merge the latest updates from our repo. Unfortunately, since this is a forked repo, I don’t have access to create a new branch, so making updates here would be the most efficient way. Thanks again for your understanding! |
@nytian Absolutely, please do. All I want is for these changes to make it to an official build, so go for it. |
@dixonte, I removed this section of code from this commit because it wasn’t functioning as expected. I’m not an expert on HTTP forwarding, so perhaps @jviau , who left the comments, might have additional context on this. Anyways thanks again for this contribution. I think opening another PR might be better, as this change is somewhat separate from adding the WaitForCompletionOrCreateCheckStatusResponseAsync API, and separating it could also make the PR merge faster. If you're interested, we could address it there :) |
src/Worker.Extensions.DurableTask/DurableTaskClientExtensions.cs
Outdated
Show resolved
Hide resolved
I think I had some issues getting the returned URIs to work when deployed to a linux host in Azure without those changes, that's why I bundled them in this PR. E.g. the status URI would have http://localhost:XXXXX at the start instead of the expected https://YYYYY.azurewebsites.net, somewhat defeating the entire purpose. What do you mean, it wasn't functioning as expected, @nytian? |
@dixonte thanks for the follow up. I tested this locally and noticed that no |
@nytian Nothing else comes to mind right now. If I get a moment I'll check my own solution locally. Hard to imagine why baseUrl would be blank without stepping through the code. |
Regarding the base URI calculation / rewrites. I don't think it is a good idea for this code base to incorporate any of that calculation. There is too much nuance, edge cases, different ways to do it that it is not worth having durable team try and maintain it. Instead, what I recommend is:
Overall though I am not a fan of this API. It does not follow the Long-running-operation polling pattern. The end caller should be calling a get-status API to monitor if it is done, and then when it is that API should return either the location, they can get the final result from, or the final result itself. It is not recommended to have an HTTP endpoint which waits for some duration for completion and then gives up, returning the status at that time. I don't recommend this become part of the API. I understand it was part of in-proc, but this is a good time to drop the API by keeping it from being included in out-of-proc. If you want to implement something yourself, you could add this helper to your project: public static async Task<OrchestrationMetadata> WaitOrGetStatusAsync(this DurableTaskClient client, string instanceId, TimeSpan timeout)
{
using CancellationTokenSource cts = new(timeout);
try
{
return await client.WaitForInstanceCompletionAsync(instanceId, cts.Token);
}
catch (OperationCanceledException)
{
return (await client.GetInstanceAsync(instanceId))!;
}
}
// check if `OrchestrationMetadata` is terminal. If it is return its payload. If not, call `CreateCheckStatusResponseAsync` |
I'm fine with keeping the forwarding support for methods that use
While I understand the sentiment, I disagree with excluding it from out-of-proc. I think it's more important that we remove obstacles preventing developers from migrating from in-proc to out-of-proc than having a perfect API surface area. I think this is a design wart we'll just have to continue living with. I'm willing to reconsider this in the case of AspNetCore integration, however (which is something our APIs don't have any support for currently, IIRC). |
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.
I'm good with these changes if we can add tests for the forwarding headers.
src/Worker.Extensions.DurableTask/DurableTaskClientExtensions.cs
Outdated
Show resolved
Hide resolved
src/Worker.Extensions.DurableTask/DurableTaskClientExtensions.cs
Outdated
Show resolved
Hide resolved
src/Worker.Extensions.DurableTask/DurableTaskClientExtensions.cs
Outdated
Show resolved
Hide resolved
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.
LGTM!
My azure functions rely upon WaitForCompletionOrCreateCheckStatusResponseAsync from the in-proc model, but this feature was missing from the isolated model. I have done my best to create an implementation that not only fulfills my needs but could be used by others. Documentation is the same as the in-proc model.
Pull request checklist
pending_docs.md
release_notes.md
/src/Worker.Extensions.DurableTask/AssemblyInfo.cs