Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertDuration(d *duration.Duration) (time.Duration, error)
- func ConvertServerErrorToRpcError(code uint32) model.ErrCode
- func GenServicesRevision(services []*apiservice.Service) string
- func GetEventType(respType apiservice.DiscoverResponse_DiscoverResponseType) model.EventType
- func GetMaxValidDuration(rule *apitraffic.Rule) (time.Duration, error)
- func GetProtoRequestType(event model.EventType) apiservice.DiscoverRequest_DiscoverRequestType
- func IsMatchAllValue(ruleMetaValue *apimodel.MatchString) bool
- func NewRoutingRuleInProto(resp *apiservice.DiscoverResponse) model.ServiceRule
- func ProtoDurationToMS(dur *duration.Duration) int64
- func ValidateMessage(eventKey *model.ServiceEventKey, message interface{}) error
- type CircuitBreakAssistant
- type DiscoverError
- type FaultDetectAssistant
- type InstSlice
- type InstanceInProto
- func (i *InstanceInProto) DeepClone() model.Instance
- func (i *InstanceInProto) GetActiveDetectStatus() model.ActiveDetectStatus
- func (i *InstanceInProto) GetCampus() string
- func (i *InstanceInProto) GetCircuitBreakerStatus() model.CircuitBreakerStatus
- func (i *InstanceInProto) GetExtendedData(pluginIndex int32) interface{}
- func (i *InstanceInProto) GetHost() string
- func (i *InstanceInProto) GetIDC() string
- func (i *InstanceInProto) GetId() string
- func (i *InstanceInProto) GetInstanceKey() model.InstanceKey
- func (i *InstanceInProto) GetInstanceLocalValue() local.InstanceLocalValue
- func (i *InstanceInProto) GetLogicSet() string
- func (i *InstanceInProto) GetNamespace() string
- func (i *InstanceInProto) GetPort() uint32
- func (i *InstanceInProto) GetPriority() uint32
- func (i *InstanceInProto) GetProtocol() string
- func (i *InstanceInProto) GetRegion() string
- func (i *InstanceInProto) GetRevision() string
- func (i *InstanceInProto) GetService() string
- func (i *InstanceInProto) GetSliceWindows(pluginIndex int32) []*metric.SliceWindow
- func (i *InstanceInProto) GetTtl() int64
- func (i *InstanceInProto) GetVersion() string
- func (i *InstanceInProto) GetVpcId() string
- func (i *InstanceInProto) GetWeight() int
- func (i *InstanceInProto) GetZone() string
- func (i *InstanceInProto) IsEnableHealthCheck() bool
- func (i *InstanceInProto) IsHealthy() bool
- func (i *InstanceInProto) IsIsolated() bool
- func (i *InstanceInProto) SetExtendedData(pluginIndex int32, data interface{})
- func (i *InstanceInProto) SetHealthy(status bool)
- func (i *InstanceInProto) SingleInstances() []model.Instance
- type RateLimitRuleCache
- type RateLimitingAssistant
- type RoutingAssistant
- type ServiceInstancesInProto
- func (s *ServiceInstancesInProto) GetGetTotalWeight() int
- func (s *ServiceInstancesInProto) GetHashValue() uint64
- func (s *ServiceInstancesInProto) GetInstance(instId string) model.Instance
- func (s *ServiceInstancesInProto) GetInstanceLocalValue(instId string) local.InstanceLocalValue
- func (s *ServiceInstancesInProto) GetInstanceLocalValueByEndpoint(host string, port uint32) local.InstanceLocalValue
- func (s *ServiceInstancesInProto) GetInstances() []model.Instance
- func (s *ServiceInstancesInProto) GetMetadata() map[string]string
- func (s *ServiceInstancesInProto) GetNamespace() string
- func (s *ServiceInstancesInProto) GetRevision() string
- func (s *ServiceInstancesInProto) GetService() string
- func (s *ServiceInstancesInProto) GetServiceClusters() model.ServiceClusters
- func (s *ServiceInstancesInProto) GetServiceLoadbalancer() loadbalancer.LoadBalancer
- func (s *ServiceInstancesInProto) GetServiceLocalValue() local.ServiceLocalValue
- func (s *ServiceInstancesInProto) GetServiceRouterChain() *servicerouter.RouterChain
- func (s *ServiceInstancesInProto) GetSvcIDSet() model.HashSet
- func (s *ServiceInstancesInProto) GetTotalWeight() int
- func (s *ServiceInstancesInProto) GetType() model.EventType
- func (s *ServiceInstancesInProto) IsCacheLoaded() bool
- func (s *ServiceInstancesInProto) IsInitialized() bool
- func (s *ServiceInstancesInProto) IsNotExists() bool
- func (s *ServiceInstancesInProto) ReloadServiceClusters()
- func (s *ServiceInstancesInProto) SetInitialized(isInitialized bool)
- type ServiceRuleAssistant
- type ServiceRuleInProto
- func (s *ServiceRuleInProto) GetHashValue() uint64
- func (s *ServiceRuleInProto) GetNamespace() string
- func (s *ServiceRuleInProto) GetRevision() string
- func (s *ServiceRuleInProto) GetRuleCache() model.RuleCache
- func (s *ServiceRuleInProto) GetService() string
- func (s *ServiceRuleInProto) GetType() model.EventType
- func (s *ServiceRuleInProto) GetValidateError() error
- func (s *ServiceRuleInProto) GetValue() interface{}
- func (s *ServiceRuleInProto) IsCacheLoaded() bool
- func (s *ServiceRuleInProto) IsInitialized() bool
- func (s *ServiceRuleInProto) IsNotExists() bool
- func (s *ServiceRuleInProto) ValidateAndBuildCache() error
- type ServicesProto
- func (s *ServicesProto) GetHashValue() uint64
- func (s *ServicesProto) GetNamespace() string
- func (s *ServicesProto) GetRevision() string
- func (s *ServicesProto) GetType() model.EventType
- func (s *ServicesProto) GetValue() []*model.ServiceKey
- func (s *ServicesProto) IsInitialized() bool
- func (s *ServicesProto) IsNotExists() bool
- type SvcPluginValues
Constants ¶
const ( // DefaultRejectRateLimiter 默认的reject限流器. DefaultRejectRateLimiter = "reject" // DefaultRateLimitReportAmountPresent 默认满足百分之80的请求后立刻限流上报. DefaultRateLimitReportAmountPresent = 80 // MaxRateLimitReportAmountPresent 最大实时上报百分比. MaxRateLimitReportAmountPresent = 100 // MinRateLimitReportAmountPresent 最小实时上报百分比. MinRateLimitReportAmountPresent = 0 )
const (
MatchAll = "*"
)
Variables ¶
var ServerErrorCodeTypeMap = map[uint32]model.ErrCode{ 200: model.ErrCodeSuccess, 400: model.ErrCodeInvalidRequest, 401: model.ErrCodeUnauthorized, 403: model.ErrCodeRequestLimit, 404: model.ErrCodeCmdbNotFound, 500: model.ErrCodeServerError, }
ServerErrorCodeTypeMap 获取server错误码类型的map
Functions ¶
func ConvertDuration ¶
ConvertDuration converts to golang duration and logs errors
func ConvertServerErrorToRpcError ¶
ConvertServerErrorToRpcError 将server返回码转化为服务调用的返回码
func GenServicesRevision ¶
func GenServicesRevision(services []*apiservice.Service) string
GenServicesRevision 修正服务.
func GetEventType ¶
func GetEventType(respType apiservice.DiscoverResponse_DiscoverResponseType) model.EventType
GetEventType 通过应答类型获取事件类型
func GetMaxValidDuration ¶
func GetMaxValidDuration(rule *apitraffic.Rule) (time.Duration, error)
GetMaxValidDuration 获取最大校验周期
func GetProtoRequestType ¶
func GetProtoRequestType(event model.EventType) apiservice.DiscoverRequest_DiscoverRequestType
GetProtoRequestType 通过事件类型获取请求类型
func IsMatchAllValue ¶ added in v1.2.0
func IsMatchAllValue(ruleMetaValue *apimodel.MatchString) bool
func NewRoutingRuleInProto ¶
func NewRoutingRuleInProto(resp *apiservice.DiscoverResponse) model.ServiceRule
NewRoutingRuleInProto 兼容接口, trpc-go依赖项
func ProtoDurationToMS ¶
ProtoDurationToMS pb时间段转毫秒
func ValidateMessage ¶
func ValidateMessage(eventKey *model.ServiceEventKey, message interface{}) error
ValidateMessage 校验消息 校验返回码为500或者消息类型不对
Types ¶
type CircuitBreakAssistant ¶
type CircuitBreakAssistant struct { }
func (*CircuitBreakAssistant) ParseRuleValue ¶
func (a *CircuitBreakAssistant) ParseRuleValue(resp *service_manage.DiscoverResponse) (proto.Message, string)
ParseRuleValue 解析出具体的规则值
func (*CircuitBreakAssistant) SetDefault ¶
func (a *CircuitBreakAssistant) SetDefault(message proto.Message)
SetDefault 设置默认值
type DiscoverError ¶
DiscoverError 从discover获取到了类似500的错误码
type FaultDetectAssistant ¶
type FaultDetectAssistant struct { }
func (*FaultDetectAssistant) ParseRuleValue ¶
func (a *FaultDetectAssistant) ParseRuleValue(resp *service_manage.DiscoverResponse) (proto.Message, string)
ParseRuleValue 解析出具体的规则值
func (*FaultDetectAssistant) SetDefault ¶
func (a *FaultDetectAssistant) SetDefault(message proto.Message)
SetDefault 设置默认值
type InstanceInProto ¶
type InstanceInProto struct { *apiservice.Instance // contains filtered or unexported fields }
InstanceInProto 通过proto定义来构造实例.
func NewInstanceInProto ¶
func NewInstanceInProto( instance *apiservice.Instance, svcKey *model.ServiceKey, localValue local.InstanceLocalValue, ) *InstanceInProto
NewInstanceInProto InstanceInProto的构造函数.
func (*InstanceInProto) DeepClone ¶ added in v1.5.0
func (i *InstanceInProto) DeepClone() model.Instance
DeepClone 获取实例设置的 TTL
func (*InstanceInProto) GetActiveDetectStatus ¶
func (i *InstanceInProto) GetActiveDetectStatus() model.ActiveDetectStatus
GetActiveDetectStatus instance dynamic weight.
func (*InstanceInProto) GetCampus ¶
func (i *InstanceInProto) GetCampus() string
GetCampus instance campus.
func (*InstanceInProto) GetCircuitBreakerStatus ¶
func (i *InstanceInProto) GetCircuitBreakerStatus() model.CircuitBreakerStatus
GetCircuitBreakerStatus instance dynamic weight.
func (*InstanceInProto) GetExtendedData ¶
func (i *InstanceInProto) GetExtendedData(pluginIndex int32) interface{}
GetExtendedData 获取插件数据.
func (*InstanceInProto) GetHost ¶
func (i *InstanceInProto) GetHost() string
GetHost 获取实例Host,,因为pb3的GetId返回wrappers.StringValue,所以改写.
func (*InstanceInProto) GetId ¶
func (i *InstanceInProto) GetId() string
GetId 获取实例ID,因为pb3的GetId返回wrappers.StringValue,所以改写.
func (*InstanceInProto) GetInstanceKey ¶
func (i *InstanceInProto) GetInstanceKey() model.InstanceKey
GetInstanceKey 获取实例的四元组标识.
func (*InstanceInProto) GetInstanceLocalValue ¶
func (i *InstanceInProto) GetInstanceLocalValue() local.InstanceLocalValue
GetInstanceLocalValue 获取本地可变状态值.
func (*InstanceInProto) GetLogicSet ¶
func (i *InstanceInProto) GetLogicSet() string
GetLogicSet 获取逻辑分区.
func (*InstanceInProto) GetNamespace ¶
func (i *InstanceInProto) GetNamespace() string
GetNamespace 命名空间.
func (*InstanceInProto) GetPort ¶
func (i *InstanceInProto) GetPort() uint32
GetPort 获取实例端口,因为pb3的GetPort返回wrappers.UInt32Value,所以改写.
func (*InstanceInProto) GetPriority ¶
func (i *InstanceInProto) GetPriority() uint32
GetPriority 获取实例优先级,因为pb3的GetPriority返回wrappers.UInt32Value,所以改写.
func (*InstanceInProto) GetProtocol ¶
func (i *InstanceInProto) GetProtocol() string
GetProtocol 获取实例协议,因为pb3的GetProtocol返回wrappers.UInt32Value,所以改写.
func (*InstanceInProto) GetRegion ¶
func (i *InstanceInProto) GetRegion() string
GetRegion instance region.
func (*InstanceInProto) GetRevision ¶
func (i *InstanceInProto) GetRevision() string
GetRevision 获取实例Revision,,因为pb3的GetRevision返回wrappers.StringValue,所以改写.
func (*InstanceInProto) GetSliceWindows ¶
func (i *InstanceInProto) GetSliceWindows(pluginIndex int32) []*metric.SliceWindow
GetSliceWindows 获取统计窗口.
func (*InstanceInProto) GetTtl ¶ added in v1.5.0
func (i *InstanceInProto) GetTtl() int64
GetTtl 获取实例设置的 TTL
func (*InstanceInProto) GetVersion ¶
func (i *InstanceInProto) GetVersion() string
GetVersion 获取实例版本,因为pb3的GetVersion返回wrappers.StringValue,所以改写.
func (*InstanceInProto) GetWeight ¶
func (i *InstanceInProto) GetWeight() int
GetWeight 获取实例权重,,因为pb3的GetWeight返回wrappers.UInt32Value,所以改写.
func (*InstanceInProto) IsEnableHealthCheck ¶
func (i *InstanceInProto) IsEnableHealthCheck() bool
IsEnableHealthCheck whether the health check enabled.
func (*InstanceInProto) IsHealthy ¶
func (i *InstanceInProto) IsHealthy() bool
IsHealthy instance health status.
func (*InstanceInProto) IsIsolated ¶
func (i *InstanceInProto) IsIsolated() bool
IsIsolated instance is isolated.
func (*InstanceInProto) SetExtendedData ¶
func (i *InstanceInProto) SetExtendedData(pluginIndex int32, data interface{})
SetExtendedData 设置插件数据.
func (*InstanceInProto) SetHealthy ¶ added in v1.5.0
func (i *InstanceInProto) SetHealthy(status bool)
SetHealthy set instance health status.
func (*InstanceInProto) SingleInstances ¶
func (i *InstanceInProto) SingleInstances() []model.Instance
SingleInstances 获取单个实例数组.
type RateLimitRuleCache ¶
RateLimitRuleCache 规则PB缓存
type RateLimitingAssistant ¶
type RateLimitingAssistant struct { }
RateLimitingAssistant 限流解析助手
func (*RateLimitingAssistant) ParseRuleValue ¶
func (r *RateLimitingAssistant) ParseRuleValue(resp *apiservice.DiscoverResponse) (proto.Message, string)
ParseRuleValue 解析出具体的规则值
func (*RateLimitingAssistant) SetDefault ¶
func (r *RateLimitingAssistant) SetDefault(message proto.Message)
SetDefault 设置默认值
type RoutingAssistant ¶
type RoutingAssistant struct { }
RoutingAssistant 路由规则解析助手
func (*RoutingAssistant) ParseRuleValue ¶
func (r *RoutingAssistant) ParseRuleValue(resp *apiservice.DiscoverResponse) (proto.Message, string)
ParseRuleValue 解析出具体的规则值
func (*RoutingAssistant) SetDefault ¶
func (r *RoutingAssistant) SetDefault(message proto.Message)
SetDefault 设置默认值
type ServiceInstancesInProto ¶
type ServiceInstancesInProto struct { CacheLoaded int32 // contains filtered or unexported fields }
ServiceInstancesInProto 通用的应答.
func NewServiceInstancesInProto ¶
func NewServiceInstancesInProto(resp *apiservice.DiscoverResponse, createLocalValue func(string) local.InstanceLocalValue, pluginValues *SvcPluginValues, svcLocalValue local.ServiceLocalValue, ) *ServiceInstancesInProto
NewServiceInstancesInProto ServiceInstancesResponse的构造函数.
func (*ServiceInstancesInProto) GetGetTotalWeight ¶
func (s *ServiceInstancesInProto) GetGetTotalWeight() int
GetGetTotalWeight 总权重.
func (*ServiceInstancesInProto) GetHashValue ¶ added in v1.4.0
func (s *ServiceInstancesInProto) GetHashValue() uint64
GetHashValue 获取服务的hash值
func (*ServiceInstancesInProto) GetInstance ¶
func (s *ServiceInstancesInProto) GetInstance(instId string) model.Instance
GetInstance 通过实例ID获取实例.
func (*ServiceInstancesInProto) GetInstanceLocalValue ¶
func (s *ServiceInstancesInProto) GetInstanceLocalValue(instId string) local.InstanceLocalValue
GetInstanceLocalValue 按实例获取本地可变状态值.
func (*ServiceInstancesInProto) GetInstanceLocalValueByEndpoint ¶
func (s *ServiceInstancesInProto) GetInstanceLocalValueByEndpoint(host string, port uint32) local.InstanceLocalValue
GetInstanceLocalValueByEndpoint .
func (*ServiceInstancesInProto) GetInstances ¶
func (s *ServiceInstancesInProto) GetInstances() []model.Instance
GetInstances 获取服务实例列表.
func (*ServiceInstancesInProto) GetMetadata ¶
func (s *ServiceInstancesInProto) GetMetadata() map[string]string
GetMetadata 获取元数据信息.
func (*ServiceInstancesInProto) GetNamespace ¶
func (s *ServiceInstancesInProto) GetNamespace() string
GetNamespace 获取名字空间.
func (*ServiceInstancesInProto) GetRevision ¶
func (s *ServiceInstancesInProto) GetRevision() string
GetRevision 获取服务的修订版本信息.
func (*ServiceInstancesInProto) GetService ¶
func (s *ServiceInstancesInProto) GetService() string
GetService 获取服务名.
func (*ServiceInstancesInProto) GetServiceClusters ¶
func (s *ServiceInstancesInProto) GetServiceClusters() model.ServiceClusters
GetServiceClusters 获取缓存索引.
func (*ServiceInstancesInProto) GetServiceLoadbalancer ¶
func (s *ServiceInstancesInProto) GetServiceLoadbalancer() loadbalancer.LoadBalancer
GetServiceLoadbalancer 获取服务级的负载均衡.
func (*ServiceInstancesInProto) GetServiceLocalValue ¶
func (s *ServiceInstancesInProto) GetServiceLocalValue() local.ServiceLocalValue
GetServiceLocalValue 获取服务的localvalue.
func (*ServiceInstancesInProto) GetServiceRouterChain ¶
func (s *ServiceInstancesInProto) GetServiceRouterChain() *servicerouter.RouterChain
GetServiceRouterChain 获取服务级的路由链.
func (*ServiceInstancesInProto) GetSvcIDSet ¶
func (s *ServiceInstancesInProto) GetSvcIDSet() model.HashSet
GetSvcIDSet 返回实例的id集合.
func (*ServiceInstancesInProto) GetTotalWeight ¶
func (s *ServiceInstancesInProto) GetTotalWeight() int
GetTotalWeight 获取所有实例总权重.
func (*ServiceInstancesInProto) GetType ¶
func (s *ServiceInstancesInProto) GetType() model.EventType
GetType 获取配置类型.
func (*ServiceInstancesInProto) IsCacheLoaded ¶
func (s *ServiceInstancesInProto) IsCacheLoaded() bool
IsCacheLoaded pb值是否为从缓存文件中加载的.
func (*ServiceInstancesInProto) IsInitialized ¶
func (s *ServiceInstancesInProto) IsInitialized() bool
IsInitialized 服务实例列表是否已经加载.
func (*ServiceInstancesInProto) IsNotExists ¶ added in v1.4.0
func (s *ServiceInstancesInProto) IsNotExists() bool
IsNotExists 服务是否存在
func (*ServiceInstancesInProto) ReloadServiceClusters ¶
func (s *ServiceInstancesInProto) ReloadServiceClusters()
ReloadServiceClusters 重建缓存索引.
func (*ServiceInstancesInProto) SetInitialized ¶
func (s *ServiceInstancesInProto) SetInitialized(isInitialized bool)
SetInitialized .设置服务实例列表是否已经加载.
type ServiceRuleAssistant ¶
type ServiceRuleAssistant interface { // ParseRuleValue 解析出具体的规则值 ParseRuleValue(resp *apiservice.DiscoverResponse) (proto.Message, string) // SetDefault 设置默认值 SetDefault(message proto.Message) // Validate 规则校验 Validate(message proto.Message, cache model.RuleCache) error }
ServiceRuleAssistant 助手接口.
type ServiceRuleInProto ¶
type ServiceRuleInProto struct { *model.ServiceKey CacheLoaded int32 // contains filtered or unexported fields }
ServiceRuleInProto 路由规则配置对象.
func NewServiceRuleInProto ¶
func NewServiceRuleInProto(resp *apiservice.DiscoverResponse) *ServiceRuleInProto
NewServiceRuleInProto 创建路由规则配置对象.
func NewServiceRuleInProtoWithInitializeStatus ¶ added in v1.4.0
func NewServiceRuleInProtoWithInitializeStatus(resp *apiservice.DiscoverResponse, initialized bool) *ServiceRuleInProto
NewServiceRuleInProtoWithInitializeStatus 创建路由规则配置对象.
func (*ServiceRuleInProto) GetHashValue ¶ added in v1.4.0
func (s *ServiceRuleInProto) GetHashValue() uint64
GetHashValue 获取数据的hash值
func (*ServiceRuleInProto) GetNamespace ¶
func (s *ServiceRuleInProto) GetNamespace() string
GetNamespace 获取命名空间.
func (*ServiceRuleInProto) GetRevision ¶
func (s *ServiceRuleInProto) GetRevision() string
GetRevision 缓存版本号,标识缓存是否更新.
func (*ServiceRuleInProto) GetRuleCache ¶
func (s *ServiceRuleInProto) GetRuleCache() model.RuleCache
GetRuleCache 获取规则缓存信息.
func (*ServiceRuleInProto) GetService ¶
func (s *ServiceRuleInProto) GetService() string
GetService 获取服务名.
func (*ServiceRuleInProto) GetType ¶
func (s *ServiceRuleInProto) GetType() model.EventType
GetType 获取规则类型.
func (*ServiceRuleInProto) GetValidateError ¶
func (s *ServiceRuleInProto) GetValidateError() error
GetValidateError 获取规则校验错误.
func (*ServiceRuleInProto) GetValue ¶
func (s *ServiceRuleInProto) GetValue() interface{}
GetValue 获取通用规则值.
func (*ServiceRuleInProto) IsCacheLoaded ¶
func (s *ServiceRuleInProto) IsCacheLoaded() bool
IsCacheLoaded pb的值是否从缓存文件中加载.
func (*ServiceRuleInProto) IsInitialized ¶
func (s *ServiceRuleInProto) IsInitialized() bool
IsInitialized 缓存是否已经初始化.
func (*ServiceRuleInProto) IsNotExists ¶ added in v1.4.0
func (s *ServiceRuleInProto) IsNotExists() bool
IsNotExists 规则是否存在
func (*ServiceRuleInProto) ValidateAndBuildCache ¶
func (s *ServiceRuleInProto) ValidateAndBuildCache() error
ValidateAndBuildCache 校验路由规则,以及构建正则表达式缓存.
type ServicesProto ¶
type ServicesProto struct { CacheLoaded int32 // contains filtered or unexported fields }
ServicesProto 批量服务.
func NewServicesProto ¶
func NewServicesProto(resp *apiservice.DiscoverResponse) *ServicesProto
NewServicesProto 新建服务proto.
func (*ServicesProto) GetHashValue ¶ added in v1.4.0
func (s *ServicesProto) GetHashValue() uint64
GetHashValue 获取数据的hash值
func (*ServicesProto) GetNamespace ¶
func (s *ServicesProto) GetNamespace() string
GetNamespace 获取命名空间
func (*ServicesProto) GetRevision ¶
func (s *ServicesProto) GetRevision() string
GetRevision 缓存版本号,标识缓存是否更新.
func (*ServicesProto) GetValue ¶
func (s *ServicesProto) GetValue() []*model.ServiceKey
GetValue 获取值.
func (*ServicesProto) IsInitialized ¶
func (s *ServicesProto) IsInitialized() bool
IsInitialized 缓存是否已经初始化.
func (*ServicesProto) IsNotExists ¶ added in v1.4.0
func (s *ServicesProto) IsNotExists() bool
IsNotExists 规则是否存在
type SvcPluginValues ¶
type SvcPluginValues struct { Routers *servicerouter.RouterChain Loadbalancer loadbalancer.LoadBalancer }
SvcPluginValues 服务级插件值.