Back to

Package lifecycle

Latest Go to latest
Published: Jan 22, 2019 | License: MIT | Module:


Package Files

type Hook

type Hook struct {
	OnStart func(context.Context) error
	OnStop  func(context.Context) error
	// contains filtered or unexported fields

A Hook is a pair of start and stop callbacks, either of which can be nil, plus a string identifying the supplier of the hook.

type Lifecycle

type Lifecycle struct {
	// contains filtered or unexported fields

Lifecycle coordinates application lifecycle hooks.

func New

func New(logger *fxlog.Logger) *Lifecycle

New constructs a new Lifecycle.

func (*Lifecycle) Append

func (l *Lifecycle) Append(hook Hook)

Append adds a Hook to the lifecycle.

func (*Lifecycle) Start

func (l *Lifecycle) Start(ctx context.Context) error

Start runs all OnStart hooks, returning immediately if it encounters an error.

func (*Lifecycle) Stop

func (l *Lifecycle) Stop(ctx context.Context) error

Stop runs any OnStop hooks whose OnStart counterpart succeeded. OnStop hooks run in reverse order.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier