Documentation ¶
Index ¶
- Variables
- func Register(id, name, description string, module *modules.Module, configKeySpace string, ...)
- type Manager
- func (mng *Manager) CheckConfig(ctx context.Context) error
- func (mng *Manager) Get(keyOrPrefix string) ([]record.Record, error)
- func (mng *Manager) PrintGraph()
- func (mng *Manager) Register(id, name, description string, module *modules.Module, configKeySpace string, ...) error
- func (mng *Manager) Start() error
- type ModuleStatus
- type Subsystem
Constants ¶
This section is empty.
Variables ¶
var ( // ErrManagerStarted is returned when subsystem registration attempt // occurs after the manager has been started. ErrManagerStarted = errors.New("subsystem manager already started") // ErrDuplicateSubsystem is returned when the subsystem to be registered // is alreadey known (duplicated subsystem ID). ErrDuplicateSubsystem = errors.New("subsystem is already registered") )
Functions ¶
Types ¶
type Manager ¶ added in v0.9.0
type Manager struct {
// contains filtered or unexported fields
}
Manager manages subsystems, provides access via a runtime value providers and can takeover module management.
var ( // DefaultManager is the default subsystem registry. DefaultManager *Manager )
func NewManager ¶ added in v0.9.0
NewManager returns a new subsystem manager that registers itself at rtReg.
func (*Manager) CheckConfig ¶ added in v0.9.0
CheckConfig checks subsystem configuration values and enables or disables subsystems and their dependencies as required.
func (*Manager) PrintGraph ¶ added in v0.9.0
func (mng *Manager) PrintGraph()
PrintGraph prints the subsystem and module graph.
func (*Manager) Register ¶ added in v0.9.0
func (mng *Manager) Register(id, name, description string, module *modules.Module, configKeySpace string, option *config.Option) error
Register registers a new subsystem. The given option must be a bool option. Should be called in init() directly after the modules.Register() function. The config option must not yet be registered and will be registered for you. Pass a nil option to force enable.
TODO(ppacher): IMHO the subsystem package is not responsible of registering the "toggle option". This would also remove runtime dependency to the config package. Users should either pass the BoolOptionFunc and the expertise/release level directly or just pass the configuration key so those information can be looked up by the registry.
type ModuleStatus ¶
type ModuleStatus struct { Name string // status mgmt Enabled bool Status uint8 // failure status FailureStatus uint8 FailureID string FailureMsg string // contains filtered or unexported fields }
ModuleStatus describes the status of a module.
type Subsystem ¶
type Subsystem struct { record.Base sync.Mutex // ID is a unique identifier for the subsystem. ID string // Name holds a human readable name of the subsystem. Name string // Description may holds an optional description of // the subsystem's purpose. Description string // Modules contains all modules that are related to the subsystem. // Note that this slice also contains a reference to the subsystem // module itself. Modules []*ModuleStatus // FailureStatus is the worst failure status that is currently // set in one of the subsystem's dependencies. FailureStatus uint8 // ToggleOptionKey holds the key of the configuration option // that is used to completely enable or disable this subsystem. ToggleOptionKey string // ExpertiseLevel defines the complexity of the subsystem and is // copied from the subsystem's toggleOption. ExpertiseLevel config.ExpertiseLevel // ReleaseLevel defines the stability of the subsystem and is // copied form the subsystem's toggleOption. ReleaseLevel config.ReleaseLevel // ConfigKeySpace defines the database key prefix that all // options that belong to this subsystem have. Note that this // value is mainly used to mark all related options with a // config.SubsystemAnnotation. Options that are part of // this subsystem but don't start with the correct prefix can // still be marked by manually setting the appropriate annotation. ConfigKeySpace string // contains filtered or unexported fields }
Subsystem describes a subset of modules that represent a part of a service or program to the user. Subsystems can be (de-)activated causing all related modules to be brought down or up.