plugin

package
v0.0.0-...-89602ce Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 18 Imported by: 3

Documentation

Overview

* Package plugin defines the interface for a plugin into the services provided * with the magma orchestrator. For module authors, the OrchestratorPlugin * is the point of integration with the orchestrator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenHandlerLists

func FlattenHandlerLists(handlersIn ...[]obsidian.Handler) []obsidian.Handler

FlattenHandlerLists turns a variadic list of obsidian handlers into a single flattened list of handlers. This is typically used to merge handlers from different services into a single collection to return in an impl of OrchestratorPlugin.

func LoadAllPlugins

func LoadAllPlugins(loader OrchestratorPluginLoader) error

LoadAllPlugins loads and registers all orchestrator plugins, returning the first error encountered during the process. Standard use-cases should pass DefaultOrchestratorPluginLoader.

This function will NOT roll back registered plugins if it fails in the middle of execution. For this reason, you will likely prefer to use LoadAllPluginsFatalOnError which wraps this function with a glog.Fatal.

func LoadAllPluginsFatalOnError

func LoadAllPluginsFatalOnError(loader OrchestratorPluginLoader)

LoadAllPluginsFatalOnError loads and registers all orchestrator plugins and calls os.Exit() on error. See LoadAllPlugins for additional documentation.

func RegisterPluginForTests

func RegisterPluginForTests(_ *testing.T, plugin OrchestratorPlugin) error

RegisterPluginForTests registers all components of a given plugin with the corresponding component registries exposed by the orchestrator. This should only be used in test code to avoid the cost of building and loading plugins from disk for unit tests, thus the required but unused *testing.T parameter. This function will not register a plugin which has already been registered as identified by its GetName().

Types

type DefaultOrchestratorPluginLoader

type DefaultOrchestratorPluginLoader struct{}

DefaultOrchestratorPluginLoader looks for all .so files in /var/opt/magma/plugins and tries to load each .so as an OrchestratorPlugin.

func (DefaultOrchestratorPluginLoader) LoadPlugins

type OrchestratorPlugin

type OrchestratorPlugin interface {
	// GetName returns a unique name for the plugin.
	GetName() string

	// GetServices returns a list of services that this plugin runs to register
	// with the orc8r service registry.
	GetServices() []registry.ServiceLocation

	// GetSerdes returns a list of Serde implementations to register with the
	// global serde registry. These serdes are the primary integration surface
	// for many core orchestrator services.
	GetSerdes() []serde.Serde

	// GetMconfigBuilders returns a list of MconfigBuilders to register with
	// the configurator service. These builder are responsible for constructing
	// mconfigs to pass down to gateways.
	GetMconfigBuilders() []configurator.MconfigBuilder

	// GetMetricsProfiles returns the metricsd profiles that this module
	// supplies. This will make specific configurations available for metricsd
	// to load on startup. See MetricsProfile for additional documentation.
	GetMetricsProfiles(metricsConfig *config.ConfigMap) []metricsd.MetricsProfile

	// GetObsidianHandlers returns all the custom obsidian handlers for the
	// plugin to add functionality to the REST API.
	GetObsidianHandlers(metricsConfig *config.ConfigMap) []obsidian.Handler

	// GetStreamerProviders returns streamer streams to expose to gateways.
	// These stream providers are the primary mechanism by which gateways
	// receive data from the orchestrator (e.g. configuration).
	GetStreamerProviders() []providers.StreamProvider

	// GetStateIndexers returns a list of Indexers to register with the state service.
	// These indexers are responsible for generating secondary indices mapped to derived state.
	GetStateIndexers() []indexer.Indexer
}

OrchestratorPlugin defines the functionality that a plugin on the magma cloud side is expected to implement and provide. This interface is the formal surface area for integrating into and extending the magma orchestrator.

type OrchestratorPluginLoader

type OrchestratorPluginLoader interface {
	LoadPlugins() ([]OrchestratorPlugin, error)
}

OrchestratorPluginLoader wraps the loading of OrchestratorPlugin impls. Standard use case is to use the provided DefaultOrchestratorPluginLoader in this package - only create a new impl if you need to customize the loading process in some way (e.g. loading from a different directory).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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