loader

package
v0.0.0-...-b6230bc Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 8 Imported by: 47

Documentation

Index

Constants

View Source
const (
	ErrorNoDependencies int = iota
	ErrorCircleDependencies
	ErrorMissingModule
	ErrorInternalError
	ErrorConflict
)

Variables

This section is empty.

Functions

func EnableModules

func EnableModules(enablingModules []string, disableModules []string, flag EnableFlag) error

func GetService

func GetService() *dbusutil.Service

func Register

func Register(m Module)

func SetLogLevel

func SetLogLevel(pri log.Priority)

func SetService

func SetService(s *dbusutil.Service)

func StartAll

func StartAll()

func StopAll

func StopAll()

TODO: check dependencies

func ToggleLogDebug

func ToggleLogDebug(enabled bool)

Types

type DAGBuilder

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

func NewDAGBuilder

func NewDAGBuilder(loader *Loader, enablingModules []string, disableModules []string, flag EnableFlag) *DAGBuilder

func (*DAGBuilder) Execute

func (builder *DAGBuilder) Execute() (*graph.Data, error)

type EnableError

type EnableError struct {
	ModuleName string
	Code       int
	// contains filtered or unexported fields
}

func (*EnableError) Error

func (e *EnableError) Error() string

type EnableFlag

type EnableFlag int
const (
	EnableFlagNone EnableFlag = 1 << iota
	EnableFlagIgnoreMissingModule
	EnableFlagForceStart
)

func (EnableFlag) HasFlag

func (flags EnableFlag) HasFlag(flag EnableFlag) bool

type Loader

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

func (*Loader) AddModule

func (l *Loader) AddModule(m Module)

func (*Loader) DeleteModule

func (l *Loader) DeleteModule(name string)

func (*Loader) EnableModules

func (l *Loader) EnableModules(enablingModules []string, disableModules []string, flag EnableFlag) error

func (*Loader) GetModule

func (l *Loader) GetModule(name string) Module

func (*Loader) List

func (l *Loader) List() []Module

func (*Loader) SetLogLevel

func (l *Loader) SetLogLevel(pri log.Priority)

func (*Loader) WaitDependencies

func (l *Loader) WaitDependencies(module Module)

type Module

type Module interface {
	Name() string
	IsEnable() bool
	Enable(bool) error
	GetDependencies() []string
	SetLogLevel(log.Priority)
	LogLevel() log.Priority
	WaitEnable() // TODO: should this function return when modules enable failed?
	ModuleImpl
}

func GetModule

func GetModule(name string) Module

func List

func List() []Module

type ModuleBase

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

func NewModuleBase

func NewModuleBase(name string, impl ModuleImpl, logger *log.Logger) *ModuleBase

func (*ModuleBase) Enable

func (d *ModuleBase) Enable(enable bool) error

func (*ModuleBase) IsEnable

func (d *ModuleBase) IsEnable() bool

func (*ModuleBase) LogLevel

func (d *ModuleBase) LogLevel() log.Priority

func (*ModuleBase) Name

func (d *ModuleBase) Name() string

func (*ModuleBase) SetLogLevel

func (d *ModuleBase) SetLogLevel(pri log.Priority)

func (*ModuleBase) WaitEnable

func (d *ModuleBase) WaitEnable()

type ModuleImpl

type ModuleImpl interface {
	Start() error // please keep Start sync, please return err, err log will be done by loader
	Stop() error
}

type Modules

type Modules map[string]Module

Jump to

Keyboard shortcuts

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