-
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
intercept Orchestrator before/after setting the runtimeStatus #1244
Comments
You actually can already do this. These failed activities will throw a |
The retry logic is implemented by Durable Functions. I would like a point to intercept before / after it set this state. In summary, some extensibility to enable AOP |
I'm not quite sure what you mean. Let's say you have the following orchestration: public static async Task<string> CatchException([OrchestrationTrigger] IDurableOrchestrationContext context)
{
try
{
return await context.CallActivityWithRetryAsync<string>("PrimaryAction", new RetryOptions(TimeSpan.FromSeconds(3), 3), input);
} catch (FunctionFailedException)
{
return await context.CallActivityAsync<string>("BackupAction", input);
}
} Now let's say that |
You got the idea. But I would like something like this:
|
I'm not quite sure what utility that adds that catching the exception manually does not add, but I will leave it open for dicussion. |
the benefit is quite simple. I can have one single orchestrator or multiple sub orchestrators. I want to setup a single entry point to capture failures, but this could be used for other purposes too. For example, in the past there was the Invocation Filters that was removed, but allow Cross Cutting Concerns. I would like the same ability, but in the orchestrator. |
I think the "before failure" part is easy to implement in user-land code. You can provide an extension method to IDurableOrchestrationContext that accepts an additional delegate parameter "OnFailure" and wrap it around a try/catch block as Connor suggested.
I think the "after failure" part is harder. But from your example, "just before failure" might be enough. |
Agreed, in fact it should be: Before / After -> activity |
Oh, I see now. I think using the extension methods are viable for both before and after for activity functions (using 3 extra params, "before", "after", "onError"). The "before Orchestrator starts" is also viable (adding the extension method on IDurableOrchestrationClient interface, i.e, extending StartNewAsync). The hard part is the "after orchestration is completed/failed". I suggest you to check WaitForCompletionOrCreateCheckStatusResponseAsync method. It uses some sort of pooling to keep checking the status on the orchestration. Not ideal given the amount of resource usage you would have. Other option is to add extra activities to all your orchestrations. Altough not very "cross-cutting", these activities would be pretty generic and reusable. |
as I said, I can implement everything by myself...but I think they would be a nice feature at the framework level |
When working with several sub activities on an orchestrator. If some activity exceeds the number of retries, it will set the orchestrator status as "runtimeStatus:Failed". I would like the ability to intercept this moment and perform some action.
The text was updated successfully, but these errors were encountered: