lifecycle

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotStarted = orberrors.NewTransient(errors.New("service has not started"))

ErrNotStarted indicates that an attempt was made to invoke a service that has not been started or is still in the process of starting.

Functions

This section is empty.

Types

type Lifecycle

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

Lifecycle implements the lifecycle of a service, i.e. Start and Stop.

func New

func New(name string, opts ...Opt) *Lifecycle

New returns a new Lifecycle.

func (*Lifecycle) Start

func (h *Lifecycle) Start()

Start starts the service.

func (*Lifecycle) State

func (h *Lifecycle) State() State

State returns the state of the service.

func (*Lifecycle) Stop

func (h *Lifecycle) Stop()

Stop stops the service.

type Opt

type Opt func(opts *options)

Opt sets a Lifecycle option.

func WithStart

func WithStart(start func()) Opt

WithStart sets the start function which is invoked when Start() is called.

func WithStop

func WithStop(stop func()) Opt

WithStop sets the stop function which is invoked when Stop() is called.

type State

type State = uint32

State is the state of the service.

const (
	// StateNotStarted indicates that the service has not been started.
	StateNotStarted State = 0
	// StateStarting indicates that the service is in the process of starting.
	StateStarting State = 1
	// StateStarted indicates that the service has been started.
	StateStarted State = 2
	// StateStopped indicates that the service has been stopped.
	StateStopped State = 3
)

Jump to

Keyboard shortcuts

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