Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph holds the adjacency list for Dijkstra shortest-path routing.
func Build ¶
func Build() *Graph
Build constructs the format graph from all registered backends.
Edges are filtered by backend.IsAvailable so that capabilities whose underlying binary is missing from $PATH never appear in the graph. This makes Dijkstra prefer cheap routes that can actually run instead of failing at exec time on a backend with the same nominal Cost.
func BuildFromBackends ¶ added in v0.1.1
BuildFromBackends constructs the format graph from the supplied backends. Exposed for testing and for callers that need to scope a graph to a subset of backends (e.g. plugin sandboxing).
func (*Graph) Find ¶
Find returns the lowest-cost route from src to dst using the default speed policy (max 4 hops, lossy allowed). Preserved for backward compatibility.
func (*Graph) FindWithPolicy ¶ added in v0.1.1
func (g *Graph) FindWithPolicy(src, dst string, policy RoutePolicy) (*Route, error)
FindWithPolicy returns the best route from src to dst according to the given RoutePolicy.
In ModeQuality the router maximises the route bottleneck quality (min(step.Quality)), then minimises total cost, then fewer hops. In ModeSpeed the router minimises total cost, then fewer hops.
MaxHops pruning is safe: dist is keyed by (format, hops), so a cheap but hop-exhausted path to an intermediate cannot suppress a costlier shorter path that can still reach the target.
type Route ¶
type Route struct {
Steps []Step
}
Route is an ordered sequence of steps from source to target format.
type RouteMode ¶ added in v0.1.1
type RouteMode int
RouteMode controls the routing optimisation objective.
type RoutePolicy ¶ added in v0.1.1
type RoutePolicy struct {
// Mode selects the optimisation objective: speed (lowest cost) or quality.
Mode RouteMode
// AvoidLossy skips edges marked as lossy when true.
AvoidLossy bool
// MaxHops constrains the maximum number of steps. Defaults to 4 when <= 0.
MaxHops int
}
RoutePolicy controls how the router selects and filters paths.
func DefaultPolicy ¶ added in v0.1.1
func DefaultPolicy() RoutePolicy
DefaultPolicy returns the backward-compatible default: speed mode, lossy allowed, max 4 hops.