plugins

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Interfaces = make(map[string]ModuleInterface)

Interfaces stores module-name to ModuleInterface mapping for all loaded plugins

Functions

func Enforce

func Enforce(moduleName string, params map[string]interface{}) (string, error)

Enforce simplifies enforcing data using specified plugin

Function checks if plugin is loaded, verifies if stored interface is not null and then calls Enforce() method of stored interface. Returns error if any of steps above fails

func GetConfig

func GetConfig(name string) (map[string]interface{}, error)

GetConfig reads configuration section given by name and returns it as a map of string-interface pairs

func Release

func Release(moduleName string, params map[string]interface{}) error

Release simplifies releasing data using specified plugin

Function checks if plugin is loaded, verifies if stored interface is not null and then calls Release() method of stored interface. Returns error if any of steps above fails

func Store

func Store(name string, iface ModuleInterface) error

Store stores provided module interface under provided name

If module already exists or one of params is not correct (ex. nil interface) error is returned

func Validate

func Validate(moduleName string, params map[string]interface{}) error

Validate simplifies data validation for selected plugin

Function checks if plugin is loaded, verifies if stored interface is not null and then calls Validate() method of stored interface. Returns error if any of steps above fails

Types

type ModuleInterface

type ModuleInterface interface {

	// Initialize is a module initialization function
	// config param contains all information needed to initialize plugin
	// (ex. path to config file)
	Initialize(params map[string]interface{}) error

	// GetEndpointPrefixes returns declaration of REST endpoints handled by this module
	// If function's implementation for specific module returns:
	// { "/endpoint1" and "/endpoint2/" }
	// then RMD will expose and forward to this module requests for URI's:
	// - http://ip:port/v1/endpoint1
	// - http://ip:port/v1/endpoint2/
	// - all http://ip:port/v1/endpoint2/{something}
	GetEndpointPrefixes() []string

	// HandleRequest is called by HTTP request routing mechanism
	//
	// NOTE: currently "emicklei/go-restfull" package is used for HTTP requests routing
	// There's also a plan for standard HTTP package usage with following handling function
	// HandleRequest(wrt http.ResponseWriter, req *http.Request) error
	HandleRequest(request *restful.Request, response *restful.Response)

	// Validate allows workload module to check parameters before trying to enforce them
	Validate(params map[string]interface{}) error

	// Enforce allocates resources or set platform params according to data in 'params' map
	// Returned string should contain identifier for allocated resource.
	// If plugin does not need to store any identifier for future use in Release() then string should be empty
	Enforce(params map[string]interface{}) (string, error)

	// Release removes setting for given params
	// (in case of pstate it will be just disabling of monitoring for specified cores)
	Release(params map[string]interface{}) error

	// GetCapabilities returns comma separated list of platform resources used by plugin
	GetCapabilities() string
}

ModuleInterface defines interface of loadable RMD modules (dynamic loading with use of "plugin" package)

func Load

func Load(path string) (ModuleInterface, error)

Load opens file given in path param and tries to load symbol "Handle" implementing ModuleInterface Returns error if failed to open file, load symbol or cast interface

Jump to

Keyboard shortcuts

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