ezLifecycle

package
v0.0.0-...-77ac295 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is an application components lifecycle manager

func New

func New(opts ...Option) *App

New create an application lifecycle manager.

func (*App) Append

func (a *App) Append(lc Lifecycle)

Append register interface that are executed on application start and stop.

func (*App) AppendInstance

func (a *App) AppendInstance(ins Instance)

AppendInstance register callbacks that are executed on application start and stop.

func (*App) Run

func (a *App) Run() error

Run executes all OnStart Instances registered with the application's Lifecycle.

func (*App) Stop

func (a *App) Stop()

Stop gracefully stops the application.

type Instance

type Instance struct {
	OnStart func(context.Context) error
	OnStop  func(context.Context) error
}

Instance is a pair of start and stop callbacks.

type Lifecycle

type Lifecycle interface {
	Start(context.Context) error
	Stop(context.Context) error
}

Lifecycle is component lifecycle.

type Option

type Option func(o *options)

Option is an application option.

func Signal

func Signal(fn func(*App, os.Signal), sigs ...os.Signal) Option

Signal with os signals.

func StartTimeout

func StartTimeout(d time.Duration) Option

StartTimeout with start timeout.

func StopTimeout

func StopTimeout(d time.Duration) Option

StopTimeout with stop timeout.

Jump to

Keyboard shortcuts

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