Documentation
¶
Overview ¶
Package compare provides a virtual Backend that runs multiple backends in parallel, uses the first (master) backend's results as the response, and logs discrepancies between backends for testing and validation purposes.
Index ¶
- type Backend
- type CompareBackend
- func (c *CompareBackend) AbortSelfTest(ctx context.Context, devicePath string) error
- func (c *CompareBackend) CheckHealth(ctx context.Context, devicePath string) (bool, error)
- func (c *CompareBackend) Close() error
- func (c *CompareBackend) DisableSMART(ctx context.Context, devicePath string) error
- func (c *CompareBackend) DiscoverDevices(ctx context.Context) ([]DiscoveryResult, error)
- func (c *CompareBackend) EnableSMART(ctx context.Context, devicePath string) error
- func (c *CompareBackend) GetAvailableSelfTests(ctx context.Context, devicePath string) (*SelfTestInfo, error)
- func (c *CompareBackend) GetDeviceInfo(ctx context.Context, devicePath string) (map[string]any, error)
- func (c *CompareBackend) GetSMARTInfo(ctx context.Context, devicePath string) (*SMARTInfo, error)
- func (c *CompareBackend) Name() string
- func (c *CompareBackend) RunSelfTest(ctx context.Context, devicePath string, testType string) error
- func (c *CompareBackend) ScanDevices(ctx context.Context) ([]Device, error)
- type Device
- type DiscoveryBackend
- type DiscoveryResult
- type LogAdapter
- type Option
- type SMARTInfo
- type SelfTestInfo
- type SmartctlInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompareBackend ¶
type CompareBackend struct {
// contains filtered or unexported fields
}
CompareBackend is a virtual Backend that runs multiple backends in parallel, returns the first (master) backend's results, and logs discrepancies.
All backends execute concurrently so overall latency is determined by the slowest backend. Callers should set an appropriate timeout on the context to bound latency when using slow or unreliable secondaries.
func NewCompareBackend ¶
func NewCompareBackend(backends []Backend, opts ...Option) (*CompareBackend, error)
NewCompareBackend creates a CompareBackend with at least two backends. The first backend is the master; its results are always returned to the caller. Secondary backends run in parallel with the master; result mismatches are logged as warnings and secondary errors are logged as errors.
func (*CompareBackend) AbortSelfTest ¶
func (c *CompareBackend) AbortSelfTest(ctx context.Context, devicePath string) error
AbortSelfTest aborts a running self-test on all backends and returns the master's error.
func (*CompareBackend) CheckHealth ¶
CheckHealth checks device health from all backends and returns the master's result.
func (*CompareBackend) Close ¶
func (c *CompareBackend) Close() error
Close closes all backends, combining any errors into a single return value.
func (*CompareBackend) DisableSMART ¶
func (c *CompareBackend) DisableSMART(ctx context.Context, devicePath string) error
DisableSMART disables SMART on all backends and returns the master's error.
func (*CompareBackend) DiscoverDevices ¶
func (c *CompareBackend) DiscoverDevices(ctx context.Context) ([]DiscoveryResult, error)
DiscoverDevices discovers devices from all backends and returns the master's result. Backends that do not implement DiscoveryBackend fall back to ScanDevices + GetSMARTInfo.
func (*CompareBackend) EnableSMART ¶
func (c *CompareBackend) EnableSMART(ctx context.Context, devicePath string) error
EnableSMART enables SMART on all backends and returns the master's error.
func (*CompareBackend) GetAvailableSelfTests ¶
func (c *CompareBackend) GetAvailableSelfTests(ctx context.Context, devicePath string) (*SelfTestInfo, error)
GetAvailableSelfTests retrieves self-test info from all backends and returns the master's result.
func (*CompareBackend) GetDeviceInfo ¶
func (c *CompareBackend) GetDeviceInfo(ctx context.Context, devicePath string) (map[string]any, error)
GetDeviceInfo retrieves device info from all backends and returns the master's result.
func (*CompareBackend) GetSMARTInfo ¶
GetSMARTInfo retrieves SMART information from all backends and returns the master's result.
func (*CompareBackend) RunSelfTest ¶
RunSelfTest runs a self-test on all backends and returns the master's error.
func (*CompareBackend) ScanDevices ¶
func (c *CompareBackend) ScanDevices(ctx context.Context) ([]Device, error)
ScanDevices scans for storage devices from all backends and returns the master's result.
type DiscoveryBackend ¶
type DiscoveryBackend = smtypes.DiscoveryBackend
Shared interface aliases keep the compare backend decoupled from the root package.
type DiscoveryResult ¶
type DiscoveryResult = smtypes.DiscoveryResult
Shared type aliases reuse the module's SMART domain model in the compare backend.
type LogAdapter ¶
type LogAdapter = smtypes.LogAdapter
Shared interface aliases keep the compare backend decoupled from the root package.
type Option ¶
type Option func(*CompareBackend)
Option configures a CompareBackend.
func WithLogHandler ¶
func WithLogHandler(logger LogAdapter) Option
WithLogHandler sets a custom LogAdapter for the compare backend.
func WithSlogHandler ¶
WithSlogHandler sets a custom slog.Logger for the compare backend.
func WithTLogHandler ¶
WithTLogHandler sets a custom tlog.Logger for the compare backend.
type SelfTestInfo ¶
type SelfTestInfo = smtypes.SelfTestInfo
Shared type aliases reuse the module's SMART domain model in the compare backend.
type SmartctlInfo ¶
type SmartctlInfo = smtypes.SmartctlInfo
Shared type aliases reuse the module's SMART domain model in the compare backend.