Documentation ¶
Index ¶
- Variables
- func NewModuleService(name string, logger log.Logger, service services.Service, ...) services.Service
- func UserInvisibleModule(m *module)
- type Manager
- func (m *Manager) AddDependency(name string, dependsOn ...string) error
- func (m *Manager) DependenciesForModule(module string) []string
- func (m *Manager) InitModuleServices(modules ...string) (map[string]services.Service, error)
- func (m *Manager) IsModuleRegistered(mod string) bool
- func (m *Manager) IsUserVisibleModule(mod string) bool
- func (m *Manager) RegisterModule(name string, initFn func() (services.Service, error), ...)
- func (m *Manager) UserVisibleModuleNames() []string
Constants ¶
This section is empty.
Variables ¶
var ErrStopProcess = errors.New("stop process")
ErrStopProcess is the error returned by a service as a hint to stop the server entirely.
Functions ¶
func NewModuleService ¶ added in v1.13.0
func NewModuleService(name string, logger log.Logger, service services.Service, startDeps, stopDeps func(string) map[string]services.Service) services.Service
NewModuleService wraps a module service, and makes sure that dependencies are started/stopped before module service starts or stops. If any dependency fails to start, this service fails as well. On stop, errors from failed dependencies are ignored.
func UserInvisibleModule ¶ added in v1.3.0
func UserInvisibleModule(m *module)
UserInvisibleModule is an option for `RegisterModule` that marks module not visible to user. Modules are user visible by default.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a component that initialises modules of the application in the right order of dependencies.
func (*Manager) AddDependency ¶
AddDependency adds a dependency from name(source) to dependsOn(targets) An error is returned if the source module name is not found
func (*Manager) DependenciesForModule ¶ added in v1.4.0
DependenciesForModule returns transitive dependencies for given module, sorted by name.
func (*Manager) InitModuleServices ¶
InitModuleServices initialises given modules by initialising all their dependencies in the right order. Modules are wrapped in such a way that they start after their dependencies have been started and stop before their dependencies are stopped.
func (*Manager) IsModuleRegistered ¶ added in v1.10.0
IsModuleRegistered checks if the given module has been registered or not. Returns true if the module has previously been registered via a call to RegisterModule, false otherwise.
func (*Manager) IsUserVisibleModule ¶ added in v1.3.0
IsUserVisibleModule check if given module is public or not. Returns true if and only if the given module is registered and is public.
func (*Manager) RegisterModule ¶
func (m *Manager) RegisterModule(name string, initFn func() (services.Service, error), options ...func(option *module))
RegisterModule registers a new module with name, init function, and options. Name must be unique to avoid overwriting modules. If initFn is nil, the module will not initialise. Modules are user visible by default.
func (*Manager) UserVisibleModuleNames ¶ added in v1.3.0
UserVisibleModuleNames gets list of module names that are user visible. Returned list is sorted in increasing order.