knative/func

lifecycle hook apis

Closed this issue · 3 comments

matzew commented

Looking at the Go lang tempaltes, I am seeing some nice hooks to plug into the lifecycle of a function:
https://github.com/knative/func/blob/main/templates/go/.instanced-http/function.go#L34-L69

It would be nice if other SDKs/languages, such as Node.js, quarkus would have these APIs:

  • Start
  • Stop
  • Alive
  • Ready

Seems pretty handy

@matzew JS/TS have this too https://github.com/rh-max/openshift-docs/blob/a500f4874d3c0a14a88265d451ca1ea39d6fcd29/modules/serverless-nodejs-functions-overriding-liveness-readiness.adoc

With Quarkus you can do it too albeit it might be little bit more complicated. You just need to use standard Java lifecycle thingies @PostConstruct @PreDestroy. For health probes check out https://quarkus.io/guides/smallrye-health.

Yes, very good to know it's possible in JS and Quarkus. I'd like to discuss further how these are implemented and invoked to ensure we're being consistent. Especially since we'll hopefully be able to provide them in Python and Rust in the not-too-distant future

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.