gajus / lightship

Abstracts readiness, liveness and startup checks and graceful shutdown of Node.js services running in Kubernetes.
Other
517 stars 33 forks source link

Run shutdown handlers is paralle #6

Closed gajus closed 4 years ago

gajus commented 5 years ago

Currently the shutdown handlers are executed sequentially.

Running shutdown handlers in parallel would potentially shorten the shutdown time.

Refer to https://github.com/gajus/lightship/issues/5#issuecomment-451775408 discussion.

memelet commented 4 years ago

I agree with @dcherman, that dependencies should be handled by registered handler.

gajus commented 4 years ago

This introduces unnecessary ambiguity. There is nothing stopping user from simply implementing their own collection of methods that need to be run in parallel, i.e.

registerShutdownHandler(async () => {
  await Promise.all([
    userCollectionOfShutdownHandlers,
  ]);
});