stack

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInfrastructure

func AddInfrastructure(svc service.Service)

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 AddService(svc service.Service)

func AllInfrastructure

func AllInfrastructure() []service.Service

func AllServices

func AllServices() []service.Service

func ServiceByName

func ServiceByName(name string) service.Service

ServiceByName returns the service with the given name, if it exists.

If the service does not exist, it returns nil.

func Start

func Start(ctx context.Context, opts ...any) error

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

func StartServices(ctx context.Context, kind string, svcs ...service.Service) error

func Stop

func Stop(
	ctx context.Context,
	includeInfrastructure bool,
	exclude []string,
) error

TODO: make progress printing pluggable

func StopServices

func StopServices(ctx context.Context, svcs ...service.Service) error

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.

Jump to

Keyboard shortcuts

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