mod_ai_route

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 13 Imported by: ? 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

Index

Constants

View Source
const (
	RouteTypeApikey = "apikey"
	RouteTypeEntity = "entity"
	RouteTypeGlobal = "global"
)

route table types

View Source
const ModAiRoute = "mod_ai_route"

Variables

This section is empty.

Functions

func ConfModAiRouteCheck

func ConfModAiRouteCheck(cfg *ConfModAiRoute, confRoot string) error

func ValidateRouteTable

func ValidateRouteTable(table *RouteTable) error

Types

type AiRouteData

type AiRouteData struct {
	Version                  string
	RouteRules               map[string]RouteTable
	ApikeyRouteTableBindings map[string][]string
}

AiRouteData is the runtime representation of the whole AI route data.

func AiRouteDataLoad

func AiRouteDataLoad(fileName string) (*AiRouteData, error)

type AiRouteDataFile

type AiRouteDataFile struct {
	Version                  string                    `json:"Version"`
	RouteRules               map[string]RouteTableFile `json:"route_rules"`
	ApikeyRouteTableBindings map[string][]string       `json:"ApikeyRouteTableBindings"`
}

AiRouteDataFile is the JSON DTO for the whole AI route data file.

func (*AiRouteDataFile) UnmarshalJSON

func (f *AiRouteDataFile) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both the canonical BFE field name "route_rules" and the ai-gateway-api InnerAPI field name "RouteRules". It also normalizes route table type values ("api_key" -> "apikey") for compatibility.

type AiRouteTable

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

func NewAiRouteTable

func NewAiRouteTable() *AiRouteTable

func (*AiRouteTable) Search

func (t *AiRouteTable) Search(apiKey string, req *bfe_basic.Request) *bfe_basic.AiRouteResult

func (*AiRouteTable) Update

func (t *AiRouteTable) Update(data *AiRouteData) error

type ConfModAiRoute

type ConfModAiRoute struct {
	Basic struct {
		RouteRulePath string // path for ai route rule
	}
	Log struct {
		OpenDebug bool
	}
}

func ConfLoad

func ConfLoad(filePath string, confRoot string) (*ConfModAiRoute, error)

func (*ConfModAiRoute) Check

func (cfg *ConfModAiRoute) Check(confRoot string) error

type ModuleAiRoute

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

func NewModuleAiRoute

func NewModuleAiRoute() *ModuleAiRoute

func (*ModuleAiRoute) Init

func (*ModuleAiRoute) Name

func (m *ModuleAiRoute) Name() string

type ModuleAiRouteState

type ModuleAiRouteState struct {
	ReqTotal     *metrics.Counter
	ReqHitApikey *metrics.Counter
	ReqHitEntity *metrics.Counter
	ReqHitGlobal *metrics.Counter
	ReqMiss      *metrics.Counter
	ReqFallback  *metrics.Counter
}

type RouteRule

type RouteRule struct {
	Name      string
	CondStr   string
	Cond      condition.Condition
	Targets   []bfe_basic.AiRouteTarget
	Fallbacks []bfe_basic.AiRouteFallback
}

RouteRule is the runtime representation of a route rule with compiled condition.

type RouteRuleFile

type RouteRuleFile struct {
	Name      string                      `json:"name"`
	Cond      string                      `json:"Cond"`
	Targets   []bfe_basic.AiRouteTarget   `json:"targets"`
	Fallbacks []bfe_basic.AiRouteFallback `json:"fallbacks"`
}

RouteRuleFile is the JSON DTO for a single route rule.

type RouteTable

type RouteTable struct {
	Type  string
	Owner string
	Rules []RouteRule
}

RouteTable is the runtime representation of a route table.

func (*RouteTable) Match

func (rt *RouteTable) Match(req *bfe_basic.Request) *RouteRule

type RouteTableFile

type RouteTableFile struct {
	Type  string          `json:"type"`
	Owner string          `json:"owner"`
	Rules []RouteRuleFile `json:"rules"`
}

RouteTableFile is the JSON DTO for a route table.

Jump to

Keyboard shortcuts

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