pb

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRejectRateLimiter 默认的reject限流器.
	DefaultRejectRateLimiter = "reject"
	// DefaultRateLimitReportAmountPresent 默认满足百分之80的请求后立刻限流上报.
	DefaultRateLimitReportAmountPresent = 80
	// MaxRateLimitReportAmountPresent 最大实时上报百分比.
	MaxRateLimitReportAmountPresent = 100
	// MinRateLimitReportAmountPresent 最小实时上报百分比.
	MinRateLimitReportAmountPresent = 0
)
View Source
const (
	MatchAll = "*"
)

Variables

ServerErrorCodeTypeMap 获取server错误码类型的map

Functions

func ConvertDuration

func ConvertDuration(d *duration.Duration) (time.Duration, error)

ConvertDuration converts to golang duration and logs errors

func ConvertServerErrorToRpcError

func ConvertServerErrorToRpcError(code uint32) model.ErrCode

ConvertServerErrorToRpcError 将server返回码转化为服务调用的返回码

func GenServicesRevision

func GenServicesRevision(services []*apiservice.Service) string

GenServicesRevision 修正服务.

func GetEventType

GetEventType 通过应答类型获取事件类型

func GetMaxValidDuration

func GetMaxValidDuration(rule *apitraffic.Rule) (time.Duration, error)

GetMaxValidDuration 获取最大校验周期

func GetProtoRequestType

GetProtoRequestType 通过事件类型获取请求类型

func IsMatchAllValue

func IsMatchAllValue(ruleMetaValue *apimodel.MatchString) bool

func NewRoutingRuleInProto

func NewRoutingRuleInProto(resp *apiservice.DiscoverResponse) model.ServiceRule

NewRoutingRuleInProto 兼容接口, trpc-go依赖项

func ProtoDurationToMS

func ProtoDurationToMS(dur *duration.Duration) int64

ProtoDurationToMS pb时间段转毫秒

func ValidateMessage

func ValidateMessage(eventKey *model.ServiceEventKey, message interface{}) error

ValidateMessage 校验消息 校验返回码为500或者消息类型不对

Types

type DiscoverError

type DiscoverError struct {
	Code    int32
	Message string
}

DiscoverError 从discover获取到了类似500的错误码

func (*DiscoverError) Error

func (d *DiscoverError) Error() string

Error 将错误信息转化为string

type InstSlice

type InstSlice []*apiservice.Instance

InstSlice instSlice,[]*namingpb.Instance的别名.

func (InstSlice) Len

func (is InstSlice) Len() int

Len instSlice的长度.

func (InstSlice) Less

func (is InstSlice) Less(i, j int) bool

Less instSlice元素比较方法.

func (InstSlice) Swap

func (is InstSlice) Swap(i, j int)

Swap instSlice交换元素方法.

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

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) GetIDC

func (i *InstanceInProto) GetIDC() string

GetIDC instance idc.

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) GetService

func (i *InstanceInProto) GetService() string

GetService 服务名.

func (*InstanceInProto) GetSliceWindows

func (i *InstanceInProto) GetSliceWindows(pluginIndex int32) []*metric.SliceWindow

GetSliceWindows 获取统计窗口.

func (*InstanceInProto) GetTtl

func (i *InstanceInProto) GetTtl() int64

GetTtl 获取实例设置的 TTL

func (*InstanceInProto) GetVersion

func (i *InstanceInProto) GetVersion() string

GetVersion 获取实例版本,因为pb3的GetVersion返回wrappers.StringValue,所以改写.

func (*InstanceInProto) GetVpcId

func (i *InstanceInProto) GetVpcId() string

GetVpcId 获取实例的vpcId.

func (*InstanceInProto) GetWeight

func (i *InstanceInProto) GetWeight() int

GetWeight 获取实例权重,,因为pb3的GetWeight返回wrappers.UInt32Value,所以改写.

func (*InstanceInProto) GetZone

func (i *InstanceInProto) GetZone() string

GetZone instance zone.

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

func (i *InstanceInProto) SetHealthy(status bool)

SetHealthy set instance health status.

func (*InstanceInProto) SingleInstances

func (i *InstanceInProto) SingleInstances() []model.Instance

SingleInstances 获取单个实例数组.

type RateLimitRuleCache

type RateLimitRuleCache struct {
	MaxDuration time.Duration
}

RateLimitRuleCache 规则PB缓存

type RateLimitingAssistant

type RateLimitingAssistant struct {
}

RateLimitingAssistant 限流解析助手

func (*RateLimitingAssistant) ParseRuleValue

ParseRuleValue 解析出具体的规则值

func (*RateLimitingAssistant) SetDefault

func (r *RateLimitingAssistant) SetDefault(message proto.Message)

SetDefault 设置默认值

func (*RateLimitingAssistant) Validate

func (r *RateLimitingAssistant) Validate(message proto.Message, ruleCache model.RuleCache) error

Validate 规则校验

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 设置默认值

func (*RoutingAssistant) Validate

func (r *RoutingAssistant) Validate(message proto.Message, ruleCache model.RuleCache) error

Validate 规则校验

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

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) 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

GetType 获取配置类型.

func (*ServiceInstancesInProto) IsCacheLoaded

func (s *ServiceInstancesInProto) IsCacheLoaded() bool

IsCacheLoaded pb值是否为从缓存文件中加载的.

func (*ServiceInstancesInProto) IsInitialized

func (s *ServiceInstancesInProto) IsInitialized() bool

IsInitialized 服务实例列表是否已经加载.

func (*ServiceInstancesInProto) IsNotExists

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

func NewServiceRuleInProtoWithInitializeStatus(resp *apiservice.DiscoverResponse, initialized bool) *ServiceRuleInProto

NewServiceRuleInProtoWithInitializeStatus 创建路由规则配置对象.

func (*ServiceRuleInProto) GetHashValue

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

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

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) GetType

func (s *ServicesProto) GetType() model.EventType

GetType 获取事件类型.

func (*ServicesProto) GetValue

func (s *ServicesProto) GetValue() []*model.ServiceKey

GetValue 获取值.

func (*ServicesProto) IsInitialized

func (s *ServicesProto) IsInitialized() bool

IsInitialized 缓存是否已经初始化.

func (*ServicesProto) IsNotExists

func (s *ServicesProto) IsNotExists() bool

IsNotExists 规则是否存在

type SvcPluginValues

type SvcPluginValues struct {
	Routers      *servicerouter.RouterChain
	Loadbalancer loadbalancer.LoadBalancer
}

SvcPluginValues 服务级插件值.

Directories

Path Synopsis
v2

Jump to

Keyboard shortcuts

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