component

package
v0.0.0-...-0d0b053 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrComponentIsNil        = errors.New("component is nil")
	ErrComponentIsNotRunning = errors.New("component is not running")
)

Functions

This section is empty.

Types

type Component

type Component interface {
	Start(ctx context.Context) (result bool)
	Interrupt(ctx context.Context) (err error)

	IsInterrupted() bool
	IsHalted() bool
	IsStarted() bool
	IsRunning() bool

	WaitUntilStarted(ctx context.Context) error
	WaitUntilHalted(ctx context.Context) error

	Error() error
}

Жизненный цикл: Создан -> Запущен -> [Прерван] -> Остановлен/Завершён

func NewComponent

func NewComponent(main func(context.Context) error, opts ...Opt) Component

type Opt

type Opt = options.Opt[compOptions]

func WithOnHalt

func WithOnHalt(f func(context.Context, error)) Opt

func WithOnInterrupt

func WithOnInterrupt(f func(context.Context) error) Opt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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