estimation

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package estimation defines a pluggable migration estimation calculator.

Each part of the calculation is encapsulated in one specific Calculator, and calculation results are aggregated by the Engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculator

type Calculator interface {
	// Name returns the human-readable name of this calculator, used as the key in Engine results.
	Name() string
	// Keys returns the list of Param keys this calculator depends on.
	Keys() []string
	// Calculate runs the estimation using the provided params and returns an Estimation or an error.
	Calculate(params map[string]Param) (Estimation, error)
}

Calculator encapsulates one specific part of the estimation (e.g. "post migration troubleshooting", "storage migration").

type Engine

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

Engine orchestrates Calculator objects and aggregates their results

func NewEngine

func NewEngine() *Engine

NewEngine creates a new Engine with no calculators registered.

func (*Engine) Register

func (e *Engine) Register(c Calculator)

Register adds a Calculator to participate in the estimation. Calculators are executed in the order they are registered. Register panics if a calculator with the same Name() is already registered, as duplicate names would silently overwrite results in Run.

func (*Engine) Run

func (e *Engine) Run(inputs []Param) map[string]Estimation

Run executes all registered calculators against the provided params

type Estimation

type Estimation struct {
	Duration    *time.Duration // non-nil for point estimates
	MinDuration *time.Duration // non-nil for ranged estimates
	MaxDuration *time.Duration // non-nil for ranged estimates
	Reason      string
}

Estimation is the result of a Calculator run. Exactly one of {Duration} or {MinDuration, MaxDuration} will be non-nil. Use NewPointEstimation or NewRangedEstimation to construct — never build the struct directly.

func NewPointEstimation added in v0.9.0

func NewPointEstimation(d time.Duration, reason string) Estimation

NewPointEstimation constructs an Estimation for a single-value calculator result.

func NewRangedEstimation added in v0.9.0

func NewRangedEstimation(min, max time.Duration, reason string) Estimation

NewRangedEstimation constructs an Estimation for a calculator that returns a duration range. Panics if min > max, as that indicates a programming error in the calculator.

func (Estimation) IsRanged added in v0.9.0

func (e Estimation) IsRanged() bool

IsRanged reports whether this estimation carries a range rather than a point value. Both MinDuration and MaxDuration must be non-nil; NewRangedEstimation always sets them together.

type Param

type Param struct {
	Key   string      // Unique identifier (e.g., "network_bandwidth")
	Value interface{} // The actual value (e.g., 1000, "fast", 0.8)
}

Param represents an input for a Calculator (can be either user supplied or discovered)

Directories

Path Synopsis
Package calculators provides concrete Calculator implementations for the estimation engine.
Package calculators provides concrete Calculator implementations for the estimation engine.

Jump to

Keyboard shortcuts

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