launcher

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RunnerServicesSequenceNone = iota
	RunnerServicesSequenceFifo
	RunnerServicesSequenceLifo
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ILauncher

type ILauncher interface {
	// Run launcher and all services
	Run() error
	// Stop launcher and all services
	Stop()
	// ServicesRunner return services runner
	ServicesRunner() IServicesRunner
	// Context return global context
	Context() context.Context

	// AddBeforeStartHooks adds before start hooks
	AddBeforeStartHooks(hook ...func() error)
	// AddBeforeStopHooks adds before stop hooks
	AddBeforeStopHooks(hook ...func() error)
	// AddAfterStartHooks adds after start hooks
	AddAfterStartHooks(hook ...func() error)
	// AddAfterStopHooks adds after stop hooks
	AddAfterStopHooks(hook ...func() error)
}

func New

func New(opts ...Option) ILauncher

New creates a new launcher.

type IServicesRunner

type IServicesRunner interface {
	// Register servicse
	Register(services ...*service.Service)
	// Services return all registered services
	Services() []*service.Service
}

type Option

type Option func(*Options)

func WithAfterStart

func WithAfterStart(fn func() error) Option

WithAfterStart run funcs after service starts.

func WithAfterStop

func WithAfterStop(fn func() error) Option

WithAfterStop run funcs after service stops.

func WithAppStartStopLog

func WithAppStartStopLog(v bool) Option

func WithBeforeStart

func WithBeforeStart(fn func() error) Option

WithBeforeStart run funcs before service starts.

func WithBeforeStop

func WithBeforeStop(fn func() error) Option

WithBeforeStop run funcs before service stops.

func WithContext

func WithContext(ctx context.Context) Option

func WithLogger

func WithLogger(l logger.ExtendedLogger) Option

func WithName

func WithName(n string) Option

Name of the launcher.

func WithOpsConfig

func WithOpsConfig(c ops.Config) Option

func WithRunnerServicesSequence

func WithRunnerServicesSequence(v RunnerServicesSequence) Option

func WithSignal

func WithSignal(b bool) Option

func WithVersion

func WithVersion(v string) Option

Version of the launcher.

type Options

type Options struct {
	Name    string
	Version string

	// Before and After funcs
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	AppStartStopLog bool

	RunnerServicesSequence RunnerServicesSequence

	Signal bool

	Context context.Context //nolint:containedctx

	OpsConfig ops.Config
	// contains filtered or unexported fields
}

type RunnerServicesSequence

type RunnerServicesSequence int

Jump to

Keyboard shortcuts

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