utilsLifecycle

package
v0.0.0-...-7ec6a99 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 6 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) AppendHook

func (a *App) AppendHook(hook Hook)

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

func (*App) Run

func (a *App) Run() error

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

func (*App) Stop

func (a *App) Stop()

Stop gracefully stops the application.

type Hook

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

Hook 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