-
Notifications
You must be signed in to change notification settings - Fork 450
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
Host Level Event Support #281
Comments
Indeed, thinking in term of host feels odd in a server-less world. We could be scaling from 1 to 10 hosts/instances, and then back down. Ideally, we want to be in a place where if something needs to be flushed, it just happens automatically as needed. |
If you're doing static level caching of things for performance and only doing periodic flushes, you want the ability to quickly flush stuff if the process is going down. It will often not be possible to flush per function invocation. Now, if your background periodic flush is often enough, perhaps in practice you won't miss much, but ideally you want the chance to flush. |
@fabiocav add a new answer on how to intercept graceful shutdown using a CancellationToken argument in a function. It works fine for me. |
In addition to startup/shutdown hooks, I feel it's important to reiterate the mention of global state and advocate more first class support for it. If I should open up a dedicated feature request on this topic (separate from startup/shutdown hooks), please let me know. |
Any update to this, 4 years and counting? Looking for node support to setup DB connections at startup, no matter which function is called first. Right now the work around to support this is quite poor. |
Also interested in this functionality. I know there are entity functions, but those do not fit every use case. If no one can detect when the lifetime of a workload ends there can be no efficient flushing.
|
Consider adding the ability for user code to be triggered on various host level events, e.g. Startup/Shutdown. Here is a case from SO where the user would like to perform a flush operation on static data: https://stackoverflow.com/questions/36760241/intercept-azure-function-host-shutdown-flush-application-insights-telemetryclie. This would also provide a mechanism for users to write Function App initialization code - i.e. startup time logic that only needs to be run once in an app domain.
We could introduce a new Functions specific trigger that triggers on system events. Users can then write a function for these and handle as is - no new mechanism for running user code is needed. This is similar in spirit to the ErrorTrigger extension I wrote (sample code here). However for functions we might want to generalize that more so its not just errors. Perhaps rather than making this Functions specific, it can be a first class Extension, since the scenarios exist outside of Functions. We could allow people to write a trigger like
[HostEventTrigger("Shutdown")] HostEvent event
. This would facilitate existing scenarios as well. We could then expose this new extension in Functions.Let's see if more scenarios pop up requiring something like this, or if there are other better ways to solve these cases. Ideally we don't really want users thinking in terms of the host - we want them to just focus on relatively short lived functions.
The text was updated successfully, but these errors were encountered: