lifecycles

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

TODO:

  • threadsafety lol
  • DEFERRED DEPS

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback = func(State)

type Controller

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

func (Controller) AddCallback

func (c Controller) AddCallback(cb Callback)

func (*Controller) Construct

func (c *Controller) Construct() error

func (*Controller) Destroy

func (c *Controller) Destroy() error

func (*Controller) Start

func (c *Controller) Start() error

func (Controller) State

func (c Controller) State() State

func (*Controller) Stop

func (c *Controller) Stop() error

type DependencyNotFoundError

type DependencyNotFoundError struct {
	Dependent,
	Dependency any
}

func (DependencyNotFoundError) Error

func (e DependencyNotFoundError) Error() string

type Handler

type Handler = func(State) error

type Lifecycle

type Lifecycle interface {
	State() State
	AddCallback(Callback)

	Construct() error
	Start() error
	Stop() error
	Destroy() error
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) AddCallback

func (m *Manager) AddCallback(cb Callback)

func (*Manager) AddDependencies

func (m *Manager) AddDependencies(obj any, deps []any) error

func (*Manager) AddObject

func (m *Manager) AddObject(obj any, fn func(State) error, deps []any) error

func (*Manager) AddObjectCallback

func (m *Manager) AddObjectCallback(obj any, cb Callback) error

func (*Manager) Construct

func (m *Manager) Construct() error

func (*Manager) Destroy

func (m *Manager) Destroy() error

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) State

func (m *Manager) State() State

func (*Manager) Stop

func (m *Manager) Stop() error

type ObjectAlreadyRegisteredError

type ObjectAlreadyRegisteredError struct {
	Obj any
}

func (ObjectAlreadyRegisteredError) Error

type ObjectNotRegisteredError

type ObjectNotRegisteredError struct {
	Obj any
}

func (ObjectNotRegisteredError) Error

func (e ObjectNotRegisteredError) Error() string

type State

type State int8
const (
	New State = iota

	Constructing
	FailedConstructing
	Constructed

	Starting
	FailedStarting
	Started

	Stopping
	FailedStopping
	Stopped

	Destroying
	FailedDestroying
	Destroyed
)

func ParseState

func ParseState(s string) State

func (State) IsFailed

func (s State) IsFailed() bool

func (State) IsStable

func (s State) IsStable() bool

func (State) IsTransitional

func (s State) IsTransitional() bool

func (State) Mask

func (s State) Mask() StateMask

func (State) String

func (s State) String() string

type StateError

type StateError struct {
	Current  State
	Expected StateMask
}

func (StateError) Error

func (e StateError) Error() string

type StateMask

type StateMask int16

func (StateMask) Contains

func (m StateMask) Contains(s State) bool

func (StateMask) Len

func (m StateMask) Len() int

func (StateMask) String

func (m StateMask) String() string

Jump to

Keyboard shortcuts

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