routing

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package routing keeps model turns on durable task pins and moves new requests away from unavailable accounts. It does not retry or replay model work.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAvailableAccount = errors.New("no account can take this work")

ErrNoAvailableAccount means new work must wait for account capacity.

Functions

This section is empty.

Types

type AccountRoutingFactsSource

type AccountRoutingFactsSource interface {
	ReadAccountRoutingFacts() ([]accounts.AccountRoutingFact, error)
	RequestAccountRoutingFactsRefresh()
	ExcludeUnsupportedAccountModel(accountName store.AccountName, modelSlug string)
	RefreshAccountCredentialsAfterUnauthorized(accountName store.AccountName, rejected accounts.Credentials) error
}

AccountRoutingFactsSource isolates selection from account-home discovery.

type RouteDecision

type RouteDecision struct {
	AccountName store.AccountName
	DisplayName string
	Credentials accounts.Credentials
	// Assignment is empty when model work stays on its pinned account. Otherwise it
	// says, in product terms, which account now serves the work and why; the relay
	// logs it with the client that sent the request.
	Assignment string
}

RouteDecision carries credentials with the account identity so the relay cannot mix accounts.

type TaskRouter

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

TaskRouter reads every pin decision from SQLite so external repairs are visible without restart.

func CreateTaskRouter

func CreateTaskRouter(storeDatabase *store.StoreDatabase, accountFacts AccountRoutingFactsSource) *TaskRouter

CreateTaskRouter keeps allowance refresh ownership outside routing's single selection rule.

func (*TaskRouter) ReadAccountAvailability

func (router *TaskRouter) ReadAccountAvailability(modelSlug string) ([]accounts.AccountRoutingFact, map[store.AccountName]string, error)

ReadAccountAvailability uses the same rule as admission. An empty reason means the account can take new work for modelSlug.

func (*TaskRouter) ReportExhaustedTurn

func (router *TaskRouter) ReportExhaustedTurn(taskID store.TaskID, servedAccountName store.AccountName, resetsAt time.Time) string

ReportExhaustedTurn changes the account for the next client request; routing never resends work. It returns what happened to the task, for the proxy log.

func (*TaskRouter) ReportUnauthorizedTurn

func (router *TaskRouter) ReportUnauthorizedTurn(servedAccountName store.AccountName, rejectedCredentials accounts.Credentials)

ReportUnauthorizedTurn refreshes rejected credentials for the client's next request without replaying the failed turn.

func (*TaskRouter) ReportUnsupportedModel

func (router *TaskRouter) ReportUnsupportedModel(taskID store.TaskID, accountName store.AccountName, modelSlug string) bool

ReportUnsupportedModel prepares the next client request without resending rejected work.

func (*TaskRouter) RouteForModelCatalogue

func (router *TaskRouter) RouteForModelCatalogue() (RouteDecision, error)

RouteForModelCatalogue reads model metadata from the widest observed account catalogue. Inference allowance does not restrict this read, and task pins are untouched.

func (*TaskRouter) RouteForProviderTask

func (router *TaskRouter) RouteForProviderTask(taskID store.TaskID, workKind store.WorkKind, modelSlug string, provider accounts.Provider, parentTaskID store.TaskID) (RouteDecision, error)

RouteForProviderTask uses the same placement rule for each provider. A new fork first inherits its parent account when that account can serve this model.

func (*TaskRouter) RouteForTask

func (router *TaskRouter) RouteForTask(taskID store.TaskID, workKind store.WorkKind, modelSlug string) (RouteDecision, error)

RouteForTask keeps model work on its task's account while that account is available and gives new work the account with the most weekly allowance left. Work without a task ID gets the same choice as a new task but is never pinned. Metadata requests never create or move a pin.

Jump to

Keyboard shortcuts

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