This section is empty.


View Source
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")


func Register

func Register(id, name, description string, module *modules.Module, configKeySpace string, option *config.Option)

    Register registers a new subsystem. It's like Manager.Register but uses DefaultManager and panics on error.


    type Manager

    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

      func NewManager(rtReg *runtime.Registry) (*Manager, error)

        NewManager returns a new subsystem manager that registers itself at rtReg.

        func (*Manager) CheckConfig

        func (mng *Manager) CheckConfig(ctx context.Context) error

          CheckConfig checks subsystem configuration values and enables or disables subsystems and their dependencies as required.

          func (*Manager) Get

          func (mng *Manager) Get(keyOrPrefix string) ([]record.Record, error)

            Get implements runtime.ValueProvider

            func (*Manager) PrintGraph

            func (mng *Manager) PrintGraph()

              PrintGraph prints the subsystem and module graph.

              func (*Manager) Register

              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.

                func (*Manager) Start

                func (mng *Manager) Start() error

                  Start starts managing subsystems. Note that it's not possible to define new subsystems once Start() has been called.

                  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 {
                    	// 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.