router

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package router defines the routing engine that selects the best provider for a request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Provider provider.Provider
	Weight   float64 // for weighted strategies
	Priority int     // for priority strategies
	Healthy  bool
	Latency  time.Duration // recent average
	Cost     float64       // per-token cost
}

Candidate is a provider eligible for routing.

type Service

type Service interface {
	// Route selects a provider for the given request.
	Route(ctx context.Context, req *provider.CompletionRequest, providers []provider.Provider) (provider.Provider, error)
}

Service selects the best provider for a request.

func NewService

func NewService(strategy Strategy) Service

NewService creates a router Service from a Strategy.

type Strategy

type Strategy interface {
	Name() string
	Select(ctx context.Context, req *provider.CompletionRequest, candidates []Candidate) (*Candidate, error)
}

Strategy defines a routing algorithm.

Directories

Path Synopsis
Package strategies provides built-in routing strategies for Nexus.
Package strategies provides built-in routing strategies for Nexus.

Jump to

Keyboard shortcuts

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