Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
StartupOpts = &allStartupOptions{}
)
Functions ¶
func StartAndWait ¶
func StartAndWait(ctx context.Context, componentName string, startFunc StartFunc, opts ...StartupOption) error
StartAndWait handles wait groups, cancels and signals on its own The context passed as an argument has to have a ContextWaitGroup context value defined, otherwise StartAndWait will return with an error.
StartAndWait executes startFunc and waits for context wait group, if context wait group is empty then startFunc does not block and returns immediately, startFunc can be terminated using SIGTERM signal, context cancel or timeout StartupOption.
componentName - used for logging purposes to identify which component is started and shut down. startFunc - function to call when initialization is done. The function must initialize and then return. I.e. not block.
Types ¶
type StartFunc ¶
StartFunc must initialize and then return. I.e. not block. It must listen for the ctx.Done() and release resources when it happens.
type StartupOption ¶
type StartupOption func(*startupOptions)