pluginmanager

package
v0.0.0-...-d6bf0fb Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BinPath       = "./plugins/"
	SyntestPrefix = "test-"
)
View Source
const (
	MarksGauge    = "syntheticheart_marks_total"
	MaxMarksGauge = "syntheticheart_max_marks_total"
	TimeGauge     = "syntheticheart_runtime_ns"
	CustomGauge   = "syntheticheart_%s" // Gauge name
)

Variables

View Source
var SynTestCmdMap = map[string][]string{}
View Source
var SynTestNameMap = map[string]plugin.Plugin{}

Functions

func RegisterSynTestPlugin

func RegisterSynTestPlugin(pluginName string, cmd []string)

func StartPlugin

func StartPlugin(ctx context.Context, pluginId string, pluginName string, plugin RunnablePlugin, restartPolicy common.PluginRestartPolicy, sm StateMap)

Starts a plugin and manages the lifecycle (i.e. syntest)

Types

type Config

type Config struct {
	NodeName         string               `yaml:"nodeName"`
	SyncFrequency    time.Duration        `yaml:"syncFrequency"`
	GracePeriod      time.Duration        `yaml:"gracePeriod"`
	PrometheusConfig PrometheusConfig     `yaml:"prometheus"`
	StoreConfig      StorageConfig        `yaml:"storage"`
	PrintPluginLogs  PrintPluginLogOption `yaml:"printPluginLogs"`
	Etc              map[string]string    `yaml:"etc"`
	DebugMode        bool                 `yaml:"debugMode"`
}

type ExtStorageHandler

type ExtStorageHandler struct {
	Store storage.SynHeartStore
	// contains filtered or unexported fields
}

ExtStorageHandler manages all communication with external storage (redis)

func NewExtStorageHandler

func NewExtStorageHandler(agentId string, config StorageConfig, logger hclog.Logger) (ExtStorageHandler, error)

func (*ExtStorageHandler) ReSyncTestRun

func (esh *ExtStorageHandler) ReSyncTestRun(ctx context.Context, b *utils.Broadcaster) error

func (*ExtStorageHandler) RegisterTestToImport

func (esh *ExtStorageHandler) RegisterTestToImport(testName string)

func (*ExtStorageHandler) Run

func (esh *ExtStorageHandler) Run(ctx context.Context, broadcaster *utils.Broadcaster, sm *StateMap) error

func (*ExtStorageHandler) UnregisterTestToImport

func (esh *ExtStorageHandler) UnregisterTestToImport(testName string)

type PluginManager

type PluginManager struct {
	AgentId string

	SyntheticTests map[string]SyntheticTest
	// contains filtered or unexported fields
}

PluginManager manages all the different plugins It manages the lifecycle and the communication between them

func NewPluginManager

func NewPluginManager(configPath string) (*PluginManager, error)

Creates a new plugin manager

func (*PluginManager) Exit

func (pm *PluginManager) Exit(err error)

func (*PluginManager) Start

func (pm *PluginManager) Start(ctx context.Context) error

func (*PluginManager) StartPrometheus

func (pm *PluginManager) StartPrometheus(ctx context.Context, wg *sync.WaitGroup, configChange chan struct{}) context.CancelFunc

Starts prometheus server, returns a cancel function

func (*PluginManager) StartTestRoutine

func (pm *PluginManager) StartTestRoutine(ctx context.Context, s SyntheticTest)

Starts the synthetic test go routine (that manages the plugin)

func (*PluginManager) StopAndDeleteSynTest

func (pm *PluginManager) StopAndDeleteSynTest(ctx context.Context, testName string)

func (*PluginManager) SyncConfig

func (pm *PluginManager) SyncConfig(ctx context.Context) (bool, error)

func (*PluginManager) SyncSyntestPluginConfigs

func (pm *PluginManager) SyncSyntestPluginConfigs(ctx context.Context) (bool, error)

checks external storage for new syntest config or change in existing ones and then start/stops appropriate plugins

type PrintPluginLogOption

type PrintPluginLogOption string
const (
	LogOnFail PrintPluginLogOption = "onFail"
	LogNever  PrintPluginLogOption = "never"
	LogAlways PrintPluginLogOption = "always"
)

type PrometheusConfig

type PrometheusConfig struct {
	ServerAddress     string `yaml:"address"`
	Push              bool   `yaml:"push"`
	PrometheusPushUrl string `yaml:"pushUrl"`
}

type PrometheusExporter

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

func NewPrometheusExporter

func NewPrometheusExporter(logger hclog.Logger, config PrometheusConfig, agentId string, debugMode bool) PrometheusExporter

func (*PrometheusExporter) Cleanup

func (p *PrometheusExporter) Cleanup()

func (*PrometheusExporter) ExportTestRunMetrics

func (p *PrometheusExporter) ExportTestRunMetrics(res proto.TestRun) error

func (*PrometheusExporter) Run

func (p *PrometheusExporter) Run(ctx context.Context, broadcaster *utils.Broadcaster, configChange chan struct{})

type RunnablePlugin

type RunnablePlugin interface {
	Run(ctx context.Context) error
}

type State

type State struct {
	PluginStates map[string]common.PluginState `json:"plugins"`
}

type StateMap

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

Stores Plugin State (i.e. whether they are running, no. of restarts etc.)

func NewStateMap

func NewStateMap(logger hclog.Logger) StateMap

func (*StateMap) DeletePluginState

func (sm *StateMap) DeletePluginState(id string)

func (*StateMap) GetAgentStatus

func (sm *StateMap) GetAgentStatus() common.AgentStatus

returns list of plugins that its meant to run

func (*StateMap) GetAllPluginState

func (sm *StateMap) GetAllPluginState() State

func (*StateMap) GetPluginState

func (sm *StateMap) GetPluginState(id string) (common.PluginState, error)

func (*StateMap) SetPluginState

func (sm *StateMap) SetPluginState(id string, state common.PluginState)

func (*StateMap) SetPluginStatus

func (sm *StateMap) SetPluginStatus(id string, status common.RoutineStatus)

type StorageConfig

type StorageConfig struct {
	Type       string        `yaml:"type"`
	BufferSize int           `yaml:"bufferSize"`
	Address    string        `yaml:"address"`
	ExportRate time.Duration `yaml:"exportRate"`
	PollRate   time.Duration `yaml:"pollRate"`
}

type SynTestRoutine

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

SynTestRoutine handles communication between the synthetic heart binary and a synthetic test plugin

func (*SynTestRoutine) Run

func (str *SynTestRoutine) Run(ctx context.Context) error

type SyntheticTest

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

Jump to

Keyboard shortcuts

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