Documentation ¶
Index ¶
- func GetFilterInstances(ctx model.ValueContext, routers []ServiceRouter, routeInfo *RouteInfo, ...) ([]model.Instance, *model.Cluster, *model.ServiceInfo, error)
- func GetRouteResultPool() *sync.Pool
- type FailOverType
- type Proxy
- type RouteGauge
- type RouteInfo
- func (r *RouteInfo) ClearValue()
- func (r *RouteInfo) Init(supplier plugin.Supplier)
- func (r *RouteInfo) IsRouterEnable(routerId int32) bool
- func (r *RouteInfo) SetIgnoreFilterOnlyOnEndChain(run bool)
- func (r *RouteInfo) SetRouterEnable(routerId int32, enable bool)
- func (r *RouteInfo) Validate() error
- type RouteResult
- type RouteStatus
- type RouterChain
- type RuleType
- type ServiceRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFilterInstances ¶
func GetFilterInstances(ctx model.ValueContext, routers []ServiceRouter, routeInfo *RouteInfo, serviceInstances model.ServiceInstances) ([]model.Instance, *model.Cluster, *model.ServiceInfo, error)
GetFilterInstances 根据服务路由链,过滤服务节点,返回对应的服务列表
Types ¶
type FailOverType ¶ added in v1.5.8
type FailOverType int32
const ( FailOverAll FailOverType FailOverNone )
type Proxy ¶
type Proxy struct { ServiceRouter // contains filtered or unexported fields }
Proxy is a proxy for service router
func (*Proxy) GetFilteredInstances ¶
func (p *Proxy) GetFilteredInstances( routeInfo *RouteInfo, serviceClusters model.ServiceClusters, withinCluster *model.Cluster) (*RouteResult, error)
GetFilteredInstances proxy ServiceRouter GetFilteredInstances
type RouteGauge ¶
type RouteGauge struct { model.EmptyInstanceGauge PluginID int32 SrcService model.ServiceKey RetCode model.ErrCode Cluster *model.Cluster ServiceInstances model.ServiceInstances RouteRuleType RuleType Status RouteStatus }
RouteGauge 路由调用统计数据
type RouteInfo ¶
type RouteInfo struct { // 源服务信息 SourceService model.ServiceMetadata // 源路由规则 SourceRouteRule model.ServiceRule // 目标服务信息 DestService model.ServiceMetadata // 目标路由规则 DestRouteRule model.ServiceRule // 在路由匹配过程中使用到的环境变量 EnvironmentVariables map[string]string // 全死全活路由插件,用于做路由兜底 // 路由链不为空,但是没有走filterOnly,则使用该路由插件来进行兜底 FilterOnlyRouter ServiceRouter // 是否开启元数据匹配不到时启用自定义匹配规则,仅用于dstMetadata路由插件 EnableFailOverDefaultMeta bool // 自定义匹配规则,仅当EnableFailOverDefaultMeta为true时生效 FailOverDefaultMeta model.FailOverDefaultMetaConfig // 金丝雀 Canary string // 进行匹配的规则类型,如规则路由有入规则和出规则之分 MatchRuleType RuleType // 规则路由失败降级类型 FailOverType *FailOverType // contains filtered or unexported fields }
RouteInfo 路由信息
func (*RouteInfo) IsRouterEnable ¶
IsRouterEnable 路由插件是否启用
func (*RouteInfo) SetIgnoreFilterOnlyOnEndChain ¶
SetIgnoreFilterOnlyOnEndChain 设置是否需要执行全死全活插件兜底
func (*RouteInfo) SetRouterEnable ¶
SetRouterEnable 设置是否启用路由插件
type RouteResult ¶
type RouteResult struct { // 根据路由规则重定向的目标服务,无需重定向则返回空 RedirectDestService *model.ServiceInfo // 根据路由规则过滤后的目标服务集群,假如重定向则列表为空 OutputCluster *model.Cluster // 路由结束状态 Status RouteStatus }
RouteResult 路由结果信息
func GetFilterCluster ¶
func GetFilterCluster(ctx model.ValueContext, routers []ServiceRouter, routeInfo *RouteInfo, svcClusters model.ServiceClusters) (*RouteResult, model.SDKError)
GetFilterCluster 根据服务理由链,过滤服务节点,返回对应的cluster
func PoolGetRouteResult ¶
func PoolGetRouteResult(ctx model.ValueContext) *RouteResult
PoolGetRouteResult 通过池子获取路由结果
type RouteStatus ¶
type RouteStatus int
RouteStatus 路由结束状态
const ( // Normal 正常结束 Normal RouteStatus = 0 // RecoverAll 全活 RecoverAll RouteStatus = 1 // DegradeToCity 降级到城市 DegradeToCity RouteStatus = 2 // DegradeToRegion 降级到大区 DegradeToRegion RouteStatus = 3 // DegradeToAll 降级到全部区域 DegradeToAll RouteStatus = 4 // DegradeToNotMatchCanary 降级到不完全匹配的金丝雀节点 DegradeToNotMatchCanary RouteStatus = 5 // DegradeToNotCanary 降级到非金丝雀节点 DegradeToNotCanary RouteStatus = 6 // DegradeToCanary 正常环境降级到金丝雀环境 DegradeToCanary RouteStatus = 7 // LimitedCanary 金丝雀环境发生异常 LimitedCanary RouteStatus = 8 // LimitedNoCanary 非金丝雀环境发生异常 LimitedNoCanary RouteStatus = 9 // DegradeToFilterOnly 降级使用filterOnly DegradeToFilterOnly RouteStatus = 10 )
type ServiceRouter ¶
type ServiceRouter interface { plugin.Plugin // Enable 当前是否需要启动该服务路由插件 Enable(routeInfo *RouteInfo, serviceClusters model.ServiceClusters) bool // GetFilteredInstances 获取通过规则过滤后的服务集群信息以及服务实例列表 // routeInfo: 路由信息,包括源和目标服务的实例及路由规则 // serviceClusters:服务级缓存信息 // withinCluster:上一个环节过滤的集群信息,本次路由需要继承 GetFilteredInstances( routeInfo *RouteInfo, serviceClusters model.ServiceClusters, withinCluster *model.Cluster) (*RouteResult, error) }
ServiceRouter 【扩展点接口】服务路由
Click to show internal directories.
Click to hide internal directories.