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.
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package calculators provides concrete Calculator implementations for the estimation engine.
|
Package calculators provides concrete Calculator implementations for the estimation engine. |