module

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEnabled = errors.New("module is not enabled")

ErrNotEnabled is a special error type that should be returned by a Factory when the associated Module is not enabled.

Functions

func Close

func Close()

Close each registered module

func GetStats

func GetStats() map[string]interface{}

GetStats returns the stats from all modules, namespaced by their names

func Register

func Register(cfg *config.Config, httpMux *mux.Router, factories []Factory) error

Register a set of modules, which involves: * Initialization using the provided Factory; * Registering the HTTP endpoints of each module;

func RestartModule

func RestartModule(factory Factory) error

RestartModule triggers a module restart

Types

type Factory

type Factory struct {
	Name config.ModuleName
	Fn   func(cfg *config.Config) (Module, error)
}

Factory encapsulates the initialization of a Module

type Module

type Module interface {
	GetStats() map[string]interface{}
	Register(*Router) error
	Close()
}

Module defines the common API implemented by every System Probe Module

type Router

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

Router provides a wrapper around mux.Router so routes can be re-registered This is needed to support the module-restart feature

func NewRouter

func NewRouter(mux *mux.Router) *Router

NewRouter returns a new Router

func (*Router) HandleFunc

func (r *Router) HandleFunc(path string, responseWriter func(http.ResponseWriter, *http.Request)) *mux.Route

HandleFunc registers a HandleFunc in such a way that routes can be registered multiple times

Jump to

Keyboard shortcuts

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