plugin

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package plugin provides the core plugin interface and registry for benchmark tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List() []string

List returns all registered plugin names

func MarshalParams

func MarshalParams(p Params) ([]byte, error)

MarshalParams converts Params to JSON

func Register

func Register(plugin TestPlugin) error

Register adds a plugin to the global registry

Types

type Info

type Info struct {
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Category    string       `json:"category"`
	Metrics     []MetricInfo `json:"metrics"`
	Parameters  []ParamInfo  `json:"parameters"`
}

Info provides metadata about a plugin

func GetPluginInfo

func GetPluginInfo() []Info

GetPluginInfo returns detailed information about all registered plugins

type MetricInfo

type MetricInfo struct {
	Name        string     `json:"name"`
	Type        MetricType `json:"type"`
	Unit        string     `json:"unit"`
	Description string     `json:"description"`
}

MetricInfo provides metadata about a metric

type MetricType

type MetricType string

MetricType represents the type of a metric

const (
	MetricTypeGauge      MetricType = "gauge"      // Point-in-time value
	MetricTypeCounter    MetricType = "counter"    // Cumulative value
	MetricTypeThroughput MetricType = "throughput" // Rate per second
	MetricTypeLatency    MetricType = "latency"    // Time measurement
)

MetricType constants define the different types of metrics that can be collected.

type ParamInfo

type ParamInfo struct {
	Name        string      `json:"name"`
	Type        string      `json:"type"`
	Default     interface{} `json:"default"`
	Description string      `json:"description"`
	Required    bool        `json:"required"`
}

ParamInfo describes a parameter that a plugin accepts

type Params

type Params struct {
	// Common parameters
	Duration time.Duration          `json:"duration"`
	Threads  int                    `json:"threads"`
	Config   map[string]interface{} `json:"config"`
}

Params represents parameters passed to a test plugin

func UnmarshalParams

func UnmarshalParams(data []byte) (Params, error)

UnmarshalParams converts JSON to Params

type Registry

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

Registry manages all available test plugins

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry

func (*Registry) Clear

func (r *Registry) Clear()

Clear removes all plugins from the registry

func (*Registry) Get

func (r *Registry) Get(name string) (TestPlugin, error)

Get retrieves a plugin by name

func (*Registry) GetAll

func (r *Registry) GetAll() map[string]TestPlugin

GetAll returns all registered plugins

func (*Registry) GetPluginInfo

func (r *Registry) GetPluginInfo() []Info

GetPluginInfo returns detailed information about all plugins

func (*Registry) List

func (r *Registry) List() []string

List returns all registered plugin names in sorted order

func (*Registry) Register

func (r *Registry) Register(plugin TestPlugin) error

Register adds a plugin to the registry

type Result

type Result struct {
	// Timing information
	StartTime time.Time     `json:"start_time"`
	EndTime   time.Time     `json:"end_time"`
	Duration  time.Duration `json:"duration"`

	// Test results
	Success bool                   `json:"success"`
	Error   string                 `json:"error,omitempty"`
	Metrics map[string]float64     `json:"metrics"`
	Details map[string]interface{} `json:"details,omitempty"`

	// Raw output
	Stdout string `json:"stdout,omitempty"`
	Stderr string `json:"stderr,omitempty"`
}

Result represents the output of a test plugin

type TestPlugin

type TestPlugin interface {
	// Name returns the unique name of the plugin
	Name() string

	// Description returns a human-readable description
	Description() string

	// Run executes the test with the given parameters
	Run(ctx context.Context, params Params) (Result, error)

	// ValidateParams checks if the parameters are valid for this plugin
	ValidateParams(params Params) error

	// DefaultParams returns the default parameters for this plugin
	DefaultParams() Params
}

TestPlugin is the interface that all test plugins must implement

func Get

func Get(name string) (TestPlugin, error)

Get retrieves a plugin from the global registry

Directories

Path Synopsis
Package cpu provides CPU benchmarking and stress testing functionality.
Package cpu provides CPU benchmarking and stress testing functionality.
Package memory provides memory stress testing and bandwidth measurement plugins for FIRE.
Package memory provides memory stress testing and bandwidth measurement plugins for FIRE.

Jump to

Keyboard shortcuts

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