Run lifecycle hook parallelly
Is your feature request related to a problem? Please describe. lifecycle hook is running one by one. if someone run too long, the hooks after it may be failed by timeout because all hooks share same start/stop timeout.
Describe the solution you'd like
hooks are not depend on each other usually.
can we add a option to make hook run in specific parallelism n.
like fx.New(fx.ParallelHooks(n), ...)
Describe alternatives you've considered
I can start a goroutine in hooks to make it run fastly.
but error can't be catched by fx
Is this a breaking change? No, default is 1 It means no behaviour change with existing code.
Additional context
hooks are not depend on each other usually
My experience speaks to the contrary. It is usually an expectation that if provider depends on some objects, start hooks for all dependencies had completed before the provider's start hook runs (and vice versa for stop hooks).
However, some parallelism can be exploited, as long as invocation of hooks sticks to the dependency DAG.
Terraform has a handy implementation that does exactly that: https://github.com/hashicorp/terraform/blob/main/internal/dag/walk.go