starter

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2023 License: AGPL-3.0, ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type StartFunc func(ctx context.Context)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL