Documentation
¶
Index ¶
- func AddInfrastructure(svc service.Service)
- func AddPreStartHook(fn func() PreStartHook)
- func AddPreStartHookType[T any, P interface{ ... }]()
- func AddService(svc service.Service)
- func AllInfrastructure() []service.Service
- func AllServices() []service.Service
- func ServiceByName(name string) service.Service
- func Start(ctx context.Context, opts ...any) error
- func StartServices(ctx context.Context, kind string, svcs ...service.Service) error
- func Stop(ctx context.Context, includeInfrastructure bool, exclude []string) error
- func StopServices(ctx context.Context, svcs ...service.Service) error
- type PreStartHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddInfrastructure ¶
func AddPreStartHook ¶
func AddPreStartHook(fn func() PreStartHook)
func AddPreStartHookType ¶
func AddPreStartHookType[T any, P interface { *T PreStartHook }]()
AddPreStartHookType is a helper to register a PreStartHook implementation for a type T where *T implements PreStartHook. When running the pre-start process, a new(T) will be created and used.
This is useful for a type that stores state between the pre-start stages, but which does not need initialization before the first stage.
func AddService ¶
func AllInfrastructure ¶
func AllServices ¶
func ServiceByName ¶
ServiceByName returns the service with the given name, if it exists.
If the service does not exist, it returns nil.
func Start ¶
Start starts the stack with the given options.
Options must be of type service.ContextOption or resource.ContextOption, and will be passed to service.NewContext and resource.NewContext respectively.
func StartServices ¶
Types ¶
type PreStartHook ¶
type PreStartHook interface {
Name() string
LoadServices(context.Context) error
BeforeServices(ctx context.Context, infra, svcs []service.Service) error
Service(context.Context, service.Service) error
AfterServices(ctx context.Context, infra, svcs []service.Service) error
}
func PreStartHookFuncs ¶
func PreStartHookFuncs( name string, loadServices func(ctx context.Context) error, beforeServices func(ctx context.Context, infra, svcs []service.Service) error, service func(ctx context.Context, svc service.Service) error, afterServices func(ctx context.Context, infra, svcs []service.Service) error, ) PreStartHook
PreStartHookFuncs creates a PreStartHook built from the given functions. Any of them may be nil if no action is needed. A hook with all nil functions is silly, but not an error.