Documentation ¶
Index ¶
- Constants
- Variables
- func CurrentMicrosecond() int64
- func CurrentMillisecond() int64
- func CurrentNanosecond() int64
- func EnsureAndVerifyDir(dir string) error
- func ErrCodeToString(ec ErrCode) string
- func GetIP(name string) (string, error)
- func HashMessage(message proto.Message) uint64
- func HashStr(key string) (uint64, error)
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsInstanceAvailable(instance Instance) bool
- func IsNearbyMatch(dst, src string) bool
- func IsServerException(retCode uint32) bool
- func IsSuccessResultCode(retCode uint32) bool
- func ParseMilliSeconds(v int64) int64
- func PathExist(path string) bool
- func PoolGetByteBuffer(size int) *bytes.Buffer
- func PoolGetStringSlice(size int) []string
- func PoolPutByteBuffer(size int, buf *bytes.Buffer)
- func PoolPutStringSlice(size int, slice []string)
- func ReplaceHomeVar(path string) string
- func SortMap(values map[string]string, keys []string) ([]string, int)
- func TimestampMsToUtcIso8601(timestamp int64) string
- func ToDurationPtr(v time.Duration) *time.Duration
- func ToMilliSeconds(v time.Duration) int64
- func ToNetIP(val uint32) net.IP
- func ToStringService(svc ServiceMetadata, printMeta bool) string
- func ValidMetircType(t MetricType) bool
- func WithQuotaFutureDeadline(deadline time.Time) quotaFutureOption
- func WithQuotaFutureHooks(hooks ...finishHook) quotaFutureOption
- func WithQuotaFutureQuotaAllocator(allocator QuotaAllocator) quotaFutureOption
- func WithQuotaFutureReq(req *QuotaRequestImpl) quotaFutureOption
- func WithQuotaFutureResp(resp *QuotaResponse) quotaFutureOption
- type APICallKey
- type APICallResult
- func (a *APICallResult) GetAPI() ApiOperation
- func (a *APICallResult) GetDelay() *time.Duration
- func (a *APICallResult) GetDelayRange() ApiDelayRange
- func (a *APICallResult) GetRetCode() *int32
- func (a *APICallResult) GetRetCodeValue() int32
- func (a *APICallResult) GetRetStatus() RetStatus
- func (a *APICallResult) SetDelay(delay time.Duration)
- func (a *APICallResult) SetFail(retCode ErrCode, delay time.Duration)
- func (a *APICallResult) SetSuccess(delay time.Duration)
- type ActiveDetectStatus
- type ApiDelayRange
- type ApiOperation
- type CacheValueQuery
- type ChangeType
- type CircuitBreakGauge
- type CircuitBreakerStatus
- type Cluster
- func (c *Cluster) AddMetadata(key string, value string) bool
- func (c *Cluster) ClearClusterValue()
- func (c *Cluster) GetAllInstances() ([]Instance, int)
- func (c *Cluster) GetClusterValue() *ClusterValue
- func (c *Cluster) GetClusters() ServiceClusters
- func (c *Cluster) GetContainMetaKeyClusterValue() *ClusterValue
- func (c *Cluster) GetContainNotMatchMetaKeyClusterValue() *ClusterValue
- func (c *Cluster) GetInstances() ([]Instance, int)
- func (c *Cluster) GetInstancesWhenSkipRouteFilter() ([]Instance, int)
- func (c *Cluster) GetNotContainMetaKeyClusterValue() *ClusterValue
- func (c *Cluster) MatchContainMetaKeyData(instance Instance) bool
- func (c *Cluster) PoolPut()
- func (c *Cluster) ReloadComposeMetaValue()
- func (c *Cluster) RuleAddMetadata(key string, value string, composedValue string) bool
- func (c *Cluster) SetReuse(value bool)
- func (c Cluster) String() string
- type ClusterEventHandler
- type ClusterKey
- type ClusterOwner
- type ClusterValue
- func (v *ClusterValue) Count() int
- func (v *ClusterValue) GetAllInstanceSet() *InstanceSet
- func (v *ClusterValue) GetInstancesSet(hasLimitedInstances bool, includeHalfOpen bool) *InstanceSet
- func (v *ClusterValue) GetInstancesSetWhenSkipRouteFilter(hasLimitedInstances bool, includeHalfOpen bool) *InstanceSet
- func (v ClusterValue) String() string
- type ConfigFile
- type ConfigFileChangeEvent
- type ConfigFileMetadata
- type ConfigMode
- type ControlParam
- type DefaultConfigFileMetadata
- type DefaultServiceInstances
- func (d *DefaultServiceInstances) GetInstance(id string) Instance
- func (d *DefaultServiceInstances) GetInstances() []Instance
- func (d *DefaultServiceInstances) GetMetadata() map[string]string
- func (d *DefaultServiceInstances) GetNamespace() string
- func (d *DefaultServiceInstances) GetRevision() string
- func (d *DefaultServiceInstances) GetService() string
- func (d *DefaultServiceInstances) GetServiceClusters() ServiceClusters
- func (d *DefaultServiceInstances) GetTotalWeight() int
- func (d *DefaultServiceInstances) GetType() EventType
- func (d *DefaultServiceInstances) IsCacheLoaded() bool
- func (d *DefaultServiceInstances) IsInitialized() bool
- func (d *DefaultServiceInstances) ReloadServiceClusters()
- type EmptyInstanceGauge
- func (e EmptyInstanceGauge) GetAPI() ApiOperation
- func (e EmptyInstanceGauge) GetCalledInstance() Instance
- func (e EmptyInstanceGauge) GetCircuitBreakerStatus() CircuitBreakerStatus
- func (e EmptyInstanceGauge) GetDelay() *time.Duration
- func (e EmptyInstanceGauge) GetDelayRange() ApiDelayRange
- func (e EmptyInstanceGauge) GetHost() string
- func (e EmptyInstanceGauge) GetNamespace() string
- func (e EmptyInstanceGauge) GetPort() int
- func (e EmptyInstanceGauge) GetRetCodeValue() int32
- func (e EmptyInstanceGauge) GetRetStatus() RetStatus
- func (e EmptyInstanceGauge) GetService() string
- func (e EmptyInstanceGauge) Validate() error
- type Engine
- type ErrCode
- type ErrCodeType
- type EventType
- type ExtendedSelector
- type FailOverDefaultMetaConfig
- type FailOverHandler
- type FilteredInstanceCounter
- func (f *FilteredInstanceCounter) AddIsolatedInstances(n int32)
- func (f *FilteredInstanceCounter) AddRouteFilteredInstances(routerName string, n int32)
- func (f *FilteredInstanceCounter) AddUnhealthyInstances(n int32)
- func (f *FilteredInstanceCounter) GetIsolatedInstances() int32
- func (f *FilteredInstanceCounter) GetUnhealthyInstances() int32
- type GetAllInstancesRequest
- func (g *GetAllInstancesRequest) GetMetadata() map[string]string
- func (g *GetAllInstancesRequest) GetNamespace() string
- func (g *GetAllInstancesRequest) GetResponse() *InstancesResponse
- func (g *GetAllInstancesRequest) GetRetryCountPtr() *int
- func (g *GetAllInstancesRequest) GetService() string
- func (g *GetAllInstancesRequest) GetTimeoutPtr() *time.Duration
- func (g *GetAllInstancesRequest) SetRetryCount(retryCount int)
- func (g *GetAllInstancesRequest) SetTimeout(duration time.Duration)
- func (g *GetAllInstancesRequest) Validate() error
- type GetInstancesRequest
- func (g *GetInstancesRequest) GetCanary() string
- func (g *GetInstancesRequest) GetMetadata() map[string]string
- func (g *GetInstancesRequest) GetNamespace() string
- func (g *GetInstancesRequest) GetResponse() *InstancesResponse
- func (g *GetInstancesRequest) GetRetryCountPtr() *int
- func (g *GetInstancesRequest) GetService() string
- func (g *GetInstancesRequest) GetTimeoutPtr() *time.Duration
- func (g *GetInstancesRequest) SetCanary(canary string)
- func (g *GetInstancesRequest) SetRetryCount(retryCount int)
- func (g *GetInstancesRequest) SetTimeout(duration time.Duration)
- func (g *GetInstancesRequest) Validate() error
- type GetMeshConfigRequest
- func (g *GetMeshConfigRequest) GetBusiness() string
- func (g *GetMeshConfigRequest) GetMeshType() string
- func (g *GetMeshConfigRequest) GetNamespace() string
- func (g *GetMeshConfigRequest) GetRetryCountPtr() *int
- func (g *GetMeshConfigRequest) GetTimeoutPtr() *time.Duration
- func (g *GetMeshConfigRequest) SetRetryCount(retryCount int)
- func (g *GetMeshConfigRequest) SetTimeout(duration time.Duration)
- type GetMeshRequest
- func (g *GetMeshRequest) GetBusiness() string
- func (g *GetMeshRequest) GetMeshId() string
- func (g *GetMeshRequest) GetNamespace() string
- func (g *GetMeshRequest) GetRetryCountPtr() *int
- func (g *GetMeshRequest) GetTimeoutPtr() *time.Duration
- func (g *GetMeshRequest) SetRetryCount(retryCount int)
- func (g *GetMeshRequest) SetTimeout(duration time.Duration)
- type GetOneInstanceRequest
- func (g *GetOneInstanceRequest) GetCanary() string
- func (g *GetOneInstanceRequest) GetMetadata() map[string]string
- func (g *GetOneInstanceRequest) GetNamespace() string
- func (g *GetOneInstanceRequest) GetResponse() *InstancesResponse
- func (g *GetOneInstanceRequest) GetRetryCountPtr() *int
- func (g *GetOneInstanceRequest) GetService() string
- func (g *GetOneInstanceRequest) GetTimeoutPtr() *time.Duration
- func (g *GetOneInstanceRequest) SetCanary(canary string)
- func (g *GetOneInstanceRequest) SetRetryCount(retryCount int)
- func (g *GetOneInstanceRequest) SetTimeout(duration time.Duration)
- func (g *GetOneInstanceRequest) Validate() error
- type GetServiceRuleRequest
- func (g *GetServiceRuleRequest) GetMetadata() map[string]string
- func (g *GetServiceRuleRequest) GetNamespace() string
- func (g *GetServiceRuleRequest) GetResponse() *ServiceRuleResponse
- func (g *GetServiceRuleRequest) GetRetryCountPtr() *int
- func (g *GetServiceRuleRequest) GetService() string
- func (g *GetServiceRuleRequest) GetTimeoutPtr() *time.Duration
- func (g *GetServiceRuleRequest) SetRetryCount(retryCount int)
- func (g *GetServiceRuleRequest) SetTimeout(duration time.Duration)
- func (g *GetServiceRuleRequest) Validate() error
- type GetServicesRequest
- type HashSet
- type HealthCheckStatus
- type InitCalleeServiceRequest
- type Instance
- type InstanceAddEvent
- type InstanceDeRegisterRequest
- func (g *InstanceDeRegisterRequest) GetRetryCountPtr() *int
- func (g *InstanceDeRegisterRequest) GetTimeoutPtr() *time.Duration
- func (g *InstanceDeRegisterRequest) SetRetryCount(retryCount int)
- func (g *InstanceDeRegisterRequest) SetTimeout(duration time.Duration)
- func (g InstanceDeRegisterRequest) String() string
- func (i *InstanceDeRegisterRequest) Validate() error
- type InstanceDeleteEvent
- type InstanceEvent
- type InstanceGauge
- type InstanceHeartbeatRequest
- func (g *InstanceHeartbeatRequest) GetRetryCountPtr() *int
- func (g *InstanceHeartbeatRequest) GetTimeoutPtr() *time.Duration
- func (g *InstanceHeartbeatRequest) SetRetryCount(retryCount int)
- func (g *InstanceHeartbeatRequest) SetTimeout(duration time.Duration)
- func (g InstanceHeartbeatRequest) String() string
- func (i *InstanceHeartbeatRequest) Validate() error
- type InstanceKey
- type InstanceRegisterRequest
- func (g *InstanceRegisterRequest) GetLocation() *Location
- func (g *InstanceRegisterRequest) GetRetryCountPtr() *int
- func (g *InstanceRegisterRequest) GetTimeoutPtr() *time.Duration
- func (g *InstanceRegisterRequest) SetHealthy(healthy bool)
- func (g *InstanceRegisterRequest) SetIsolate(isolate bool)
- func (g *InstanceRegisterRequest) SetLocation(loc *Location)
- func (g *InstanceRegisterRequest) SetRetryCount(retryCount int)
- func (g *InstanceRegisterRequest) SetTTL(ttl int)
- func (g *InstanceRegisterRequest) SetTimeout(duration time.Duration)
- func (g InstanceRegisterRequest) String() string
- func (g *InstanceRegisterRequest) Validate() error
- type InstanceRegisterResponse
- type InstanceSet
- func (i *InstanceSet) Count() int
- func (i *InstanceSet) GetInstances() WeightIndexSlice
- func (i *InstanceSet) GetLock() sync.Locker
- func (i *InstanceSet) GetRealInstances() []Instance
- func (i *InstanceSet) GetSelector(id int32) ExtendedSelector
- func (i *InstanceSet) GetServiceClusters() ServiceClusters
- func (i *InstanceSet) GetValue(index int) uint64
- func (i *InstanceSet) MaxWeight() int
- func (i *InstanceSet) SetSelector(selector ExtendedSelector)
- func (i *InstanceSet) String() string
- func (i *InstanceSet) TotalWeight() int
- type InstanceUpdateEvent
- type InstanceWeight
- type InstancesResponse
- func (i *InstancesResponse) GetCluster() *Cluster
- func (i *InstancesResponse) GetInstance(instanceId string) Instance
- func (i *InstancesResponse) GetInstances() []Instance
- func (i *InstancesResponse) GetRevision() string
- func (i *InstancesResponse) GetServiceClusters() ServiceClusters
- func (i *InstancesResponse) GetTotalWeight() int
- func (i *InstancesResponse) GetType() EventType
- func (i *InstancesResponse) IsCacheLoaded() bool
- func (i *InstancesResponse) IsInitialized() bool
- func (i *InstancesResponse) ReloadServiceClusters()
- type Location
- type LocationBasedMetaKey
- type LocationInfo
- type Mesh
- type MeshConfig
- type MeshConfigResponse
- func (s *MeshConfigResponse) GetNamespace() string
- func (s *MeshConfigResponse) GetRevision() string
- func (s *MeshConfigResponse) GetService() string
- func (s *MeshConfigResponse) GetType() EventType
- func (s *MeshConfigResponse) GetValidateError() error
- func (s *MeshConfigResponse) GetValue() interface{}
- func (s *MeshConfigResponse) IsInitialized() bool
- type MeshKey
- type MeshResponse
- func (s *MeshResponse) GetNamespace() string
- func (s *MeshResponse) GetRevision() string
- func (s *MeshResponse) GetService() string
- func (s *MeshResponse) GetType() EventType
- func (s *MeshResponse) GetValidateError() error
- func (s *MeshResponse) GetValue() interface{}
- func (s *MeshResponse) IsInitialized() bool
- type MetaComposedValue
- type MetricType
- type NotifyTrigger
- type OnConfigFileChange
- type OneInstanceResponse
- type OneInstanceUpdate
- type PeriodicCallBack
- type PeriodicTask
- type PriorityCallBack
- type PriorityTask
- type ProcessLoadBalanceRequest
- type ProcessRoutersRequest
- func (p *ProcessRoutersRequest) GetResponse() *InstancesResponse
- func (p *ProcessRoutersRequest) GetRetryCountPtr() *int
- func (p *ProcessRoutersRequest) GetTimeoutPtr() *time.Duration
- func (p *ProcessRoutersRequest) SetRetryCount(v int)
- func (p *ProcessRoutersRequest) SetTimeout(duration time.Duration)
- func (p *ProcessRoutersRequest) Validate() error
- type QuotaAllocator
- type QuotaFutureImpl
- type QuotaRequestImpl
- func (q *QuotaRequestImpl) GetCluster() string
- func (q *QuotaRequestImpl) GetLabels() map[string]string
- func (q *QuotaRequestImpl) GetNamespace() string
- func (q *QuotaRequestImpl) GetRetryCountPtr() *int
- func (q *QuotaRequestImpl) GetService() string
- func (q *QuotaRequestImpl) GetTimeoutPtr() *time.Duration
- func (q *QuotaRequestImpl) SetCluster(cluster string)
- func (q *QuotaRequestImpl) SetLabels(labels map[string]string)
- func (q *QuotaRequestImpl) SetNamespace(namespace string)
- func (q *QuotaRequestImpl) SetRetryCount(retryCount int)
- func (q *QuotaRequestImpl) SetService(svc string)
- func (q *QuotaRequestImpl) SetTimeout(timeout time.Duration)
- func (q *QuotaRequestImpl) Validate() error
- type QuotaResponse
- type QuotaResultCode
- type RateLimitGauge
- type RegistryValue
- type ReplicateNodes
- type ReportClientRequest
- type ReportClientResponse
- type RetStatus
- type RuleCache
- type RunMode
- type SDKError
- type SDKToken
- type SelectorBase
- type ServiceCallResult
- func (s *ServiceCallResult) GetCalledInstance() Instance
- func (s *ServiceCallResult) GetDelay() *time.Duration
- func (s *ServiceCallResult) GetHost() string
- func (s *ServiceCallResult) GetID() string
- func (s *ServiceCallResult) GetNamespace() string
- func (s *ServiceCallResult) GetPort() int
- func (s *ServiceCallResult) GetRetCode() *int32
- func (s *ServiceCallResult) GetRetCodeValue() int32
- func (s *ServiceCallResult) GetRetStatus() RetStatus
- func (s *ServiceCallResult) GetService() string
- func (s *ServiceCallResult) SetCalledInstance(inst Instance) *ServiceCallResult
- func (s *ServiceCallResult) SetDelay(duration time.Duration) *ServiceCallResult
- func (s *ServiceCallResult) SetRetCode(value int32) *ServiceCallResult
- func (s *ServiceCallResult) SetRetStatus(retStatus RetStatus) *ServiceCallResult
- func (s *ServiceCallResult) Validate() error
- type ServiceClusters
- type ServiceEventKey
- type ServiceInfo
- type ServiceInstances
- type ServiceKey
- type ServiceMetadata
- type ServiceRule
- type ServiceRuleResponse
- func (s *ServiceRuleResponse) GetNamespace() string
- func (s *ServiceRuleResponse) GetRevision() string
- func (s *ServiceRuleResponse) GetRuleCache() RuleCache
- func (s *ServiceRuleResponse) GetService() string
- func (s *ServiceRuleResponse) GetType() EventType
- func (s *ServiceRuleResponse) GetValidateError() error
- func (s *ServiceRuleResponse) GetValue() interface{}
- func (s *ServiceRuleResponse) IsCacheLoaded() bool
- func (s *ServiceRuleResponse) IsInitialized() bool
- type Services
- type ServicesResponse
- func (s *ServicesResponse) GetNamespace() string
- func (s *ServicesResponse) GetRevision() string
- func (s *ServicesResponse) GetService() string
- func (s *ServicesResponse) GetType() EventType
- func (s *ServicesResponse) GetValidateError() error
- func (s *ServicesResponse) GetValue() interface{}
- func (s *ServicesResponse) IsInitialized() bool
- type StatInfo
- type Status
- type SubScribeEvent
- type SubScribeEventType
- type SyncHashSet
- type TaskEvent
- type TaskResult
- type TaskValue
- type TaskValues
- type ValueContext
- type WatchServiceRequest
- type WatchServiceResponse
- type WeightIndexSlice
- type WeightedIndex
Constants ¶
const ( NearbyMetadataEnable = "internal-enable-nearby" CanaryMetadataEnable = "internal-canary" CanaryMetaKey = "canary" )
用于拼接metadata的样式
const ( // 主流程引擎的上下文key // SDK初始化后,会将主流程引擎对象放入上下文中,供插件按需使用 ContextKeyEngine = "engine" // SDK的唯一标识id ContextKeyToken = "SDKToken" // sdkcontext上面的pluginManager ContextKeyPlugins = "plugins" // sdkContext创建开始时间 ContextKeyTakeEffectTime = "SDKTakeEffectTime" // sdkContext创建结束时间 ContextKeyFinishInitTime = "SDKFinishInitTime" )
const ( // 地域信息初始化,未获取到地域信息 LocationInit uint32 = iota // 地域信息获取失败,出现异常 LocationError // 地域信息获取成功 LocationReady // 地域信息获取成功,但是是空的,即没有在cmdb上面发现地域信息 LocationEmpty )
const ( // 返回码取模的底数 RetCodeDivFactor = 1000 // 取模后的成功错误码 SuccessRetCode = 200 // 取模后的server内部错误 ServerExceptionRetCode = 500 )
const ( RateLimitLocal = "local" RateLimitGlobal = "global" )
const ( // ServiceEntry MeshServiceEntry string = "networking.istio.io/v1alpha3/ServiceEntry" // VirtualService MeshVirtualService string = "networking.istio.io/v1alpha3/VirtualService" // DestinationRule MeshDestinationRule string = "networking.istio.io/v1alpha3/DestinationRule" // EnvoyFilter MeshEnvoyFilter string = "networking.istio.io/v1alpha3/EnvoyFilter" // Gateway MeshGateway string = "networking.istio.io/v1alpha3/Gateway" )
网格规则类型
const ( // ModeNoAgent 以no agent模式运行 ModeNoAgent = iota // ModeWithAgent 带agent模式运行 ModeWithAgent )
const ( // 最小权重值 MinWeight int = 0 // 最大权重值 MaxWeight int = 10000 // 最小优先级 MinPriority = 0 // 最大优先级 MaxPriority = 9 )
const (
BaseIndexErrCode = 1000
)
const (
BaseSDKInternalErrCode = 3000
)
const (
BaseServerErrCode = 2000
)
const (
ErrCodeDiskError = BaseSDKInternalErrCode + 1
)
const ( // 健康检查类型:心跳 HealthCheckTypeHeartBeat int = 0 )
const (
HomeVar = "$HOME"
)
Variables ¶
var ( // 网格请求key前缀 MeshPrefix = "mesh_resource" // 网格请求key分割长度 MeshKeyLen = 3 // 网格请求key分隔符 MeshKeySpliter = "MESHa071a34fecSPLITER" )
Functions ¶
func CurrentNanosecond ¶
func CurrentNanosecond() int64
CurrentNanosecond obtains the current microsecond, use syscall for better performance
func EnsureAndVerifyDir ¶
EnsureAndVerifyDir 检测缓存目录,不存在则创建
func IsInstanceAvailable ¶
IsInstanceAvailable 服务实例是否可用
func IsServerException ¶
IsServerException 判断是否为内部server错误
func IsSuccessResultCode ¶
IsSuccessResultCode 判断是否成功的错误码
func PoolGetByteBuffer ¶
PoolGetByteBuffer 通过池子获取字符串队列
func PoolPutByteBuffer ¶
PoolPutByteBuffer 归还字节数组
func PoolPutStringSlice ¶
PoolPutStringSlice 归还字符串数组
func TimestampMsToUtcIso8601 ¶
TimestampMsToUtcIso8601 格式化时间戳
func ToStringService ¶
func ToStringService(svc ServiceMetadata, printMeta bool) string
ToStringService 服务元数据的ToString操作
func WithQuotaFutureDeadline ¶ added in v1.1.0
func WithQuotaFutureHooks ¶ added in v1.1.0
func WithQuotaFutureHooks(hooks ...finishHook) quotaFutureOption
func WithQuotaFutureQuotaAllocator ¶ added in v1.1.0
func WithQuotaFutureQuotaAllocator(allocator QuotaAllocator) quotaFutureOption
func WithQuotaFutureReq ¶ added in v1.1.0
func WithQuotaFutureReq(req *QuotaRequestImpl) quotaFutureOption
func WithQuotaFutureResp ¶ added in v1.1.0
func WithQuotaFutureResp(resp *QuotaResponse) quotaFutureOption
Types ¶
type APICallKey ¶
type APICallKey struct { // 调用的API接口名字 APIName ApiOperation // 必选,本地服务调用的错误码 RetCode ErrCode // 延迟的范围 DelayRange ApiDelayRange }
APICallKey API调用的唯一标识
type APICallResult ¶
type APICallResult struct { EmptyInstanceGauge APICallKey // 必选,本地服务调用的状态,正常or异常 RetStatus RetStatus // contains filtered or unexported fields }
APICallResult sdk api调用结果
func (*APICallResult) GetDelayRange ¶
func (a *APICallResult) GetDelayRange() ApiDelayRange
GetDelayRange 返回延迟范围
func (*APICallResult) GetRetCodeValue ¶
func (a *APICallResult) GetRetCodeValue() int32
GetRetCodeValue 实例的返回码
func (*APICallResult) GetRetStatus ¶
func (a *APICallResult) GetRetStatus() RetStatus
GetRetStatus 实例的调用返回状态
func (*APICallResult) SetDelay ¶
func (a *APICallResult) SetDelay(delay time.Duration)
SetDelay 设置调用时延
func (*APICallResult) SetFail ¶
func (a *APICallResult) SetFail(retCode ErrCode, delay time.Duration)
SetFail 设置失败的调用结果
func (*APICallResult) SetSuccess ¶
func (a *APICallResult) SetSuccess(delay time.Duration)
SetSuccess 设置成功的调用结果
type ActiveDetectStatus ¶
type ActiveDetectStatus interface { // GetStatus 健康探测结果状态 GetStatus() HealthCheckStatus // GetStartTime 状态转换的时间 GetStartTime() time.Time }
ActiveDetectStatus 健康探测管理器
type ApiDelayRange ¶
type ApiDelayRange int
ApiDelayRange API延时范围
const ( ApiDelayBelow50 ApiDelayRange = iota ApiDelayBelow100 ApiDelayBelow150 ApiDelayBelow200 ApiDelayOver200 ApiDelayMax )
API延时范围常量
func GetApiDelayRange ¶
func GetApiDelayRange(delay time.Duration) ApiDelayRange
GetApiDelayRange 获取api时延范围
type ApiOperation ¶
type ApiOperation int
命名类型,标识具体的API类型
const ( ApiGetOneInstance ApiOperation = iota ApiGetInstances ApiGetRouteRule ApiRegister ApiDeregister ApiHeartbeat ApiGetQuota ApiGetAllInstances ApiUpdateServiceCallResult ApiMeshConfig ApiInitCalleeServices ApiMesh ApiProcessRouters ApiProcessLoadBalance // ApiOperationMax这个必须在最下面 ApiOperationMax )
API标识
type CacheValueQuery ¶
type CacheValueQuery interface { // 获取目标服务 GetDstService() *ServiceKey // 获取源服务 GetSrcService() *ServiceKey // 获取缓存查询触发器 GetNotifierTrigger() *NotifyTrigger // 设置目标服务实例 SetDstInstances(instances ServiceInstances) // 设置目标服务路由规则 SetDstRoute(rule ServiceRule) // 设置目标服务限流规则 SetDstRateLimit(rule ServiceRule) // 设置源服务路由规则 SetSrcRoute(rule ServiceRule) // 获取API调用控制参数 GetControlParam() *ControlParam // 获取API调用统计 GetCallResult() *APICallResult // 设置网格规则 SetMeshConfig(mc MeshConfig) }
CacheValueQuery 缓存查询请求对象
type ChangeType ¶ added in v1.1.0
type ChangeType int
ChangeType 配置文件变更类型
const ( // Modified 修改类型 Modified ChangeType = iota // Deleted 删除类型 Deleted // Added 新增类型 Added // NotChanged 没有变更 NotChanged )
type CircuitBreakGauge ¶ added in v1.1.0
type CircuitBreakGauge struct { EmptyInstanceGauge ChangeInstance Instance Method string CBStatus CircuitBreakerStatus }
func (*CircuitBreakGauge) GetCalledInstance ¶ added in v1.1.0
func (cbg *CircuitBreakGauge) GetCalledInstance() Instance
获取状态发生改变的实例
func (*CircuitBreakGauge) GetCircuitBreakerStatus ¶ added in v1.1.0
func (cbg *CircuitBreakGauge) GetCircuitBreakerStatus() CircuitBreakerStatus
获取变化前的熔断状态
func (*CircuitBreakGauge) Validate ¶ added in v1.1.0
func (cbg *CircuitBreakGauge) Validate() error
检测指标是否合法
type CircuitBreakerStatus ¶
type CircuitBreakerStatus interface { // 标识被哪个熔断器熔断 GetCircuitBreaker() string // 熔断状态 GetStatus() Status // 状态转换的时间 GetStartTime() time.Time // 是否可以分配请求 IsAvailable() bool // 执行请求分配 Allocate() bool // 获取进入半开状态之后分配的请求数 GetRequestsAfterHalfOpen() int32 // 获取进入半开状态之后的失败请求数 GetFailRequestsAfterHalfOpen() int32 // 添加半开状态下面的请求数 AddRequestCountAfterHalfOpen(n int32, success bool) int32 // 获取分配了最后配额的时间 GetFinalAllocateTimeInt64() int64 // 获取状态转换锁,主要是避免状态重复发生转变,如多个协程上报调用失败时,每个stat方法都返回需要转化为熔断状态 AcquireStatusLock() bool // 获取在半开之后,分配出去的请求数,即getOneInstance接口返回这个实例的次数 AllocatedRequestsAfterHalfOpen() int32 }
CircuitBreakerStatus 熔断器状态管理器
type Cluster ¶
type Cluster struct { ClusterKey MetaComposedValue // 集群的元数据信息,key为metaKey, valueKey为metaValue, valueValue为composedValue Metadata map[string]map[string]string // 元数据KV的个数 MetaCount int // 是否包含限制路由的实例,全死全活后为true HasLimitedInstances bool // 没有符合就近路由的实例 MissLocationInstances bool // 位置信息匹配情况 LocationMatchInfo string IncludeHalfOpen bool // contains filtered or unexported fields }
Cluster 路由后的集群信息,包含的是标签以及地域信息
func NewCluster ¶
func NewCluster(clusters ServiceClusters, cls *Cluster) *Cluster
NewCluster 新建Cluster
func (*Cluster) AddMetadata ¶
AddMetadata 开放给插件进行手动元数据的添加
func (*Cluster) GetAllInstances ¶
GetAllInstances 获取完整的服务实例列表
func (*Cluster) GetClusterValue ¶
func (c *Cluster) GetClusterValue() *ClusterValue
GetClusterValue 重构建集群缓存
func (*Cluster) GetContainMetaKeyClusterValue ¶
func (c *Cluster) GetContainMetaKeyClusterValue() *ClusterValue
GetContainMetaKeyClusterValue 重构 包含Key 的缓存
func (*Cluster) GetContainNotMatchMetaKeyClusterValue ¶
func (c *Cluster) GetContainNotMatchMetaKeyClusterValue() *ClusterValue
GetContainNotMatchMetaKeyClusterValue 重构 包含Key但是不匹配 的缓存
func (*Cluster) GetInstances ¶
GetInstances 通过服务实例全量列表获取集群服务实例
func (*Cluster) GetInstancesWhenSkipRouteFilter ¶
func (*Cluster) GetNotContainMetaKeyClusterValue ¶
func (c *Cluster) GetNotContainMetaKeyClusterValue() *ClusterValue
GetNotContainMetaKeyClusterValue 重构 不包含Key 的缓存
func (*Cluster) MatchContainMetaKeyData ¶
MatchContainMetaKeyData 判断是否包含标签key
func (*Cluster) ReloadComposeMetaValue ¶
func (c *Cluster) ReloadComposeMetaValue()
ReloadComposeMetaValue 重建组合元数据KV
func (*Cluster) RuleAddMetadata ¶
RuleAddMetadata 通过路由规则插件添加复合元数据,不会进行缓存数据的变更
type ClusterEventHandler ¶
type ClusterEventHandler struct { // 在集群值构建完毕后进行调用 PostClusterValueBuilt func(value *ClusterValue) }
ClusterEventHandler 集群事件处理器
type ClusterKey ¶
ClusterKey 集群缓存KEY对象
type ClusterOwner ¶ added in v1.2.0
type ClusterOwner interface { // GetCluster get the retained cluster GetCluster() *Cluster }
ClusterOwner 保存了cluster指针的对象
type ClusterValue ¶
type ClusterValue struct {
// contains filtered or unexported fields
}
ClusterValue 集群缓存VALUE对象
func (*ClusterValue) GetAllInstanceSet ¶
func (v *ClusterValue) GetAllInstanceSet() *InstanceSet
GetAllInstanceSet 获取全量服务实例集合
func (*ClusterValue) GetInstancesSet ¶
func (v *ClusterValue) GetInstancesSet(hasLimitedInstances bool, includeHalfOpen bool) *InstanceSet
GetInstancesSet 获取实例集合,根据参数来进行选择返回全量或者健康
func (*ClusterValue) GetInstancesSetWhenSkipRouteFilter ¶
func (v *ClusterValue) GetInstancesSetWhenSkipRouteFilter(hasLimitedInstances bool, includeHalfOpen bool) *InstanceSet
type ConfigFile ¶ added in v1.1.0
type ConfigFile interface { ConfigFileMetadata // GetContent 获取配置文件内容 GetContent() string // HasContent 是否有配置内容 HasContent() bool // AddChangeListenerWithChannel 增加配置文件变更监听器 AddChangeListenerWithChannel(chan ConfigFileChangeEvent) // AddChangeListener 增加配置文件变更监听器 AddChangeListener(cb OnConfigFileChange) }
ConfigFile 文本类型配置文件对象
type ConfigFileChangeEvent ¶ added in v1.1.0
type ConfigFileChangeEvent struct { ConfigFileMetadata ConfigFileMetadata // OldValue 变更之前的值 OldValue string // NewValue 变更之后的值 NewValue string // ChangeType 变更类型 ChangeType ChangeType }
ConfigFileChangeEvent 配置文件变更事件
type ConfigFileMetadata ¶ added in v1.1.0
type ConfigFileMetadata interface { // GetNamespace 获取 Namespace 信息 GetNamespace() string // GetFileGroup 获取配置文件组 GetFileGroup() string // GetFileName 获取配置文件值 GetFileName() string }
ConfigFileMetadata 配置文件元信息
type ConfigMode ¶
type ConfigMode int
const ( ConfigQuotaLocalMode ConfigMode = 0 ConfigQuotaGlobalMode ConfigMode = 1 )
type ControlParam ¶
ControlParam 单次查询的控制参数
type DefaultConfigFileMetadata ¶ added in v1.1.0
DefaultConfigFileMetadata 默认 ConfigFileMetadata 实现类
func (*DefaultConfigFileMetadata) GetFileGroup ¶ added in v1.1.0
func (m *DefaultConfigFileMetadata) GetFileGroup() string
GetFileGroup 获取配置文件组
func (*DefaultConfigFileMetadata) GetFileName ¶ added in v1.1.0
func (m *DefaultConfigFileMetadata) GetFileName() string
GetFileName 获取配置文件值
func (*DefaultConfigFileMetadata) GetNamespace ¶ added in v1.1.0
func (m *DefaultConfigFileMetadata) GetNamespace() string
GetNamespace 获取 Namespace
type DefaultServiceInstances ¶ added in v1.2.0
type DefaultServiceInstances struct {
// contains filtered or unexported fields
}
func (*DefaultServiceInstances) GetInstance ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetInstance(id string) Instance
获取单个服务实例
func (*DefaultServiceInstances) GetInstances ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetInstances() []Instance
获取服务实例列表
func (*DefaultServiceInstances) GetMetadata ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetMetadata() map[string]string
获取元数据信息
func (*DefaultServiceInstances) GetNamespace ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetNamespace() string
获取命名空间
func (*DefaultServiceInstances) GetRevision ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetRevision() string
获取服务实例或规则的版本号
func (*DefaultServiceInstances) GetService ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetService() string
获取服务名
func (*DefaultServiceInstances) GetServiceClusters ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetServiceClusters() ServiceClusters
获取集群索引
func (*DefaultServiceInstances) GetTotalWeight ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetTotalWeight() int
获取全部实例总权重
func (*DefaultServiceInstances) GetType ¶ added in v1.2.0
func (d *DefaultServiceInstances) GetType() EventType
获取配置类型
func (*DefaultServiceInstances) IsCacheLoaded ¶ added in v1.2.0
func (d *DefaultServiceInstances) IsCacheLoaded() bool
数据是否来自于缓存文件
func (*DefaultServiceInstances) IsInitialized ¶ added in v1.2.0
func (d *DefaultServiceInstances) IsInitialized() bool
是否初始化,实例列表或路由值是否加载
func (*DefaultServiceInstances) ReloadServiceClusters ¶ added in v1.2.0
func (d *DefaultServiceInstances) ReloadServiceClusters()
重建缓存索引
type EmptyInstanceGauge ¶
type EmptyInstanceGauge struct { }
EmptyInstanceGauge instangeGauge的空实现
func (EmptyInstanceGauge) GetCalledInstance ¶
func (e EmptyInstanceGauge) GetCalledInstance() Instance
GetCalledInstance 获取被调节点
func (EmptyInstanceGauge) GetCircuitBreakerStatus ¶
func (e EmptyInstanceGauge) GetCircuitBreakerStatus() CircuitBreakerStatus
GetCircuitBreakerStatus
func (EmptyInstanceGauge) GetDelay ¶
func (e EmptyInstanceGauge) GetDelay() *time.Duration
GetDelay delay
func (EmptyInstanceGauge) GetDelayRange ¶
func (e EmptyInstanceGauge) GetDelayRange() ApiDelayRange
GetDelayRange 调用时延
func (EmptyInstanceGauge) GetNamespace ¶
func (e EmptyInstanceGauge) GetNamespace() string
GetNamespace
func (EmptyInstanceGauge) GetRetCodeValue ¶
func (e EmptyInstanceGauge) GetRetCodeValue() int32
GetRetCodeValue retcode
func (EmptyInstanceGauge) GetRetStatus ¶
func (e EmptyInstanceGauge) GetRetStatus() RetStatus
GetRetStatus
type Engine ¶
type Engine interface { // 销毁流程引擎 Destroy() error // 同步加载资源,可通过配置参数指定一次同时加载多个资源 SyncGetResources(req CacheValueQuery) error // 同步获取负载均衡后的服务实例 SyncGetOneInstance(req *GetOneInstanceRequest) (*OneInstanceResponse, error) // 同步获取批量服务实例 SyncGetInstances(req *GetInstancesRequest) (*InstancesResponse, error) // 同步获取全量服务实例 SyncGetAllInstances(req *GetAllInstancesRequest) (*InstancesResponse, error) // 同步进行服务注册 SyncRegister(instance *InstanceRegisterRequest) (*InstanceRegisterResponse, error) // 同步进行服务反注册 SyncDeregister(instance *InstanceDeRegisterRequest) error // 同步进行心跳上报 SyncHeartbeat(instance *InstanceHeartbeatRequest) error // 上报调用结果信息 SyncUpdateServiceCallResult(result *ServiceCallResult) error // 上报实例统计信息 SyncReportStat(typ MetricType, stat InstanceGauge) error // 同步获取服务规则 SyncGetServiceRule( eventType EventType, req *GetServiceRuleRequest) (*ServiceRuleResponse, error) // 同步获取网格规则 SyncGetMeshConfig( eventType EventType, req *GetMeshConfigRequest) (*MeshConfigResponse, error) // 同步获取网格 SyncGetMesh( eventType EventType, req *GetMeshRequest) (*MeshResponse, error) // 同步获取批量服务 SyncGetServices( eventType EventType, req *GetServicesRequest) (*ServicesResponse, error) // 同步获取配额信息 AsyncGetQuota(request *QuotaRequestImpl) (*QuotaFutureImpl, error) // 启动定时任务 ScheduleTask(task *PeriodicTask) (chan<- *PriorityTask, TaskValues) // 监听服务的change WatchService(request *WatchServiceRequest) (*WatchServiceResponse, error) GetContext() ValueContext // 所需的被调初始化 InitCalleeService(req *InitCalleeServiceRequest) error // SyncGetConfigFile 同步获取配置文件 SyncGetConfigFile(namespace, fileGroup, fileName string) (ConfigFile, error) // 执行路由链过滤,返回经过路由后的实例列表 ProcessRouters(req *ProcessRoutersRequest) (*InstancesResponse, error) // 执行负载均衡策略,返回负载均衡后的实例 ProcessLoadBalance(req *ProcessLoadBalanceRequest) (*OneInstanceResponse, error) }
Engine 编排调度引擎,API相关逻辑在这里执行
type ErrCode ¶
type ErrCode int32
ErrCode 错误码类型,Polaris SDK对外返回错误码都使用该类型
const ( // ErrCodeSuccess 没有发生错误 ErrCodeSuccess ErrCode = 0 // ErrCodeUnknown 未知错误 ErrCodeUnknown ErrCode = BaseIndexErrCode // ErrCodeAPIInvalidArgument API参数非法的错误码 ErrCodeAPIInvalidArgument ErrCode = BaseIndexErrCode + 1 // ErrCodeAPIInvalidConfig 配置非法的错误码 ErrCodeAPIInvalidConfig ErrCode = BaseIndexErrCode + 2 // ErrCodePluginError 插件错误的错误码 ErrCodePluginError ErrCode = BaseIndexErrCode + 3 // ErrCodeAPITimeoutError API超时错误的错误码 ErrCodeAPITimeoutError ErrCode = BaseIndexErrCode + 4 // ErrCodeAPITimeoutError SDK已经destroy后,继续调API会出现的错误码 ErrCodeInvalidStateError ErrCode = BaseIndexErrCode + 5 // ErrCodeServerUserError 连接server时,server返回400错误信息 ErrCodeServerUserError ErrCode = BaseIndexErrCode + 6 // ErrCodeNetworkError 连接server时所出现的未知网络异常 ErrCodeNetworkError ErrCode = BaseIndexErrCode + 7 // ErrCodeCircuitBreakerError 服务熔断错误 ErrCodeCircuitBreakerError ErrCode = BaseIndexErrCode + 8 // 实例信息有误,如服务权重信息为空 ErrCodeInstanceInfoError ErrCode = BaseIndexErrCode + 9 // ErrCodeAPIInstanceNotFOUND 服务实例获取失败 ErrCodeAPIInstanceNotFound ErrCode = BaseIndexErrCode + 10 // ErrCodeInvalidRule 路由规则非法 ErrCodeInvalidRule ErrCode = BaseIndexErrCode + 11 // ErrCodeRouteRuleNotMatch 路由规则匹配失败 ErrCodeRouteRuleNotMatch ErrCode = BaseIndexErrCode + 12 // ErrCodeInvalidResponse Server返回的消息不合法 ErrCodeInvalidResponse ErrCode = BaseIndexErrCode + 13 // ErrCodeInternalError 内部算法及系统错误 ErrCodeInternalError ErrCode = BaseIndexErrCode + 14 // ErrCodeServiceNotFound 服务不存在 ErrCodeServiceNotFound ErrCode = BaseIndexErrCode + 15 // ErrCodeServerException server返回500错误 ErrCodeServerException ErrCode = BaseIndexErrCode + 16 // ErrCodeLocationNotFound 获取地域信息失败 ErrCodeLocationNotFound ErrCode = BaseIndexErrCode + 17 // ErrCodeLocationMismatch 就近路由失败,在对应就近级别上面没有实例 ErrCodeLocationMismatch ErrCode = BaseIndexErrCode + 18 // ErrCodeDstMetaMismatch 目标规则元数据过滤失败 ErrCodeDstMetaMismatch ErrCode = BaseIndexErrCode + 19 // ErrCodeMeshConfigNotFound 目标类型的网格规则未找到 ErrCodeMeshConfigNotFound ErrCode = BaseIndexErrCode + 20 // ErrCodeConsumerInitCalleeError 初始化服务运行中需要的被调服务失败 ErrCodeConsumerInitCalleeError ErrCode = BaseIndexErrCode + 21 // 接口错误码数量,每添加了一个错误码,将这个数值加1 ErrCodeCount = 23 )
const ( ErrCodeConnectError ErrCode = BaseServerErrCode + 1 ErrCodeServerError ErrCode = BaseServerErrCode + 2 ErrorCodeRpcError ErrCode = BaseServerErrCode + 3 ErrorCodeRpcTimeout ErrCode = BaseServerErrCode + 4 ErrCodeInvalidServerResponse ErrCode = BaseServerErrCode + 5 ErrCodeInvalidRequest ErrCode = BaseServerErrCode + 6 ErrCodeRequestLimit ErrCode = BaseServerErrCode + 8 ErrCodeCmdbNotFound ErrCode = BaseServerErrCode + 9 ErrCodeUnknownServerError ErrCode = BaseServerErrCode + 100 )
func GetErrorCodeFromError ¶
GetErrorCodeFromError 从错误中获取错误码
type ErrCodeType ¶
type ErrCodeType int
ErrCodeType 错误码类型
const ( // 北极星系统错误 PolarisError ErrCodeType = 0 // 用户错误 UserError ErrCodeType = 1 )
type EventType ¶
type EventType uint32
EventType 事件类型,用于标识各种不同的事件
const ( // 未知事件 EventUnknown EventType = 0 // EventInstances 实例事件 EventInstances EventType = 0x2001 // EventTypeConfig 路由配置事件 EventRouting EventType = 0x2002 // EventRateLimiting 限流配置事件 EventRateLimiting EventType = 0x2003 // mesh config EventMeshConfig EventType = 0x2004 // EventRateLimiting 批量服务 EventServices EventType = 0x2005 // mesh EventMesh EventType = 0x2006 )
type ExtendedSelector ¶
type ExtendedSelector interface { Select(criteria interface{}) (int, *ReplicateNodes, error) // 对应负载均衡插件的名字 ID() int32 }
ExtendedSelector 可供插件自定义的实例选择器
type FailOverDefaultMetaConfig ¶
type FailOverDefaultMetaConfig struct { // 元数据路由兜底策略类型 Type FailOverHandler // 仅type==CustomMeta时需要填写 Meta map[string]string }
type FailOverHandler ¶
type FailOverHandler int
FailOverHandler 元数据路由兜底策略
const ( // 通配所有可用ip实例,等于关闭meta路由 GetOneHealth FailOverHandler = 1 // 匹配不带 metaData key路由 NotContainMetaKey FailOverHandler = 2 // 匹配自定义meta CustomMeta FailOverHandler = 3 )
type FilteredInstanceCounter ¶
type FilteredInstanceCounter struct {
// contains filtered or unexported fields
}
FilteredInstanceCounter 本地缓存中过滤的实例数量
func (*FilteredInstanceCounter) AddIsolatedInstances ¶
func (f *FilteredInstanceCounter) AddIsolatedInstances(n int32)
AddIsolatedInstances 增加过滤的被隔离实例数量
func (*FilteredInstanceCounter) AddRouteFilteredInstances ¶
func (f *FilteredInstanceCounter) AddRouteFilteredInstances(routerName string, n int32)
AddRouteFilteredInstances 增加被就近接入路由过滤的实例数量
func (*FilteredInstanceCounter) AddUnhealthyInstances ¶
func (f *FilteredInstanceCounter) AddUnhealthyInstances(n int32)
AddUnhealthyInstances 增加过滤的不健康实例数量
func (*FilteredInstanceCounter) GetIsolatedInstances ¶
func (f *FilteredInstanceCounter) GetIsolatedInstances() int32
GetIsolatedInstances 被隔离实例数量
func (*FilteredInstanceCounter) GetUnhealthyInstances ¶
func (f *FilteredInstanceCounter) GetUnhealthyInstances() int32
GetUnhealthyInstances 不健康实例数量
type GetAllInstancesRequest ¶
type GetAllInstancesRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 必选,服务名 Service string // 必选,命名空间 Namespace string // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int // contains filtered or unexported fields }
GetAllInstancesRequest 获取所有实例的请求
func (*GetAllInstancesRequest) GetMetadata ¶
func (g *GetAllInstancesRequest) GetMetadata() map[string]string
GetMetadata 获取命名空间
func (*GetAllInstancesRequest) GetNamespace ¶
func (g *GetAllInstancesRequest) GetNamespace() string
GetNamespace 获取命名空间
func (*GetAllInstancesRequest) GetResponse ¶
func (g *GetAllInstancesRequest) GetResponse() *InstancesResponse
GetResponse 获取应答指针
func (*GetAllInstancesRequest) GetRetryCountPtr ¶
func (g *GetAllInstancesRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetAllInstancesRequest) GetService ¶
func (g *GetAllInstancesRequest) GetService() string
GetService 获取服务名
func (*GetAllInstancesRequest) GetTimeoutPtr ¶
func (g *GetAllInstancesRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetAllInstancesRequest) SetRetryCount ¶
func (g *GetAllInstancesRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetAllInstancesRequest) SetTimeout ¶
func (g *GetAllInstancesRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (*GetAllInstancesRequest) Validate ¶
func (g *GetAllInstancesRequest) Validate() error
Validate 校验获取全部服务实例请求对象
type GetInstancesRequest ¶
type GetInstancesRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 必选,服务名 Service string // 必选,命名空间 Namespace string // 可选,元数据信息,仅用于dstMetadata路由插件的过滤 Metadata map[string]string // 主调方服务信息,只用于路由规则匹配 SourceService *ServiceInfo // 可选,是否包含被熔断的服务实例,默认false // Deprecated: 已弃用,1.0版本后会正式去掉,需要返回全量IP直接设置SkipRouteFilter=true IncludeCircuitBreakInstances bool // 可选,是否包含不健康的服务实例,默认false // Deprecated: 已弃用,1.0版本后会正式去掉,需要返回全量IP直接设置SkipRouteFilter=true IncludeUnhealthyInstances bool // 可选,是否跳过服务路由筛选,默认false SkipRouteFilter bool // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int // 金丝雀 Canary string // contains filtered or unexported fields }
GetInstancesRequest 批量服务实例查询请求
func (*GetInstancesRequest) GetCanary ¶
func (g *GetInstancesRequest) GetCanary() string
func (*GetInstancesRequest) GetMetadata ¶
func (g *GetInstancesRequest) GetMetadata() map[string]string
GetMetadata 获取命名空间
func (*GetInstancesRequest) GetNamespace ¶
func (g *GetInstancesRequest) GetNamespace() string
GetNamespace 获取命名空间
func (*GetInstancesRequest) GetResponse ¶
func (g *GetInstancesRequest) GetResponse() *InstancesResponse
GetResponse 获取应答指针
func (*GetInstancesRequest) GetRetryCountPtr ¶
func (g *GetInstancesRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetInstancesRequest) GetService ¶
func (g *GetInstancesRequest) GetService() string
GetService 获取服务名
func (*GetInstancesRequest) GetTimeoutPtr ¶
func (g *GetInstancesRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetInstancesRequest) SetCanary ¶
func (g *GetInstancesRequest) SetCanary(canary string)
func (*GetInstancesRequest) SetRetryCount ¶
func (g *GetInstancesRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetInstancesRequest) SetTimeout ¶
func (g *GetInstancesRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (*GetInstancesRequest) Validate ¶
func (g *GetInstancesRequest) Validate() error
Validate 校验获取全部服务实例请求对象
type GetMeshConfigRequest ¶
type GetMeshConfigRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 命名空间 Namespace string // 业务 Business string // 类型 MeshType string // 网格名 MeshId string // 可选,仅对同步请求有效,本次查询最大超时信息,可选,默认直接获取全局的超时配置 Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int }
GetMeshConfigRequest 获取网格数据
func (*GetMeshConfigRequest) GetBusiness ¶
func (g *GetMeshConfigRequest) GetBusiness() string
GetBusiness 获取命名空间
func (*GetMeshConfigRequest) GetMeshType ¶
func (g *GetMeshConfigRequest) GetMeshType() string
GetMeshType 获取网格类型
func (*GetMeshConfigRequest) GetNamespace ¶
func (g *GetMeshConfigRequest) GetNamespace() string
GetNamespace 获取命名空间
func (*GetMeshConfigRequest) GetRetryCountPtr ¶
func (g *GetMeshConfigRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetMeshConfigRequest) GetTimeoutPtr ¶
func (g *GetMeshConfigRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetMeshConfigRequest) SetRetryCount ¶
func (g *GetMeshConfigRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetMeshConfigRequest) SetTimeout ¶
func (g *GetMeshConfigRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
type GetMeshRequest ¶
type GetMeshRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 命名空间 Namespace string // 业务 Business string // 网格id MeshId string // 可选,仅对同步请求有效,本次查询最大超时信息,可选,默认直接获取全局的超时配置 Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int }
GetMeshRequest 获取网格数据
func (*GetMeshRequest) GetBusiness ¶
func (g *GetMeshRequest) GetBusiness() string
GetBusiness 获取命名空间
func (*GetMeshRequest) GetNamespace ¶
func (g *GetMeshRequest) GetNamespace() string
GetNamespace 获取命名空间
func (*GetMeshRequest) GetRetryCountPtr ¶
func (g *GetMeshRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetMeshRequest) GetTimeoutPtr ¶
func (g *GetMeshRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetMeshRequest) SetRetryCount ¶
func (g *GetMeshRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetMeshRequest) SetTimeout ¶
func (g *GetMeshRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
type GetOneInstanceRequest ¶
type GetOneInstanceRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 必选,服务名 Service string // 必选,命名空间 Namespace string // 可选,元数据信息,仅用于dstMetadata路由插件的过滤 Metadata map[string]string // 是否开启元数据匹配不到时启用自定义匹配规则,仅用于dstMetadata路由插件 EnableFailOverDefaultMeta bool // 自定义匹配规则,仅当EnableFailOverDefaultMeta为true时生效 FailOverDefaultMeta FailOverDefaultMetaConfig // 用户计算hash值的key HashKey []byte // 已经计算好的hash值,用于一致性hash的负载均衡选择 // Deprecated: 已弃用,请直接使用HashKey参数传入key来计算hash HashValue uint64 // 主调方服务信息 SourceService *ServiceInfo // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int // 可选,备份节点数 // 对于一致性hash等有状态的负载均衡方式 ReplicateCount int // 可选,负载均衡算法 LbPolicy string // 金丝雀 Canary string // contains filtered or unexported fields }
GetOneInstanceRequest 单个服务实例查询请求
func (*GetOneInstanceRequest) GetCanary ¶
func (g *GetOneInstanceRequest) GetCanary() string
func (*GetOneInstanceRequest) GetMetadata ¶
func (g *GetOneInstanceRequest) GetMetadata() map[string]string
GetMetadata 获取命名空间
func (*GetOneInstanceRequest) GetNamespace ¶
func (g *GetOneInstanceRequest) GetNamespace() string
GetNamespace 获取命名空间
func (*GetOneInstanceRequest) GetResponse ¶
func (g *GetOneInstanceRequest) GetResponse() *InstancesResponse
GetResponse 获取应答指针
func (*GetOneInstanceRequest) GetRetryCountPtr ¶
func (g *GetOneInstanceRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetOneInstanceRequest) GetService ¶
func (g *GetOneInstanceRequest) GetService() string
GetService 获取服务名
func (*GetOneInstanceRequest) GetTimeoutPtr ¶
func (g *GetOneInstanceRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetOneInstanceRequest) SetCanary ¶
func (g *GetOneInstanceRequest) SetCanary(canary string)
func (*GetOneInstanceRequest) SetRetryCount ¶
func (g *GetOneInstanceRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetOneInstanceRequest) SetTimeout ¶
func (g *GetOneInstanceRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (*GetOneInstanceRequest) Validate ¶
func (g *GetOneInstanceRequest) Validate() error
Validate 校验获取单个服务实例请求对象
type GetServiceRuleRequest ¶
type GetServiceRuleRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 命名空间 Namespace string // 服务名 Service string // 可选,仅对同步请求有效,本次查询最大超时信息,可选,默认直接获取全局的超时配置 Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int // contains filtered or unexported fields }
GetServiceRuleRequest 获取服务规则请求
func (*GetServiceRuleRequest) GetMetadata ¶
func (g *GetServiceRuleRequest) GetMetadata() map[string]string
GetMetadata 获取元数据信息
func (*GetServiceRuleRequest) GetNamespace ¶
func (g *GetServiceRuleRequest) GetNamespace() string
GetNamespace 获取命名空间
func (*GetServiceRuleRequest) GetResponse ¶
func (g *GetServiceRuleRequest) GetResponse() *ServiceRuleResponse
GetResponse 获取应答
func (*GetServiceRuleRequest) GetRetryCountPtr ¶
func (g *GetServiceRuleRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetServiceRuleRequest) GetService ¶
func (g *GetServiceRuleRequest) GetService() string
GetService 获取服务名
func (*GetServiceRuleRequest) GetTimeoutPtr ¶
func (g *GetServiceRuleRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetServiceRuleRequest) SetRetryCount ¶
func (g *GetServiceRuleRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetServiceRuleRequest) SetTimeout ¶
func (g *GetServiceRuleRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (*GetServiceRuleRequest) Validate ¶
func (g *GetServiceRuleRequest) Validate() error
Validate 校验获取服务规则请求对象
type GetServicesRequest ¶
type GetServicesRequest struct { // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 可选,是否使用业务过滤 EnableBusiness bool // 必选,业务名 Business string // 必选,命名空间 Namespace string // 可选,元数据信息,可用于过滤 Metadata map[string]string // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int }
func (*GetServicesRequest) GetRetryCountPtr ¶
func (g *GetServicesRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*GetServicesRequest) GetTimeoutPtr ¶
func (g *GetServicesRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*GetServicesRequest) SetRetryCount ¶
func (g *GetServicesRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*GetServicesRequest) SetTimeout ¶
func (g *GetServicesRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
type HealthCheckStatus ¶
type HealthCheckStatus int
HealthCheckStatus 健康探测状态
const ( // Healthy 节点探测结果已经恢复健康, 代表可以放开一部分流量 Healthy HealthCheckStatus = 1 // Dead 节点仍然不可用 Dead HealthCheckStatus = 2 )
type InitCalleeServiceRequest ¶
func (*InitCalleeServiceRequest) Validate ¶
func (g *InitCalleeServiceRequest) Validate() error
type Instance ¶
type Instance interface { // 获取实例四元组标识 GetInstanceKey() InstanceKey // 实例所在命名空间 GetNamespace() string // 实例所在服务名 GetService() string // 服务实例唯一标识 GetId() string // 实例的域名/IP信息 GetHost() string // 实例的监听端口 GetPort() uint32 // 实例的vpcId GetVpcId() string // 服务实例的协议 GetProtocol() string // 实例版本号 GetVersion() string // 实例静态权重值 GetWeight() int // 实例优先级信息 GetPriority() uint32 // 实例元数据信息 GetMetadata() map[string]string // 实例逻辑分区 GetLogicSet() string // 实例的断路器状态,包括: // 打开(被熔断)、半开(探测恢复)、关闭(正常运行) GetCircuitBreakerStatus() CircuitBreakerStatus // 实例是否健康,基于服务端返回的健康数据 IsHealthy() bool // 实例是否已经被手动隔离 IsIsolated() bool // 实例是否启动了健康检查 IsEnableHealthCheck() bool // 实例所属的大区信息 GetRegion() string // 实例所属的地方信息 GetZone() string // Deprecated,建议使用GetCampus方法 GetIDC() string // 实例所属的园区信息 GetCampus() string // 获取实例的修订版本信息 // 与上一次比较,用于确认服务实例是否发生变更 GetRevision() string }
Instance 服务实例信息
type InstanceAddEvent ¶
type InstanceAddEvent struct {
Instances []Instance
}
InstanceAddEvent 实例Add事件
type InstanceDeRegisterRequest ¶
type InstanceDeRegisterRequest struct { // 服务名 Service string // 服务访问Token ServiceToken string // 命名空间 Namespace string // 服务实例ID InstanceID string // 服务实例ip Host string // 服务实例端口 Port int // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int }
InstanceDeRegisterRequest 反注册服务请求
func (*InstanceDeRegisterRequest) GetRetryCountPtr ¶
func (g *InstanceDeRegisterRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*InstanceDeRegisterRequest) GetTimeoutPtr ¶
func (g *InstanceDeRegisterRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*InstanceDeRegisterRequest) SetRetryCount ¶
func (g *InstanceDeRegisterRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*InstanceDeRegisterRequest) SetTimeout ¶
func (g *InstanceDeRegisterRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (InstanceDeRegisterRequest) String ¶
func (g InstanceDeRegisterRequest) String() string
String 打印消息内容
func (*InstanceDeRegisterRequest) Validate ¶
func (i *InstanceDeRegisterRequest) Validate() error
Validate 校验InstanceDeRegisterRequest
type InstanceDeleteEvent ¶
type InstanceDeleteEvent struct {
Instances []Instance
}
InstanceDeleteEvent 实例Delete事件
type InstanceEvent ¶
type InstanceEvent struct { AddEvent *InstanceAddEvent UpdateEvent *InstanceUpdateEvent DeleteEvent *InstanceDeleteEvent }
InstanceEvent 实例事件
func (*InstanceEvent) GetSubScribeEventType ¶
func (e *InstanceEvent) GetSubScribeEventType() SubScribeEventType
GetSubScribeEventType
type InstanceGauge ¶
type InstanceGauge interface { // 获取服务的命名空间 GetNamespace() string // 获取服务名 GetService() string // 获取调用api GetAPI() ApiOperation // 实例的节点信息 GetHost() string // 实例的端口信息 GetPort() int // 实例的调用返回状态 GetRetStatus() RetStatus // 实例的熔断状态 GetCircuitBreakerStatus() CircuitBreakerStatus // 实例的返回码 GetRetCodeValue() int32 // 调用时延 GetDelay() *time.Duration // 调用时延 GetDelayRange() ApiDelayRange // 获取被调节点 GetCalledInstance() Instance // 检测指标是否合法 Validate() error }
InstanceGauge 针对单个实例的单次评估指标
type InstanceHeartbeatRequest ¶
type InstanceHeartbeatRequest struct { // 必选,服务名 Service string // 必选,服务访问Token ServiceToken string // 必选,命名空间 Namespace string // 必选,服务实例ID InstanceID string // 必选,服务实例ip Host string // 必选,服务实例端口 Port int // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int }
InstanceHeartbeatRequest 心跳上报请求
func (*InstanceHeartbeatRequest) GetRetryCountPtr ¶
func (g *InstanceHeartbeatRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*InstanceHeartbeatRequest) GetTimeoutPtr ¶
func (g *InstanceHeartbeatRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*InstanceHeartbeatRequest) SetRetryCount ¶
func (g *InstanceHeartbeatRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*InstanceHeartbeatRequest) SetTimeout ¶
func (g *InstanceHeartbeatRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (InstanceHeartbeatRequest) String ¶
func (g InstanceHeartbeatRequest) String() string
String 打印消息内容
func (*InstanceHeartbeatRequest) Validate ¶
func (i *InstanceHeartbeatRequest) Validate() error
Validate 校验InstanceDeRegisterRequest
type InstanceKey ¶
type InstanceKey struct { ServiceKey Host string Port int }
InstanceKey 服务实例的唯一标识
type InstanceRegisterRequest ¶
type InstanceRegisterRequest struct { // 必选,服务名 Service string // 必选,服务访问Token ServiceToken string // 必选,命名空间 Namespace string // 必选,服务监听host,支持IPv6地址 Host string // 必选,服务实例监听port Port int // 以下字段可选,默认nil表示客户端不配置,使用服务端配置 // 服务协议 Protocol *string // 服务权重,默认100,范围0-10000 Weight *int // 实例优先级,默认为0,数值越小,优先级越高 Priority *int // 实例提供服务版本号 Version *string // 用户自定义metadata信息 Metadata map[string]string // 该服务实例是否健康,默认健康 Healthy *bool // 该服务实例是否隔离,默认不隔离 Isolate *bool // ttl超时时间,如果节点要调用heartbeat上报,则必须填写,否则会400141错误码,单位:秒 TTL *int Location *Location // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int }
InstanceRegisterRequest 注册服务请求
func (*InstanceRegisterRequest) GetLocation ¶ added in v1.1.0
func (g *InstanceRegisterRequest) GetLocation() *Location
GetLocation 获取实例的地址信息
func (*InstanceRegisterRequest) GetRetryCountPtr ¶
func (g *InstanceRegisterRequest) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*InstanceRegisterRequest) GetTimeoutPtr ¶
func (g *InstanceRegisterRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*InstanceRegisterRequest) SetHealthy ¶
func (g *InstanceRegisterRequest) SetHealthy(healthy bool)
SetHealthy 设置实例是否健康
func (*InstanceRegisterRequest) SetIsolate ¶
func (g *InstanceRegisterRequest) SetIsolate(isolate bool)
SetIsolate 设置实例是否隔离
func (*InstanceRegisterRequest) SetLocation ¶ added in v1.1.0
func (g *InstanceRegisterRequest) SetLocation(loc *Location)
SetLocation 设置服务实例的地理信息
func (*InstanceRegisterRequest) SetRetryCount ¶
func (g *InstanceRegisterRequest) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*InstanceRegisterRequest) SetTTL ¶
func (g *InstanceRegisterRequest) SetTTL(ttl int)
SetTTL 设置服务实例TTL
func (*InstanceRegisterRequest) SetTimeout ¶
func (g *InstanceRegisterRequest) SetTimeout(duration time.Duration)
SetTimeout 设置超时时间
func (InstanceRegisterRequest) String ¶
func (g InstanceRegisterRequest) String() string
String 打印消息内容
func (*InstanceRegisterRequest) Validate ¶
func (g *InstanceRegisterRequest) Validate() error
Validate 校验InstanceRegisterRequest
type InstanceRegisterResponse ¶
InstanceRegisterResponse 注册服务应答
type InstanceSet ¶
type InstanceSet struct {
// contains filtered or unexported fields
}
InstanceSet 服务实例集合
func (*InstanceSet) GetInstances ¶
func (i *InstanceSet) GetInstances() WeightIndexSlice
GetInstances 获取实例下标集合
func (*InstanceSet) GetLock ¶
func (i *InstanceSet) GetLock() sync.Locker
GetLock 获取互斥锁,用于创建selector时使用,防止重复创建selector
func (*InstanceSet) GetRealInstances ¶
func (i *InstanceSet) GetRealInstances() []Instance
GetRealInstances 获取实例对象集合
func (*InstanceSet) GetSelector ¶
func (i *InstanceSet) GetSelector(id int32) ExtendedSelector
GetSelector 获取selector
func (*InstanceSet) GetServiceClusters ¶
func (i *InstanceSet) GetServiceClusters() ServiceClusters
GetServiceClusters 获取当前服务集群
func (*InstanceSet) SetSelector ¶
func (i *InstanceSet) SetSelector(selector ExtendedSelector)
SetSelector 设置selector
type InstanceUpdateEvent ¶
type InstanceUpdateEvent struct {
UpdateList []OneInstanceUpdate
}
InstanceUpdateEvent 实例Update事件
type InstanceWeight ¶
InstanceWeight 节点权重
type InstancesResponse ¶
type InstancesResponse struct { ServiceInfo // 可选,流水号,用于跟踪用户的请求,默认0 FlowID uint64 // 服务权重类型 TotalWeight int // 获取实例的修订版本信息 // 与上一次比较,用于确认服务实例是否发生变更 Revision string // 服务实例列表 Instances []Instance // 当前查询结果所属的集群,如果是获取GetOneInstance返回的结果,则为nil Cluster *Cluster }
InstancesResponse 服务实例查询应答
func (*InstancesResponse) GetCluster ¶ added in v1.2.0
func (i *InstancesResponse) GetCluster() *Cluster
InstancesResponse get the cluster
func (*InstancesResponse) GetInstance ¶
func (i *InstancesResponse) GetInstance(instanceId string) Instance
GetInstance 获取单个服务实例
func (*InstancesResponse) GetInstances ¶
func (i *InstancesResponse) GetInstances() []Instance
GetInstances 获取服务实例列表
func (*InstancesResponse) GetRevision ¶
func (i *InstancesResponse) GetRevision() string
GetRevision 获取服务的修订版本信息
func (*InstancesResponse) GetServiceClusters ¶
func (i *InstancesResponse) GetServiceClusters() ServiceClusters
GetServiceClusters 获取集群缓存
func (*InstancesResponse) GetTotalWeight ¶
func (i *InstancesResponse) GetTotalWeight() int
GetTotalWeight 获取全部实例总权重
func (*InstancesResponse) IsCacheLoaded ¶
func (i *InstancesResponse) IsCacheLoaded() bool
IsCacheLoaded 数据是否来自于缓存文件
func (*InstancesResponse) IsInitialized ¶
func (i *InstancesResponse) IsInitialized() bool
IsInitialized 服务实例列表是否已经加载
func (*InstancesResponse) ReloadServiceClusters ¶
func (i *InstancesResponse) ReloadServiceClusters()
ReloadServiceClusters 重建集群缓存
type LocationBasedMetaKey ¶
type LocationBasedMetaKey struct {
// contains filtered or unexported fields
}
LocationBasedMetaKey 基于某个地域信息的元数据查询key
type LocationInfo ¶
type LocationInfo interface { // 获取地域明细 GetLocation() *Location // 在地域信息获取过程中的错误信息 GetLastError() SDKError // 获取地域信息状态 GetStatus() uint32 // 查看地域信息是否已初始化状态 IsLocationInitialized() bool // 查看地域信息是否ready状态 IsLocationReady() bool }
LocationInfo 地域信息
type Mesh ¶
type Mesh interface { RegistryValue GetNamespace() string GetService() string GetValue() interface{} }
Mesh 网格
type MeshConfig ¶
type MeshConfig interface { RegistryValue GetNamespace() string GetService() string GetValue() interface{} }
MeshConfig 网格规则
type MeshConfigResponse ¶
type MeshConfigResponse struct { // 规则类型 Type EventType // 所属服务 Service ServiceKey // 规则对象,不同EventType对应不同类型实例 Value interface{} // 规则版本信息 Revision string // 规则缓存 // RuleCache RuleCache // 规则校验异常 ValidateError error }
MeshConfigResponse 网格规则应答
func (*MeshConfigResponse) GetNamespace ¶
func (s *MeshConfigResponse) GetNamespace() string
GetNamespace 获取命名空间
func (*MeshConfigResponse) GetRevision ¶
func (s *MeshConfigResponse) GetRevision() string
GetRevision 获取配置规则的修订版本信息
func (*MeshConfigResponse) GetService ¶
func (s *MeshConfigResponse) GetService() string
GetService 获取服务名
func (*MeshConfigResponse) GetValidateError ¶
func (s *MeshConfigResponse) GetValidateError() error
GetValidateError 获取规则校验异常
func (*MeshConfigResponse) GetValue ¶
func (s *MeshConfigResponse) GetValue() interface{}
GetValue 获取值 PB场景下,路由规则类型为*Routing
func (*MeshConfigResponse) IsInitialized ¶
func (s *MeshConfigResponse) IsInitialized() bool
IsInitialized 配置规则是否已经加载
type MeshResponse ¶
type MeshResponse struct { // 规则类型 Type EventType // 所属服务 Service ServiceKey // 规则对象,不同EventType对应不同类型实例 Value interface{} // 规则版本信息 Revision string // 规则缓存 // RuleCache RuleCache // 规则校验异常 ValidateError error }
MeshResponse 获取网格应答
func (*MeshResponse) GetNamespace ¶
func (s *MeshResponse) GetNamespace() string
GetNamespace 获取命名空间
func (*MeshResponse) GetRevision ¶
func (s *MeshResponse) GetRevision() string
GetRevision 获取配置规则的修订版本信息
func (*MeshResponse) GetValidateError ¶
func (s *MeshResponse) GetValidateError() error
GetValidateError 获取规则校验异常
func (*MeshResponse) GetValue ¶
func (s *MeshResponse) GetValue() interface{}
GetValue 获取值 PB场景下,路由规则类型为*Routing
func (*MeshResponse) IsInitialized ¶
func (s *MeshResponse) IsInitialized() bool
IsInitialized 配置规则是否已经加载
type MetaComposedValue ¶
type MetaComposedValue struct {
// contains filtered or unexported fields
}
MetaComposedValue 单个结构,针对单个会进行优化
type MetricType ¶
type MetricType int
MetricType 统计类型
const ( SDKAPIStat MetricType = iota ServiceStat InstanceStat SDKCfgStat CircuitBreakStat PluginAPIStat LoadBalanceStat RateLimitStat RouteStat )
type NotifyTrigger ¶
type NotifyTrigger struct { EnableDstInstances bool EnableDstRoute bool EnableSrcRoute bool EnableDstRateLimit bool EnableMeshConfig bool EnableServices bool EnableMesh bool }
NotifyTrigger 通知开关,标识本次需要获取哪些资源
type OnConfigFileChange ¶ added in v1.1.0
type OnConfigFileChange func(event ConfigFileChangeEvent)
OnConfigFileChange 配置文件变更回调监听器
type OneInstanceResponse ¶
type OneInstanceResponse struct {
InstancesResponse
}
func (*OneInstanceResponse) GetInstance ¶
func (o *OneInstanceResponse) GetInstance() Instance
GetInstance get the only instance
type OneInstanceUpdate ¶
OneInstanceUpdate 实例one update struct
type PeriodicCallBack ¶
type PeriodicCallBack interface { // 任务回调函数 // 参数说明: // lastProcessTime:上一次任务处理时间 // taskKey:任务数据主键 // taskValue: 任务数据值 // 返回值: // TaskResult:后续是否继续执行,本次是否忽略 Process(taskKey interface{}, taskValue interface{}, lastProcessTime time.Time) TaskResult // OnTaskEvent 任务事件回调 OnTaskEvent(event TaskEvent) }
PeriodicCallBack 回调接口
type PeriodicTask ¶
type PeriodicTask struct { // 任务标识 Name string // 定时任务回调 CallBack PeriodicCallBack // 是否需要处理高优先级任务 TakePriority bool // 是否长稳运行 LongRun bool // 调度周期 Period time.Duration // 是否延迟启动,为true的话,则会延迟一个周期再执行第一次任务 DelayStart bool }
PeriodicTask 周期执行的任务信息(含高优先级任务)
type PriorityCallBack ¶
type PriorityCallBack interface {
// 处理任务内容
Process()
}
PriorityCallBack 调度高优先级任务
type PriorityTask ¶
type PriorityTask struct { // 任务标识 Name string // 任务执行回调函数 CallBack PriorityCallBack }
PriorityTask 任务结构
type ProcessLoadBalanceRequest ¶ added in v1.2.0
type ProcessLoadBalanceRequest struct { // DstInstances indicate the destination instances resolved from discovery, required. // Two implementations to ServiceInstances: // 1. InstancesResponse, returned from ConsumerAPI.GetAllInstances. // 2. DefaultServiceInstances, for user to construct manually. DstInstances ServiceInstances // LbPolicy indicate the load balancer plugin, optional. // If empty, it will use the default load balancer config by console or sdk. LbPolicy string // HashKey indicate the hash key to do load balance, optional. HashKey []byte // ReplicateCount indicate the sibling count in consist hash ring, optional. ReplicateCount int // contains filtered or unexported fields }
ProcessLoadBalanceRequest the input request parameters for RouterAPI.ProcessLoadBalance
func (*ProcessLoadBalanceRequest) GetResponse ¶ added in v1.2.0
func (p *ProcessLoadBalanceRequest) GetResponse() *InstancesResponse
GetResponse get the response object
func (*ProcessLoadBalanceRequest) Validate ¶ added in v1.2.0
func (p *ProcessLoadBalanceRequest) Validate() error
Validate validate the request object
type ProcessRoutersRequest ¶ added in v1.2.0
type ProcessRoutersRequest struct { // Routers indicate the router plugins, optional. // If empty, it will use the default routers config by console or sdk. Routers []string // SourceService indicate the source service to match the route rule, optional. SourceService ServiceInfo // DstInstances indicate the destination instances resolved from discovery, required. // Two implementations to ServiceInstances: // 1. InstancesResponse, returned from ConsumerAPI.GetAllInstances. // 2. DefaultServiceInstances, for user to construct manually. DstInstances ServiceInstances // Method indicate the invoke method to match the route rule, optional. Method string // Timeout indicate the max timeout for single remote request, optional. // Total request timeout is (1+RetryCount) * Timeout, default is 1s Timeout *time.Duration // RetryCount indicate the request retry count, default is 0 RetryCount *int // contains filtered or unexported fields }
ProcessRoutersRequest the input request parameters for RouterAPI.ProcessRouters
func (*ProcessRoutersRequest) GetResponse ¶ added in v1.2.0
func (p *ProcessRoutersRequest) GetResponse() *InstancesResponse
GetResponse get the response object
func (*ProcessRoutersRequest) GetRetryCountPtr ¶ added in v1.2.0
func (p *ProcessRoutersRequest) GetRetryCountPtr() *int
GetRetryCountPtr get the retry count pointer
func (*ProcessRoutersRequest) GetTimeoutPtr ¶ added in v1.2.0
func (p *ProcessRoutersRequest) GetTimeoutPtr() *time.Duration
GetTimeoutPtr get the timeout pointer
func (*ProcessRoutersRequest) SetRetryCount ¶ added in v1.2.0
func (p *ProcessRoutersRequest) SetRetryCount(v int)
SetRetryCount set the retry count to request
func (*ProcessRoutersRequest) SetTimeout ¶ added in v1.2.0
func (p *ProcessRoutersRequest) SetTimeout(duration time.Duration)
SetTimeout set the timeout value to request
func (*ProcessRoutersRequest) Validate ¶ added in v1.2.0
func (p *ProcessRoutersRequest) Validate() error
Validate validate the request object
type QuotaAllocator ¶
type QuotaAllocator interface { // 执行配额分配操作 Allocate() *QuotaResponse // 执行配额回收操作 Release() }
QuotaAllocator 配额分配器,执行配额分配及回收
type QuotaFutureImpl ¶
type QuotaFutureImpl struct {
// contains filtered or unexported fields
}
QuotaFutureImpl 异步获取配额的future
func NewQuotaFuture ¶
func NewQuotaFuture(options ...quotaFutureOption) *QuotaFutureImpl
NewQuotaFuture 创建分配future 可以直接传入
type QuotaRequestImpl ¶
type QuotaRequestImpl struct { // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout *time.Duration // 可选,重试次数,默认直接获取全局的超时配置 RetryCount *int // contains filtered or unexported fields }
QuotaRequestImpl 配额获取的请求
func (*QuotaRequestImpl) GetCluster ¶
func (q *QuotaRequestImpl) GetCluster() string
GetCluster 获取集群
func (*QuotaRequestImpl) GetLabels ¶
func (q *QuotaRequestImpl) GetLabels() map[string]string
GetLabels 获取业务标签
func (*QuotaRequestImpl) GetNamespace ¶
func (q *QuotaRequestImpl) GetNamespace() string
GetNamespace 获取命名空间
func (*QuotaRequestImpl) GetRetryCountPtr ¶
func (q *QuotaRequestImpl) GetRetryCountPtr() *int
GetRetryCountPtr 获取重试次数指针
func (*QuotaRequestImpl) GetService ¶
func (q *QuotaRequestImpl) GetService() string
GetService 获取服务名
func (*QuotaRequestImpl) GetTimeoutPtr ¶
func (q *QuotaRequestImpl) GetTimeoutPtr() *time.Duration
GetTimeoutPtr 获取超时值指针
func (*QuotaRequestImpl) SetCluster ¶
func (q *QuotaRequestImpl) SetCluster(cluster string)
SetCluster 设置集群
func (*QuotaRequestImpl) SetLabels ¶
func (q *QuotaRequestImpl) SetLabels(labels map[string]string)
SetLabels 设置业务标签
func (*QuotaRequestImpl) SetNamespace ¶
func (q *QuotaRequestImpl) SetNamespace(namespace string)
SetNamespace 设置命名空间
func (*QuotaRequestImpl) SetRetryCount ¶
func (q *QuotaRequestImpl) SetRetryCount(retryCount int)
SetRetryCount 设置重试次数
func (*QuotaRequestImpl) SetService ¶
func (q *QuotaRequestImpl) SetService(svc string)
SetService 设置服务名称
func (*QuotaRequestImpl) SetTimeout ¶
func (q *QuotaRequestImpl) SetTimeout(timeout time.Duration)
SetTimeout 设置单次查询超时时间
type QuotaResponse ¶
type QuotaResponse struct { // 配额分配的返回码 Code QuotaResultCode // 配额分配的结果提示信息 Info string }
QuotaResponse 配额查询应答
type QuotaResultCode ¶
type QuotaResultCode int
QuotaResultCode 应答码
const ( QuotaResultOk QuotaResultCode = 0 QuotaResultLimited QuotaResultCode = -1 )
type RateLimitGauge ¶ added in v1.1.0
type RateLimitGauge struct { EmptyInstanceGauge Namespace string Service string Result QuotaResultCode Labels map[string]string }
type RegistryValue ¶
type RegistryValue interface { // 获取配置类型 GetType() EventType // 是否初始化,实例列表或路由值是否加载 IsInitialized() bool // 获取服务实例或规则的版本号 GetRevision() string }
RegistryValue 存储于sdk缓存中的对象,包括服务实例和服务路由
type ReplicateNodes ¶
type ReplicateNodes struct { // 所依附的集群缓存 SvcClusters ServiceClusters // 备份节点数 Count int // 实例下标 Indexes []int // 实例列表缓存 Instances atomic.Value }
ReplicateNodes 备份节点Set
func (*ReplicateNodes) GetInstances ¶
func (r *ReplicateNodes) GetInstances() []Instance
GetInstances 获取服务实例
type ReportClientRequest ¶
type ReportClientRequest struct { // 客户端进程唯一标识 ID string // 客户端IP地址 Host string // 客户端类型 Type string // 客户端版本信息 Version string // 可选,单次查询超时时间,默认直接获取全局的超时配置 // 用户总最大超时时间为(1+RetryCount) * Timeout Timeout time.Duration // 地理位置信息 Location *Location // 监控插件的上报信息 StatInfos []StatInfo // 持久化回调 PersistHandler func(message proto.Message) error }
ReportClientRequest 客户端上报请求信息
func (*ReportClientRequest) Validate ¶
func (r *ReportClientRequest) Validate() error
Validate 校验ReportClientRequest
type ReportClientResponse ¶
type ReportClientResponse struct { Mode RunMode Version string Region string Zone string Campus string }
ReportClientResponse 客户端上报应答信息
type RuleCache ¶
type RuleCache interface { // 通过字面值获取表达式对象 GetRegexMatcher(message string) *regexp.Regexp // 设置表达式对象, 非线程安全 PutRegexMatcher(message string, pattern *regexp.Regexp) // 获取消息缓存 GetMessageCache(message proto.Message) interface{} // 设置消息缓存 SetMessageCache(message proto.Message, cacheValue interface{}) }
RuleCache 服务规则缓存
type SDKError ¶
type SDKError interface { // 获取错误码 ErrorCode() ErrCode // 获取错误信息 Error() string // 获取服务端返回的错误码 ServerCode() uint32 // 获取服务端返回的错误信息 ServerInfo() string }
SDKError SDK错误的总封装类型
func NewSDKError ¶
NewSDKError SDK错误相关的类构建器
type SDKToken ¶
type SDKToken struct { IP string PID int32 UID string Client string Version string PodName string HostName string }
sdkContext的唯一标识
type SelectorBase ¶
type SelectorBase struct {
Id int32
}
SelectorBase 插件自定义的实例选择器base
func (*SelectorBase) ID ¶
func (s *SelectorBase) ID() int32
type ServiceCallResult ¶
type ServiceCallResult struct { EmptyInstanceGauge // 上报的服务实例 CalledInstance Instance // 调用接口方法 Method string // 必选,本地服务调用的状态,正常or异常 RetStatus RetStatus // 必选,本地服务调用的返回码 RetCode *int32 // 必选,被调服务实例获取接口的最大时延 Delay *time.Duration }
ServiceCallResult 服务调用结果
func (*ServiceCallResult) GetCalledInstance ¶
func (s *ServiceCallResult) GetCalledInstance() Instance
GetCalledInstance 获取被调服务实例
func (*ServiceCallResult) GetDelay ¶
func (s *ServiceCallResult) GetDelay() *time.Duration
GetDelay 调用时延
func (*ServiceCallResult) GetNamespace ¶
func (s *ServiceCallResult) GetNamespace() string
GetNamespace 实例所属命名空间
func (*ServiceCallResult) GetRetCode ¶
func (s *ServiceCallResult) GetRetCode() *int32
GetRetCode 实例的返回码
func (*ServiceCallResult) GetRetCodeValue ¶
func (s *ServiceCallResult) GetRetCodeValue() int32
GetRetCodeValue 实例的返回码
func (*ServiceCallResult) GetRetStatus ¶
func (s *ServiceCallResult) GetRetStatus() RetStatus
GetRetStatus 获取本地调用状态
func (*ServiceCallResult) GetService ¶
func (s *ServiceCallResult) GetService() string
GetService 实例所属服务名
func (*ServiceCallResult) SetCalledInstance ¶
func (s *ServiceCallResult) SetCalledInstance(inst Instance) *ServiceCallResult
SetCalledInstance 设置实例
func (*ServiceCallResult) SetDelay ¶
func (s *ServiceCallResult) SetDelay(duration time.Duration) *ServiceCallResult
SetDelay 设置时延值
func (*ServiceCallResult) SetRetCode ¶
func (s *ServiceCallResult) SetRetCode(value int32) *ServiceCallResult
SetRetCode 设置实例返回码
func (*ServiceCallResult) SetRetStatus ¶
func (s *ServiceCallResult) SetRetStatus(retStatus RetStatus) *ServiceCallResult
SetRetStatus 设置返回状态
func (*ServiceCallResult) Validate ¶
func (s *ServiceCallResult) Validate() error
Validate 校验InstanceDeRegisterRequest
type ServiceClusters ¶
type ServiceClusters interface { // 获取就近集群 GetNearbyCluster(location Location) (*Cluster, int) // 设置就近集群 SetNearbyCluster(location Location, cluster *Cluster, matchLevel int) // 获取缓存值 GetClusterInstances(cacheKey ClusterKey) *ClusterValue // 获取 包含指定key但是不匹配value 的ClusterValue GetContainNotMatchMetaKeyClusterInstances(cacheKey ClusterKey) *ClusterValue // 获取不包含指定meta的ClusterValue GetNotContainMetaKeyClusterInstances(cacheKey ClusterKey) *ClusterValue // 获取包含指定meta key的ClusterValue GetContainMetaKeyClusterInstances(cacheKey ClusterKey) *ClusterValue // 构建缓存实例 AddInstance(instance Instance) // 服务存在该大区 HasRegion(region string) bool // 服务存在该园区 HasZone(zone string) bool // 服务存在该机房 HasCampus(campus string) bool // 是否开启了就近路由 IsNearbyEnabled() bool // 是否开启了金丝雀路由 IsCanaryEnabled() bool // 获取实例的标签集合 GetInstanceMetaValues(location Location, metaKey string) map[string]string // 获取服务二元组信息 GetServiceKey() ServiceKey // 获取所属服务 GetServiceInstances() ServiceInstances // 获取扩展的缓存值 GetExtendedCacheValue(pluginIndex int) interface{} // 设置扩展的缓存值,需要预初始化好,否则会有并发修改的问题 SetExtendedCacheValue(pluginIndex int, value interface{}) }
ServiceClusters 集群缓存接口
func NewServiceClusters ¶
func NewServiceClusters(svcInstances ServiceInstances) ServiceClusters
NewServiceClusters 创建集群缓存
type ServiceEventKey ¶
type ServiceEventKey struct { // 服务标识 ServiceKey // 网格标识 // MeshKey // 值类型 Type EventType }
ServiceEventKey 服务加规则的唯一标识KEY
type ServiceInfo ¶
type ServiceInfo struct { // 必选,服务名 Service string // 必选,命名空间 Namespace string // 可选,服务元数据信息 Metadata map[string]string }
ServiceInfo 服务信息
func (*ServiceInfo) GetMetadata ¶
func (i *ServiceInfo) GetMetadata() map[string]string
GetMetadata 获取元数据信息
func (*ServiceInfo) HasService ¶ added in v1.2.0
func (i *ServiceInfo) HasService() bool
HasService 是否存在服务名
func (*ServiceInfo) IsEmpty ¶ added in v1.2.0
func (i *ServiceInfo) IsEmpty() bool
IsEmpty 服务数据内容是否为空
type ServiceInstances ¶
type ServiceInstances interface { ServiceMetadata RegistryValue // 获取服务实例列表 GetInstances() []Instance // 获取全部实例总权重 GetTotalWeight() int // 获取集群索引 GetServiceClusters() ServiceClusters // 重建缓存索引 ReloadServiceClusters() // 获取单个服务实例 GetInstance(string) Instance // 数据是否来自于缓存文件 IsCacheLoaded() bool }
ServiceInstances 服务实例列表
func NewDefaultServiceInstances ¶ added in v1.2.0
func NewDefaultServiceInstances(service ServiceInfo, instances []Instance) ServiceInstances
type ServiceKey ¶
ServiceKey 服务的唯一标识KEY
type ServiceMetadata ¶
type ServiceMetadata interface { // 获取服务名 GetService() string // 获取命名空间 GetNamespace() string // 获取元数据信息 GetMetadata() map[string]string }
ServiceMetadata 服务元数据信息
type ServiceRule ¶
type ServiceRule interface { RegistryValue // 获取路由所属服务的命名空间 GetNamespace() string // 获取路由所属服务的服务名 GetService() string // 获取值 // PB场景下,路由规则类型为*Routing GetValue() interface{} // 获取规则缓存信息 GetRuleCache() RuleCache // 获取规则校验失败异常 GetValidateError() error IsCacheLoaded() bool }
ServiceRule 服务配置通用接口
type ServiceRuleResponse ¶
type ServiceRuleResponse struct { // 规则类型 Type EventType // 所属服务 Service ServiceKey // 规则对象,不同EventType对应不同类型实例 Value interface{} // 规则版本信息 Revision string // 规则缓存 RuleCache RuleCache // 规则校验异常 ValidateError error }
ServiceRuleResponse 服务规则应答
func (*ServiceRuleResponse) GetNamespace ¶
func (s *ServiceRuleResponse) GetNamespace() string
GetNamespace 获取命名空间
func (*ServiceRuleResponse) GetRevision ¶
func (s *ServiceRuleResponse) GetRevision() string
GetRevision 获取配置规则的修订版本信息
func (*ServiceRuleResponse) GetRuleCache ¶
func (s *ServiceRuleResponse) GetRuleCache() RuleCache
GetRuleCache 获取规则缓存信息
func (*ServiceRuleResponse) GetService ¶
func (s *ServiceRuleResponse) GetService() string
GetService 获取服务名
func (*ServiceRuleResponse) GetType ¶
func (s *ServiceRuleResponse) GetType() EventType
GetType 获取配置类型
func (*ServiceRuleResponse) GetValidateError ¶
func (s *ServiceRuleResponse) GetValidateError() error
GetValidateError 获取规则校验异常
func (*ServiceRuleResponse) GetValue ¶
func (s *ServiceRuleResponse) GetValue() interface{}
GetValue 获取值 PB场景下,路由规则类型为*Routing
func (*ServiceRuleResponse) IsCacheLoaded ¶
func (s *ServiceRuleResponse) IsCacheLoaded() bool
func (*ServiceRuleResponse) IsInitialized ¶
func (s *ServiceRuleResponse) IsInitialized() bool
IsInitialized 配置规则是否已经加载
type Services ¶
type Services interface { RegistryValue GetNamespace() string GetService() string GetValue() interface{} }
Services 批量服务
type ServicesResponse ¶
type ServicesResponse struct { // 规则类型 Type EventType // 所属服务 Service ServiceKey // 规则对象,不同EventType对应不同类型实例 Value interface{} // 规则版本信息 Revision string // 规则缓存 // RuleCache RuleCache // 规则校验异常 ValidateError error }
ServicesResponse 批量服务应答
func (*ServicesResponse) GetNamespace ¶
func (s *ServicesResponse) GetNamespace() string
GetNamespace 获取命名空间
func (*ServicesResponse) GetRevision ¶
func (s *ServicesResponse) GetRevision() string
GetRevision 获取配置规则的修订版本信息
func (*ServicesResponse) GetService ¶
func (s *ServicesResponse) GetService() string
GetService 获取服务名
func (*ServicesResponse) GetValidateError ¶
func (s *ServicesResponse) GetValidateError() error
GetValidateError 获取规则校验异常
func (*ServicesResponse) GetValue ¶
func (s *ServicesResponse) GetValue() interface{}
GetValue 获取值 PB场景下,路由规则类型为*Routing
func (*ServicesResponse) IsInitialized ¶
func (s *ServicesResponse) IsInitialized() bool
IsInitialized 配置规则是否已经加载
type SubScribeEvent ¶
type SubScribeEvent interface { // GetSubScribeEventType GetSubScribeEventType() SubScribeEventType }
type SubScribeEventType ¶
type SubScribeEventType int
const ( // service实例事件 EventInstance SubScribeEventType = 1 )
type SyncHashSet ¶
type SyncHashSet struct {
// contains filtered or unexported fields
}
SyncHashSet 协程安全的HashSet
func (*SyncHashSet) Contains ¶
func (s *SyncHashSet) Contains(value interface{}) bool
Contains 检查元素存在性
type TaskResult ¶
type TaskResult int
任务处理结果
const ( // CONTINUE 本次任务处理完毕,更新时间戳并等待下一轮 CONTINUE TaskResult = iota // SKIP 本次任务无需执行,不更新时间戳 SKIP // TERMINATE 后续任务无需再执行 TERMINATE )
type TaskValue ¶
type TaskValue interface { // 比较两个元素 CompareTo(interface{}) int // 删除前进行检查,返回true才删除,该检查是同步操作 EnsureDeleted(value interface{}) bool }
TaskValue 任务值类型
type TaskValues ¶
type TaskValues interface { // 获取启动状态 Started() bool // 增加数据 // 对于非立即启动的任务,首次增加value时,协程才开始启动 AddValue(key interface{}, value TaskValue) // 删除数据 // 当缓存数据列表为空时,对于非长稳运行的任务,则会结束协程 DeleteValue(key interface{}, value TaskValue) }
TaskValues 定时任务处理的数据
type ValueContext ¶
type ValueContext interface { // 设置kv值 SetValue(key string, value interface{}) // 获取kv值 GetValue(key string) (interface{}, bool) // 获取当前节点地域信息 GetCurrentLocation() LocationInfo // 获取客户端ID GetClientId() string // 获取引擎接口 GetEngine() Engine // 等待location是否达到locationStatus WaitLocationInfo(ctx context.Context, locationStatus uint32) bool // 设置当前节点地域信息 // 返回是否由非ready转换为ready SetCurrentLocation(*Location, SDKError) bool // 获取当前时间戳 Now() time.Time // 计算时间间隔 Since(time.Time) time.Duration }
ValueContext 用于主流程传递kv数据的上下文对象,线程安全
type WatchServiceRequest ¶
type WatchServiceRequest struct {
Key ServiceKey
}
WatchServiceRequest WatchService req
func (*WatchServiceRequest) Validate ¶
func (req *WatchServiceRequest) Validate() error
Validate WatchServiceRequest 校验
type WatchServiceResponse ¶
type WatchServiceResponse struct { EventChannel <-chan SubScribeEvent GetAllInstancesResp *InstancesResponse }
WatchServiceResponse
type WeightedIndex ¶
WeightedIndex 带累加权重的索引