Documentation ¶
Overview ¶
Package manager is the module manager, it wraps the initialization and mass notification of core-plugin's modules.
Index ¶
- Constants
- func Metrics() map[string]*ModuleMetric
- func NotifyQuit(ctx context.Context, stage ModuleStage)
- func Register(mods []*Module, stage ModuleStage)
- func RunBlocking(ctx context.Context, stage ModuleStage, data any) error
- func Shutdown()
- type Errors
- type InitType
- type Module
- type ModuleMetric
- type ModuleStage
- type ModuleStatus
Constants ¶
const ( // EarlyStage represents the early stage of core-plugin execution, modules in // such stage are executed on behalf of early platform initialization, it's // assumed that the OS is still not yet fully compatible/configured with GCE // platform. EarlyStage ModuleStage = iota // LateStage represents the late(r) stage of core-plugin execution, it takes // off after the early stage has finished and we've notified Guest Agent. LateStage // BlockingInit represents the module initialization executed in a blocking // manner. BlockingInit InitType = iota // ConcurrentInit represents the module initialization executed in a // concurrent manner. ConcurrentInit // StatusSkipped represents a module initialization that was skipped. StatusSkipped ModuleStatus = iota // StatusFailed represents a module initialization that failed. StatusFailed // StatusSucceeded represents a module initialization that succeeded. StatusSucceeded )
Variables ¶
This section is empty.
Functions ¶
func Metrics ¶
func Metrics() map[string]*ModuleMetric
Metrics returns/exposes the modules metrics. The returned map is a copy of the internal map and is safe to be modified after returned (both internally and externally).
func NotifyQuit ¶
func NotifyQuit(ctx context.Context, stage ModuleStage)
NotifyQuit notifies modules registered for a stage that they should nicely quit.
func Register ¶
func Register(mods []*Module, stage ModuleStage)
Register registers modules in a execution/initialization stage. The order the modules are registered is honored.
func RunBlocking ¶
func RunBlocking(ctx context.Context, stage ModuleStage, data any) error
RunBlocking runs all modules in a given stage in a blocking manner. The selection of modules is based on the existence of the BlockSetup function implementation. It returns an error wrapping all errors returned by the modules.
Types ¶
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors is a collection of module initialization/setup errors.
func RunConcurrent ¶
func RunConcurrent(ctx context.Context, stage ModuleStage, data any) *Errors
RunConcurrent runs all modules in a given stage in parallel. The selection of of modules is based on the existence of the Setup function implementation. It returns an Errors wrapping all errors returned by the modules.
type InitType ¶
type InitType int
InitType is the type of initialization a module should be executed.
type Module ¶
type Module struct { // Enabled is a flag to indicate if the module is enabled/disabled in the // local configuration. Enabled *bool // ID is a string representation of a module identification. ID string // Description is a string representation of a module description. Description string // Setup is the function to initialize the module. Modules implementing this // function will have its execution ran in parallel with other modules - every // module Setup will be executed in a different goroutine. Setup func(ctx context.Context, data any) error // BlockSetup is equivalent to Setup but the modules initialization will // happen in sequence, meaning, a module initialization blocks the // initialization of all the non-initialized modules. BlockSetup func(ctx context.Context, data any) error // Quit is the function implemented by the module to get notifications to // "nicely" quit, the manager will wait for these executions to finish. When // returned from Quit the module is communicating that it's fully done. Quit func(ctx context.Context) }
Module is the configuration structure of a module.
func List ¶
func List(stage ModuleStage) []*Module
List returns the list of modules registered for a given stage.
type ModuleMetric ¶
type ModuleMetric struct { // Module is the module that was initialized. Module *Module // Stage is the stage in which the module was initialized. Stage ModuleStage // Start is the time the module initialization started. Start time.Time // End is the time the module initialization ended. End time.Time // Err is the error/status of the module initialization. Err error // Status is the status of the module initialization. Status ModuleStatus // InitType is the type of initialization the module was executed. InitType InitType }
ModuleMetric contains the module's initialization metrics.
type ModuleStage ¶
type ModuleStage int
ModuleStage is the stage in which a module should be grouped in.