launcher

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 11 Imported by: 3

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
}

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 added in v0.2.2

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 added in v0.1.0

func WithOpsConfig(c ops.Config) Option

func WithRunnerServicesSequence added in v0.1.0

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

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

type RunnerServicesSequence added in v0.1.0

type RunnerServicesSequence int

Jump to

Keyboard shortcuts

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