compositerouting

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package compositerouting contains deterministic model selection, without I/O, authentication or quota side effects. Admin and Gateway must use this planner.

Index

Constants

View Source
const (
	Priority   = "priority"
	Rules      = "rules"
	Difficulty = "difficulty"
)

Variables

This section is empty.

Functions

func AllowedHeader

func AllowedHeader(key string) bool

AllowedHeader excludes credentials and identity headers by construction.

Types

type Condition

type Condition struct {
	Type   string   `json:"type" yaml:"type" mapstructure:"type"`
	Key    string   `json:"key" yaml:"key" mapstructure:"key"`
	OpType string   `json:"op_type" yaml:"op_type" mapstructure:"op_type"`
	Values []string `json:"values" yaml:"values" mapstructure:"values"`
}

Condition deliberately supports only structured business metadata.

func (Condition) Validate

func (c Condition) Validate() error

type Config

type Config struct {
	Mode    string
	Primary string
	Default string
	Rules   []Rule
}

func (Config) Validate

func (c Config) Validate() error

type Input

type Input struct {
	Tags    map[string]string `json:"tags" yaml:"tags" mapstructure:"tags"`
	Headers map[string]string `json:"headers" yaml:"headers" mapstructure:"headers"`
}

type Plan

type Plan struct {
	Mode          string `json:"mode" yaml:"mode" mapstructure:"mode"`
	MatchedRuleID string `json:"matched_rule_id,omitempty" yaml:"matched_rule_id,omitempty" mapstructure:"matched_rule_id,omitempty"`
	Target        string `json:"target" yaml:"target" mapstructure:"target"`
	Reason        string `json:"reason" yaml:"reason" mapstructure:"reason"`
}

func Select

func Select(c Config, in Input) (Plan, error)

Select returns only the initial logical target. It never guesses availability, grants access or runs fallback; those belong to the authenticated executor.

type Rule

type Rule struct {
	ID           string      `json:"id" yaml:"id" mapstructure:"id"`
	Name         string      `json:"name" yaml:"name" mapstructure:"name"`
	Order        int         `json:"order" yaml:"order" mapstructure:"order"`
	Enabled      bool        `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	RelationType string      `json:"relation_type" yaml:"relation_type" mapstructure:"relation_type"`
	Conditions   []Condition `json:"conditions" yaml:"conditions" mapstructure:"conditions"`
	Target       string      `json:"target" yaml:"target" mapstructure:"target"`
}

Jump to

Keyboard shortcuts

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