Azure-webjobs-sdk: Safely short circuit function invocation from invocation filter

Created on 22 Aug 2017  路  6Comments  路  Source: Azure/azure-webjobs-sdk

I'm trying to create a IFunctionInvocationFilter but I want to be able to safely short circuit the invocation of the function from a filter and pass back a return value.

It's currently possible to short circuit it by throwing an exception within the OnExecutingAsync method of the filter but sequential filters wont be called and the exception is bubbled up.

It would be useful if within the Invocation filters to be able to set a property that allows skipping of the function execution (similar to the MVC framework)

I could throw something together and submit a PR of an example of what I mean?

Feature

Most helpful comment

Looks like there's some value here - asp.net action filters appear to have a similar feature short-circuiting if result is set in a filter, we should try to mirror that behavior.

https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Core/Filters/ActionFilterAttribute.cs#L49

All 6 comments

It might be useful if the result was also passed in and could be changed by the OnExecutedAsync on the filters too.

Looks like there's some value here - asp.net action filters appear to have a similar feature short-circuiting if result is set in a filter, we should try to mirror that behavior.

https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Core/Filters/ActionFilterAttribute.cs#L49

We're tracking some remaining work items for Filters in this issue https://github.com/Azure/azure-webjobs-sdk/issues/1284. For the initial set of functionality we kept things scoped to get feedback. We have it on our TODO list to look at return values from filters, and I updated the issue to also mention short circuiting so we can explore that.

I created a new tracking item here for the all up Result/Cancel feature: https://github.com/Azure/azure-webjobs-sdk/issues/1314

That's great, I look forward to the features! Thanks

Can you please provide status update?

No progress on this halfway through 2019 now?

Was this page helpful?
0 / 5 - 0 ratings