lifecycle

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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.

Jump to

Keyboard shortcuts

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