router

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveCanary

func ResolveCanary(rules []config.CanaryRuleConfig, defaultService string, req *http.Request) string

ResolveCanary 根据灰度规则决定目标服务名。 决策树: 1. 遍历 canary 规则,检查 match.headers 条件 2. Header 匹配且 weight > 0:按权重概率决定是否走灰度服务 3. Header 匹配且 weight == 0:100% 走灰度服务(纯 Header 匹配模式) 4. 无 Header 条件但 weight > 0:按权重概率对所有流量随机分流 5. 所有规则都不命中:返回默认服务

Types

type Router

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

Router 基于最长前缀匹配的路由器

func New

func New(routes []config.RouteConfig) *Router

New 创建路由器,路由按前缀长度降序排列以支持最长前缀匹配

func (*Router) Match

func (r *Router) Match(req *http.Request) (*config.RouteConfig, bool)

Match 对请求路径进行最长前缀匹配,返回匹配的路由配置

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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