config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 16 Imported by: 65

Documentation

Index

Constants

View Source
const (
	// HealthCheckNever never active health check
	HealthCheckNever When = "never"
	// HealthCheckAlways always active health check
	HealthCheckAlways = "always"
	// HealthCheckOnRecover active health check when instance has fail
	HealthCheckOnRecover = "on_recover"
)
View Source
const (
	// 默认API调用的超时时间
	DefaultAPIInvokeTimeout = 1 * time.Second
	// 默认api调用重试次数
	DefaultAPIMaxRetryTimes int = 1
	// 默认api调用重试间隔
	DefaultAPIRetryInterval = 1 * time.Second
	// 默认首次发现discovery服务重试间隔
	DefaultDiscoverServiceRetryInterval = 5 * time.Second
	// 默认的服务超时淘汰时间
	DefaultServiceExpireTime = 24 * time.Hour
	// 默认的服务刷新间隔
	DefaultServiceRefreshIntervalDuration = 2 * time.Second
	// 默认SDK往Server连接超时时间间隔
	DefaultServerConnectTimeout = 500 * time.Millisecond
	// 默认重连的间隔
	DefaultReConnectInterval = 500 * time.Millisecond
	// 默认消息超时时间
	DefaultServerMessageTimeout = 1500 * time.Millisecond
	// 默认服务端stream闲置超时时间
	DefaultServerConnectionIdleTimeout = 3 * time.Second
	// 默认埋点server连接过期关闭时间
	DefaultBuiltInServerConnectionCloseTimeout = 2 * DefaultServerConnectionIdleTimeout
	// 默认发送队列的buffer大小,支持的最大瞬时并发度,默认1000
	DefaultRequestQueueSize int = 1000
	// 默认server的切换时间时间
	DefaultServerSwitchInterval = 10 * time.Minute
	// 默认缓存持久化存储目录
	DefaultCachePersistDir string = "./polaris/backup"
	// 持久化缓存写文件的默认重试次数
	DefaultPersistMaxWriteRetry int = 5
	// 读取持久化缓存的默认重试次数
	DefaultPersistMaxReadRetry = 1
	// 默认持久化重试间隔时间
	DefaultPersistRetryInterval = 1 * time.Second
	// 默认持久化文件有效时间
	DefaultPersistAvailableInterval = 60 * time.Second
	// 默认熔断节点检查周期
	DefaultCircuitBreakerCheckPeriod = 10 * time.Second
	// 最低熔断节点检查周期
	MinCircuitBreakerCheckPeriod = 1 * time.Second
	// 熔断器默认开启与否
	DefaultCircuitBreakerEnabled bool = true
	// 服务路由的全死全活默认开启与否
	DefaultRecoverAllEnabled bool = true
	// 路由至少返回节点数百分比
	DefaultPercentOfMinInstances float64 = 0.0
	// DefaultHealthCheckConcurrency 默认心跳检测的并发数
	DefaultHealthCheckConcurrency int = 1
	// DefaultHealthCheckConcurrencyAlways 默认持续心跳检测的并发数
	DefaultHealthCheckConcurrencyAlways int = 10
	// DefaultHealthCheckInterval 默认健康探测周期
	DefaultHealthCheckInterval = 10 * time.Second
	// MinHealthCheckInterval 最低健康探测周期
	MinHealthCheckInterval = 500 * time.Millisecond
	// DefaultHealthCheckTimeout 默认健康探测超时时间
	DefaultHealthCheckTimeout = 100 * time.Millisecond
	// 客户端信息上报周期,默认2分钟
	DefaultReportClientIntervalDuration = 2 * time.Minute
	// 最大重定向次数,默认1
	MaxRedirectTimes = 1
	// sdk配置上报周期
	DefaultReportSDKConfigurationInterval = 5 * time.Minute
	// 熔断周期,被熔断后多久变为半开
	DefaultSleepWindow = 30 * time.Second
	// 最小熔断周期,1s
	MinSleepWindow = 1 * time.Second
	// 默认恢复周期,半开后按多久的统计窗口进行恢复统计
	DefaultRecoverWindow = 60 * time.Second
	// 最小恢复周期,10s
	MinRecoverWindow = 10 * time.Second
	// 默认恢复统计的滑桶数
	DefaultRecoverNumBuckets = 10
	// 最小恢复统计的滑桶数
	MinRecoverNumBuckets = 1
	// 半开状态后分配的探测请求数
	DefaultRequestCountAfterHalfOpen = 10
	// 半开状态后恢复的成功请求数
	DefaultSuccessCountAfterHalfOpen = 8
	// 限流上报时间窗数量,上报间隔=时间间隔/时间窗数量
	DefaultRateLimitWindowCount = 10
	// 最小限流上报周期
	MinRateLimitReportInterval = 10 * time.Millisecond
	// 限流默认和sever acquire配额间隔, 弃用
	DefaultRateLimitAcquireInterval = 100 * time.Millisecond
	// 最大限流上报周期, 弃用
	MaxRateLimitReportInterval = 5 * time.Second
	// 默认满足百分之80的请求后立刻限流上报
	DefaultRateLimitReportAmountPresent = 80
	// 最大实时上报百分比
	MaxRateLimitReportAmountPresent = 100
	// 最小实时上报百分比
	MinRateLimitReportAmountPresent = 0
	// 默认的名字分隔符
	DefaultNamesSeparator = "#"
	// 默认Map组装str key value分割符
	DefaultMapKeyValueSeparator = ":"
	// 默认Map组装str (key:value) 二元组分割符
	DefaultMapKVTupleSeparator = "|"
	// 默认实例地理位置提供者插件名称
	DefaultLocationProvider = ""
	// 默认类型转化缓存的key数量
	DefaultPropertiesValueCacheSize = 100
	// 默认类型转化缓存的过期时间,1分钟
	DefaultPropertiesValueExpireTime = 60000
	// 默认连接器类型
	DefaultConnectorType = "polaris"
	// 默认连接器类型
	DefaultConfigConnectorAddresses = "127.0.0.1:8093"
)
View Source
const (
	// 默认的服务端连接器插件
	DefaultServerConnector string = "grpc"
	// 默认本地缓存策略
	DefaultLocalCache string = "inmemory"
	// 默认规则路由
	DefaultServiceRouterRuleBased string = "ruleBasedRouter"
	// 默认只过滤健康实例的路由
	DefaultServiceRouterFilterOnly string = "filterOnlyRouter"
	// 默认就近路由
	DefaultServiceRouterNearbyBased string = "nearbyBasedRouter"
	// DefaultServiceRouterSetDivision 默认set分组
	DefaultServiceRouterSetDivision string = "setDivisionRouter"

	// 默认基于目标元数据路由
	DefaultServiceRouterDstMeta string = "dstMetaRouter"
	// 金丝雀路由
	DefaultServiceRouterCanary string = "canaryRouter"

	// 默认负载均衡器,权重随机
	DefaultLoadBalancerWR string = "weightedRandom"
	// 负载均衡器,一致性hash环
	DefaultLoadBalancerRingHash string = "ringHash"
	// 负载均衡器,maglev hash
	DefaultLoadBalancerMaglev string = "maglev"
	// 负载均衡器,l5一致性hash兼容
	DefaultLoadBalancerL5CST string = "l5cst"
	// 负载均衡器,普通hash
	DefaultLoadBalancerHash string = "hash"
	// 默认错误率熔断器
	DefaultCircuitBreakerErrRate string = "errorRate"
	// 默认持续错误熔断器
	DefaultCircuitBreakerErrCount string = "errorCount"
	// 默认错误探测熔断器
	DefaultCircuitBreakerErrCheck string = "errorCheck"
	// 默认TCP探测器
	DefaultTCPHealthCheck string = "tcp"
	// 默认UDP探测器
	DefaultUDPHealthCheck string = "udp"

	// 默认的reject限流器
	DefaultRejectRateLimiter = "reject"
	// 默认warmup限流器
	DefaultWarmUpRateLimiter = "warmUp"
	// 默认的匀速限流器
	DefaultUniformRateLimiter = "unirate"
	// 默认限流插件,预热匀速
	DefaultWarmUpWaitLimiter = "warmup-wait"
	// 默认订阅事件处理插件
	SubscribeLocalChannel = "subscribeLocalChannel"

	// 默认限流最大窗口数量
	MaxRateLimitWindowSize = 20000
	// 默认超时清理时延
	DefaultRateLimitPurgeInterval = 1 * time.Minute
	// 默认的注册中心连接器插件
	DefaultConfigConnector string = "polaris"
)
View Source
const (
	DefaultMatchLevel = "zone"
	RegionLevel       = "region"
	ZoneLevel         = "zone"
	CampusLevel       = "campus"
	AllLevel          = ""
)

默认的就近路由配置

View Source
const (
	DefaultStatReporter         string = "stat2Monitor"
	DefaultCacheReporter        string = "serviceCache"
	DefaultPluginReporter       string = "pluginInfo"
	DefaultLoadBalanceReporter  string = "lbInfo"
	DefaultRateLimitReporter    string = "rateLimitRecord"
	DefaultServiceRouteReporter string = "serviceRoute"
	DefaultStatReportEnabled    bool   = false
)
View Source
const (
	DefaultMinServiceExpireTime         = 5 * time.Second
	DefaultMaxServiceExpireCheckTime    = 1 * time.Hour
	DefaultMinTimingInterval            = 100 * time.Millisecond
	DefaultServerServiceRefreshInterval = 1 * time.Minute
)
View Source
const (
	ServerNamespace        = "Polaris"
	ServerDiscoverService  = "polaris.discover"
	ServerHeartBeatService = "polaris.healthcheck"
	ServerMonitorService   = "polaris.monitor"
	ServerConfigService    = "polaris.config"
)

默认注册中心服务名

View Source
const (
	// TypeExact .
	TypeExact = "EXACT"
	// TypeRegex .
	TypeRegex = "REGEX"
)
View Source
const (
	// 系统默认配置文件
	DefaultConfigFile = "./polaris.yaml"
)
View Source
const ForbidServerMetricService = "polaris.metric"

ForbidServerMetricService 已经禁用的限流集群名

Variables

View Source
var (
	DefaultServerServiceRouterChain = []string{DefaultServiceRouterDstMeta, DefaultServiceRouterNearbyBased}
	// 系统命名空间下的服务默认路由链
	DefaultPolarisServicesRouterChain  = []string{DefaultServiceRouterDstMeta}
	DefaultServerServiceToLoadBalancer = map[ClusterType]string{
		DiscoverCluster:    DefaultLoadBalancerWR,
		ConfigCluster:      DefaultLoadBalancerWR,
		HealthCheckCluster: DefaultLoadBalancerMaglev,
		MonitorCluster:     DefaultLoadBalancerMaglev,
	}
	DefaultServerServiceToUseDefault = map[ClusterType]bool{
		DiscoverCluster:    true,
		HealthCheckCluster: true,
	}
)

系统服务相关变量

View Source
var (
	// DefaultConfigFileEnable 默认打开配置中心能力
	DefaultConfigFileEnable = true
)
View Source
var (
	// 默认打开限流能力
	DefaultRateLimitEnable = true
)
View Source
var (
	DefaultUseFileCacheFlag = true
)

Functions

func GetContainerNameEnvList

func GetContainerNameEnvList() []string

GetContainerNameEnvList 获取可以从获取的容器

func RegisterPluginConfigType

func RegisterPluginConfigType(typ common.Type, name string, cfg BaseConfig)

RegisterPlugin 注册插件到全局配置对象,并注册插件配置类型

func ServiceClusterToServiceKey

func ServiceClusterToServiceKey(config ServerClusterConfig) model.ServiceKey

ServiceClusterToServiceKey 服务集群信息转换为服务对象

Types

type APIConfig

type APIConfig interface {
	BaseConfig
	// GetTimeout global.api.timeout
	// 默认调用超时时间
	GetTimeout() time.Duration
	// SetTimeout 设置默认调用超时时间
	SetTimeout(time.Duration)
	// GetBindIntf global.api.bindIf
	// 默认客户端绑定的网卡地址
	GetBindIntf() string
	// SetBindIntf 设置默认客户端绑定的网卡地址
	SetBindIntf(string)
	// GetBindIP global.api.bindIP
	// 默认客户端绑定的IP地址
	GetBindIP() string
	// SetBindIP 设置默认客户端绑定的IP地址
	SetBindIP(string)
	// GetReportInterval global.api.reportInterval
	// 默认客户端定时上报周期
	GetReportInterval() time.Duration
	// SetReportInterval 设置默认客户端定时上报周期
	SetReportInterval(time.Duration)
	// GetMaxRetryTimes global.api.maxRetryTimes
	// api调用最多重试时间
	GetMaxRetryTimes() int
	// SetMaxRetryTimes 设置api调用最多重试时间
	SetMaxRetryTimes(int)
	// GetRetryInterval global.api.retryInterval
	// api调用重试时间
	GetRetryInterval() time.Duration
	// SetRetryInterval 设置api调用重试时间
	SetRetryInterval(time.Duration)
}

APIConfig api相关的配置对象

type APIConfigImpl

type APIConfigImpl struct {
	Timeout        *time.Duration `yaml:"timeout" json:"timeout"`
	BindIntf       string         `yaml:"bindIf" json:"bindIf"`
	BindIP         string         `yaml:"bindIP" json:"bindIP"`
	BindIPValue    string         `yaml:"-" json:"-"`
	ReportInterval *time.Duration `yaml:"reportInterval" json:"reportInterval"`
	MaxRetryTimes  int            `yaml:"maxRetryTimes" json:"maxRetryTimes"`
	RetryInterval  *time.Duration `yaml:"retryInterval" json:"retryInterval"`
}

APIConfigImpl API访问相关的配置

func (*APIConfigImpl) GetBindIP

func (a *APIConfigImpl) GetBindIP() string

GetBindIP 默认客户端绑定的网卡地址

func (*APIConfigImpl) GetBindIntf

func (a *APIConfigImpl) GetBindIntf() string

GetBindIntf 默认客户端绑定的网卡地址

func (*APIConfigImpl) GetMaxRetryTimes

func (a *APIConfigImpl) GetMaxRetryTimes() int

GetMaxRetryTimes 最大重试次数

func (*APIConfigImpl) GetReportInterval

func (a *APIConfigImpl) GetReportInterval() time.Duration

GetReportInterval 默认客户端上报周期

func (*APIConfigImpl) GetRetryInterval

func (a *APIConfigImpl) GetRetryInterval() time.Duration

GetRetryInterval 重试周期

func (*APIConfigImpl) GetTimeout

func (a *APIConfigImpl) GetTimeout() time.Duration

GetTimeout 默认调用超时时间

func (*APIConfigImpl) SetBindIP

func (a *APIConfigImpl) SetBindIP(bindIPValue string)

SetBindIP 设置默认客户端绑定的网卡地址

func (*APIConfigImpl) SetBindIntf

func (a *APIConfigImpl) SetBindIntf(bindIntf string)

SetBindIntf 设置默认客户端绑定的网卡地址

func (*APIConfigImpl) SetDefault

func (a *APIConfigImpl) SetDefault()

设置API配置的默认值

func (*APIConfigImpl) SetMaxRetryTimes

func (a *APIConfigImpl) SetMaxRetryTimes(maxRetryTimes int)

SetMaxRetryTimes 最大重试次数

func (*APIConfigImpl) SetReportInterval

func (a *APIConfigImpl) SetReportInterval(interval time.Duration)

SetReportInterval 设置默认客户端上报周期

func (*APIConfigImpl) SetRetryInterval

func (a *APIConfigImpl) SetRetryInterval(interval time.Duration)

SetRetryInterval 重试周期

func (*APIConfigImpl) SetTimeout

func (a *APIConfigImpl) SetTimeout(timeout time.Duration)

SetTimeout 设置默认超时时间

func (*APIConfigImpl) Verify

func (a *APIConfigImpl) Verify() error

检验API配置

type BaseConfig

type BaseConfig interface {
	// 校验配置是否OK
	Verify() error
	// 对关键值设置默认值
	SetDefault()
}

自身自带校验器的配置集合

type CircuitBreakerConfig

type CircuitBreakerConfig interface {
	BaseConfig
	PluginConfig
	// IsEnable 是否启用熔断
	IsEnable() bool
	// SetEnable 设置是否启用熔断
	SetEnable(bool)
	// GetChain 熔断器插件链
	GetChain() []string
	// SetChain 设置熔断器插件链
	SetChain([]string)
	// GetCheckPeriod 熔断器定时检测时间
	GetCheckPeriod() time.Duration
	// SetCheckPeriod 设置熔断器定时检测时间
	SetCheckPeriod(time.Duration)
	// GetSleepWindow 获取熔断周期
	GetSleepWindow() time.Duration
	// SetSleepWindow 设置熔断周期
	SetSleepWindow(interval time.Duration)
	// GetRequestCountAfterHalfOpen 获取半开状态后最多分配多少个探测请求
	GetRequestCountAfterHalfOpen() int
	// SetRequestCountAfterHalfOpen 设置半开状态后最多分配多少个探测请求
	SetRequestCountAfterHalfOpen(count int)
	// GetSuccessCountAfterHalfOpen 获取半开状态后多少个成功请求则恢复
	GetSuccessCountAfterHalfOpen() int
	// SetSuccessCountAfterHalfOpen 设置半开状态后多少个成功请求则恢复
	SetSuccessCountAfterHalfOpen(count int)
	// GetRecoverWindow 获取半开后的恢复周期,按周期来进行半开放量的统计
	GetRecoverWindow() time.Duration
	// SetRecoverWindow 设置半开后的恢复周期,按周期来进行半开放量的统计
	SetRecoverWindow(value time.Duration)
	// GetRecoverNumBuckets 半开后请求数统计滑桶数量
	GetRecoverNumBuckets() int
	// SetRecoverNumBuckets 设置半开后请求数统计滑桶数量
	SetRecoverNumBuckets(value int)
	// GetErrorCountConfig 连续错误数熔断配置
	GetErrorCountConfig() ErrorCountConfig
	// GetErrorRateConfig 错误率熔断配置
	GetErrorRateConfig() ErrorRateConfig
}

CircuitBreakerConfig 熔断相关的配置项

type CircuitBreakerConfigImpl

type CircuitBreakerConfigImpl struct {
	// Enable 是否启动熔断
	Enable *bool `yaml:"enable" json:"enable"`
	// CheckPeriod 熔断器定时检查周期
	CheckPeriod *time.Duration `yaml:"checkPeriod" json:"checkPeriod"`
	// Chain 熔断插件链
	Chain []string `yaml:"chain"`
	// SleepWindow 熔断周期,被熔断后多久可以变为半开
	SleepWindow *time.Duration `yaml:"sleepWindow" json:"sleepWindow"`
	// RequestCountAfterHalfOpen 半开状态后最多分配多少个探测请求
	RequestCountAfterHalfOpen int `yaml:"requestCountAfterHalfOpen" json:"requestCountAfterHalfOpen"`
	// SuccessCountAfterHalfOpen 半开状态后多少个成功请求则恢复
	SuccessCountAfterHalfOpen int `yaml:"successCountAfterHalfOpen" json:"successCountAfterHalfOpen"`
	// RecoverWindow 半开后的恢复周期,在这个周期内统计成功数
	RecoverWindow *time.Duration `yaml:"recoverWindow" json:"recoverWindow"`
	// RecoverNumBuckets 半开后的统计的滑窗数
	RecoverNumBuckets int `yaml:"recoverNumBuckets" json:"recoverNumBuckets"`
	// Plugin 插件配置反序列化后的对象
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

CircuitBreakerConfigImpl 熔断相关配置

func (*CircuitBreakerConfigImpl) GetChain

func (c *CircuitBreakerConfigImpl) GetChain() []string

GetChain 熔断器插件链

func (*CircuitBreakerConfigImpl) GetCheckPeriod

func (c *CircuitBreakerConfigImpl) GetCheckPeriod() time.Duration

GetCheckPeriod 熔断器定时检测时间

func (*CircuitBreakerConfigImpl) GetErrorCountConfig

func (c *CircuitBreakerConfigImpl) GetErrorCountConfig() ErrorCountConfig

GetErrorCountConfig 获取连续错误数熔断配置

func (*CircuitBreakerConfigImpl) GetErrorRateConfig

func (c *CircuitBreakerConfigImpl) GetErrorRateConfig() ErrorRateConfig

GetErrorRateConfig 错误率熔断配置

func (*CircuitBreakerConfigImpl) GetPluginConfig

func (c *CircuitBreakerConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig 获取一个熔断器插件配置

func (*CircuitBreakerConfigImpl) GetRecoverNumBuckets

func (c *CircuitBreakerConfigImpl) GetRecoverNumBuckets() int

GetRecoverNumBuckets 半开后请求数统计滑桶数量

func (*CircuitBreakerConfigImpl) GetRecoverWindow

func (c *CircuitBreakerConfigImpl) GetRecoverWindow() time.Duration

GetRecoverWindow 获取半开后的恢复周期,按周期来进行半开放量的统计

func (*CircuitBreakerConfigImpl) GetRequestCountAfterHalfOpen

func (c *CircuitBreakerConfigImpl) GetRequestCountAfterHalfOpen() int

GetRequestCountAfterHalfOpen 获取半开状态后最多分配多少个探测请求

func (*CircuitBreakerConfigImpl) GetSleepWindow

func (c *CircuitBreakerConfigImpl) GetSleepWindow() time.Duration

GetSleepWindow 获取熔断周期

func (*CircuitBreakerConfigImpl) GetSuccessCountAfterHalfOpen

func (c *CircuitBreakerConfigImpl) GetSuccessCountAfterHalfOpen() int

GetSuccessCountAfterHalfOpen 获取半开状态后多少个成功请求则恢复

func (*CircuitBreakerConfigImpl) Init

func (c *CircuitBreakerConfigImpl) Init()

Init 初始化CircuitBreakerConfigImpl配置

func (*CircuitBreakerConfigImpl) IsEnable

func (c *CircuitBreakerConfigImpl) IsEnable() bool

IsEnable 是否启用熔断

func (*CircuitBreakerConfigImpl) SetChain

func (c *CircuitBreakerConfigImpl) SetChain(chain []string)

SetChain 设置熔断器插件链

func (*CircuitBreakerConfigImpl) SetCheckPeriod

func (c *CircuitBreakerConfigImpl) SetCheckPeriod(period time.Duration)

SetCheckPeriod 设置熔断器定时检测时间

func (*CircuitBreakerConfigImpl) SetDefault

func (c *CircuitBreakerConfigImpl) SetDefault()

SetDefault 设置CircuitBreakerConfigImpl配置的默认值

func (*CircuitBreakerConfigImpl) SetEnable

func (c *CircuitBreakerConfigImpl) SetEnable(enable bool)

SetEnable 设置是否启用熔断

func (*CircuitBreakerConfigImpl) SetPluginConfig

func (c *CircuitBreakerConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 设置一个熔断器插件配置

func (*CircuitBreakerConfigImpl) SetRecoverNumBuckets

func (c *CircuitBreakerConfigImpl) SetRecoverNumBuckets(value int)

SetRecoverNumBuckets 设置半开后请求数统计滑桶数量

func (*CircuitBreakerConfigImpl) SetRecoverWindow

func (c *CircuitBreakerConfigImpl) SetRecoverWindow(value time.Duration)

SetRecoverWindow 设置半开后的恢复周期,按周期来进行半开放量的统计

func (*CircuitBreakerConfigImpl) SetRequestCountAfterHalfOpen

func (c *CircuitBreakerConfigImpl) SetRequestCountAfterHalfOpen(count int)

SetRequestCountAfterHalfOpen 设置半开状态后最多分配多少个探测请求

func (*CircuitBreakerConfigImpl) SetSleepWindow

func (c *CircuitBreakerConfigImpl) SetSleepWindow(interval time.Duration)

SetSleepWindow 设置熔断周期

func (*CircuitBreakerConfigImpl) SetSuccessCountAfterHalfOpen

func (c *CircuitBreakerConfigImpl) SetSuccessCountAfterHalfOpen(count int)

SetSuccessCountAfterHalfOpen 设置半开状态后多少个成功请求则恢复

func (*CircuitBreakerConfigImpl) Verify

func (c *CircuitBreakerConfigImpl) Verify() error

Verify 检验LocalCacheConfig配置

type ClusterService

type ClusterService struct {
	model.ServiceKey
	ClusterType   ClusterType
	ClusterConfig ServerClusterConfig
}

server集群服务信息

func (ClusterService) String

func (c ClusterService) String() string

集群服务打印信息

type ClusterType

type ClusterType string

集群类型,用以标识系统服务集群

const (
	BuiltinCluster     ClusterType = "builtin"
	DiscoverCluster    ClusterType = "discover"
	ConfigCluster      ClusterType = "config"
	HealthCheckCluster ClusterType = "healthCheck"
	MonitorCluster     ClusterType = "monitor"
)

默认集群类型

type ConfigConnectorConfig added in v1.1.0

type ConfigConnectorConfig interface {
	ServerConnectorConfig

	// GetConnectorType 后端服务器类型,默认是 polaris
	GetConnectorType() string
}

ConfigConnectorConfig 配置中心连接相关的配置

type ConfigConnectorConfigImpl added in v1.1.0

type ConfigConnectorConfigImpl struct {
	Addresses []string `yaml:"addresses" json:"addresses"`

	Protocol string `yaml:"protocol" json:"protocol"`

	ConnectTimeout *time.Duration `yaml:"connectTimeout" json:"connectTimeout"`

	// 远程请求超时时间
	MessageTimeout *time.Duration `yaml:"messageTimeout" json:"messageTimeout"`

	ConnectionIdleTimeout *time.Duration `yaml:"connectionIdleTimeout" json:"connectionIdleTimeout"`

	RequestQueueSize *int32 `yaml:"requestQueueSize" json:"requestQueueSize"`

	ServerSwitchInterval *time.Duration `yaml:"serverSwitchInterval" json:"serverSwitchInterval"`

	ReconnectInterval *time.Duration `yaml:"reconnectInterval" json:"reconnectInterval"`

	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`

	ConnectorType string `yaml:"connectorType" json:"connectorType"`
}

ConfigConnectorConfigImpl 对接配置中心连接器相关配置

func (*ConfigConnectorConfigImpl) GetAddresses added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetAddresses() []string

GetAddresses config.configConnector.addresses

func (*ConfigConnectorConfigImpl) GetConnectTimeout added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetConnectTimeout() time.Duration

GetConnectTimeout config.configConnector.connectTimeout

func (*ConfigConnectorConfigImpl) GetConnectionIdleTimeout added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetConnectionIdleTimeout() time.Duration

GetConnectionIdleTimeout config.configConnector.connectionIdleTimeout

func (*ConfigConnectorConfigImpl) GetConnectorType added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetConnectorType() string

GetConnectorType 获取连接器类型

func (*ConfigConnectorConfigImpl) GetMessageTimeout added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetMessageTimeout() time.Duration

GetMessageTimeout config.configConnector.messageTimeout

func (*ConfigConnectorConfigImpl) GetPluginConfig added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig config.configConnector.plugin

func (*ConfigConnectorConfigImpl) GetProtocol added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetProtocol() string

GetProtocol config.configConnector.protocol

func (*ConfigConnectorConfigImpl) GetReconnectInterval added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetReconnectInterval() time.Duration

GetReconnectInterval 一次连接失败后,到下一次连接之间的最小间隔时间

func (*ConfigConnectorConfigImpl) GetRequestQueueSize added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetRequestQueueSize() int32

GetRequestQueueSize config.configConnector.requestQueueSize

func (*ConfigConnectorConfigImpl) GetServerSwitchInterval added in v1.1.0

func (c *ConfigConnectorConfigImpl) GetServerSwitchInterval() time.Duration

GetServerSwitchInterval config.configConnector.serverSwitchInterval

func (*ConfigConnectorConfigImpl) Init added in v1.1.0

func (c *ConfigConnectorConfigImpl) Init()

Init 配置初始化

func (*ConfigConnectorConfigImpl) SetAddresses added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetAddresses(addresses []string)

SetAddresses 设置远端server地址,格式为<host>:<port>

func (*ConfigConnectorConfigImpl) SetConnectTimeout added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetConnectTimeout(timeout time.Duration)

SetConnectTimeout 设置与server的连接超时时间

func (*ConfigConnectorConfigImpl) SetConnectionIdleTimeout added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetConnectionIdleTimeout(timeout time.Duration)

SetConnectionIdleTimeout 设置连接空闲后超时时间

func (*ConfigConnectorConfigImpl) SetConnectorType added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetConnectorType(connectorType string)

SetConnectorType 设置连接器类型

func (*ConfigConnectorConfigImpl) SetDefault added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetDefault()

SetDefault 设置ConfigConnector配置的默认值

func (*ConfigConnectorConfigImpl) SetMessageTimeout added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetMessageTimeout(timeout time.Duration)

SetMessageTimeout 设置远程请求超时时间

func (*ConfigConnectorConfigImpl) SetPluginConfig added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*ConfigConnectorConfigImpl) SetProtocol added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetProtocol(protocol string)

SetProtocol 设置与server对接的协议

func (*ConfigConnectorConfigImpl) SetReconnectInterval added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetReconnectInterval(interval time.Duration)

SetReconnectInterval 一次连接失败后,到下一次连接之间的最小间隔时间

func (*ConfigConnectorConfigImpl) SetRequestQueueSize added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetRequestQueueSize(queueSize int32)

SetRequestQueueSize 设置新请求的队列BUFFER容量

func (*ConfigConnectorConfigImpl) SetServerSwitchInterval added in v1.1.0

func (c *ConfigConnectorConfigImpl) SetServerSwitchInterval(interval time.Duration)

SetServerSwitchInterval 设置server的切换时延

func (*ConfigConnectorConfigImpl) Verify added in v1.1.0

func (c *ConfigConnectorConfigImpl) Verify() error

Verify 检验ConfigConnector配置

type ConfigFileConfig added in v1.1.0

type ConfigFileConfig interface {
	BaseConfig
	// IsEnable 是否启用配置中心
	IsEnable() bool
	// GetConfigConnectorConfig 配置文件连接器
	GetConfigConnectorConfig() ConfigConnectorConfig
	// GetPropertiesValueCacheSize 值缓存的最大数量
	GetPropertiesValueCacheSize() int32
	// GetPropertiesValueExpireTime 缓存的过期时间,默认为 60s
	GetPropertiesValueExpireTime() int64
}

ConfigFileConfig 配置中心的配置

type ConfigFileConfigImpl added in v1.1.0

type ConfigFileConfigImpl struct {
	ConfigConnectorConfig *ConfigConnectorConfigImpl `yaml:"configConnector" json:"configConnector"`
	// 是否启动配置中心
	Enable                    *bool  `yaml:"enable" json:"enable"`
	PropertiesValueCacheSize  *int32 `yaml:"propertiesValueCacheSize" json:"propertiesValueCacheSize"`
	PropertiesValueExpireTime *int64 `yaml:"propertiesValueExpireTime" json:"propertiesValueExpireTime"`
}

对接配置中心相关配置

func (*ConfigFileConfigImpl) GetConfigConnectorConfig added in v1.1.0

func (c *ConfigFileConfigImpl) GetConfigConnectorConfig() ConfigConnectorConfig

GetConfigConnectorConfig config.configConnector前缀开头的所有配置项

func (*ConfigFileConfigImpl) GetPropertiesValueCacheSize added in v1.1.0

func (c *ConfigFileConfigImpl) GetPropertiesValueCacheSize() int32

GetPropertiesValueCacheSize config.propertiesValueCacheSize

func (*ConfigFileConfigImpl) GetPropertiesValueExpireTime added in v1.1.0

func (c *ConfigFileConfigImpl) GetPropertiesValueExpireTime() int64

GetPropertiesValueExpireTime config.propertiesValueExpireTime

func (*ConfigFileConfigImpl) Init added in v1.1.0

func (c *ConfigFileConfigImpl) Init()

Init 配置初始化

func (*ConfigFileConfigImpl) IsEnable added in v1.1.0

func (c *ConfigFileConfigImpl) IsEnable() bool

IsEnable config.enable

func (*ConfigFileConfigImpl) SetDefault added in v1.1.0

func (c *ConfigFileConfigImpl) SetDefault()

SetDefault 设置ConfigConnector配置的默认值

func (*ConfigFileConfigImpl) SetEnable added in v1.1.0

func (c *ConfigFileConfigImpl) SetEnable(enable bool)

SetEnable 设置是否开启配置中心功能

func (*ConfigFileConfigImpl) SetPropertiesValueCacheSize added in v1.1.0

func (c *ConfigFileConfigImpl) SetPropertiesValueCacheSize(propertiesValueCacheSize int32)

SetPropertiesValueCacheSize 设置类型转化缓存的key数量

func (*ConfigFileConfigImpl) SetPropertiesValueExpireTime added in v1.1.0

func (c *ConfigFileConfigImpl) SetPropertiesValueExpireTime(propertiesValueExpireTime int64)

SetPropertiesValueExpireTime 设置类型转化缓存的过期时间,默认为1分钟

func (*ConfigFileConfigImpl) Verify added in v1.1.0

func (c *ConfigFileConfigImpl) Verify() error

Verify 检验ConfigConnector配置

type Configuration

type Configuration interface {
	BaseConfig
	// GetGlobal global前缀开头的所有配置项
	GetGlobal() GlobalConfig
	// GetConsumer consumer前缀开头的所有配置项
	GetConsumer() ConsumerConfig
	// GetProvider provider前缀开头的所有配置项
	GetProvider() ProviderConfig
	// GetConfigFile config前缀开头的所有配置项
	GetConfigFile() ConfigFileConfig
}

Configuration 全量配置对象

type ConfigurationImpl

type ConfigurationImpl struct {
	Global   *GlobalConfigImpl     `yaml:"global" json:"global"`
	Consumer *ConsumerConfigImpl   `yaml:"consumer" json:"consumer"`
	Provider *ProviderConfigImpl   `yaml:"provider" json:"provider"`
	Config   *ConfigFileConfigImpl `yaml:"config" json:"config"`
}

ConfigurationImpl cl5全局配置

func LoadConfiguration

func LoadConfiguration(buf []byte) (*ConfigurationImpl, error)

LoadConfiguration 加载配置项

func LoadConfigurationByDefaultFile

func LoadConfigurationByDefaultFile() (*ConfigurationImpl, error)

LoadConfigurationByDefaultFile 通过默认配置文件加载配置项

func LoadConfigurationByFile

func LoadConfigurationByFile(path string) (*ConfigurationImpl, error)

LoadConfigurationByFile 通过文件加载配置项

func NewDefaultConfiguration

func NewDefaultConfiguration(addresses []string) *ConfigurationImpl

NewDefaultConfiguration 创建默认配置对象

func NewDefaultConfigurationWithDomain

func NewDefaultConfigurationWithDomain() *ConfigurationImpl

NewDefaultConfigurationWithDomain 创建带有默认埋点server域名的默认配置

func (*ConfigurationImpl) GetConfigFile added in v1.1.0

func (c *ConfigurationImpl) GetConfigFile() ConfigFileConfig

GetConfig config前缀开头的所有配置项

func (*ConfigurationImpl) GetConsumer

func (c *ConfigurationImpl) GetConsumer() ConsumerConfig

GetConsumer cl5.consumer前缀开头的所有配置项

func (*ConfigurationImpl) GetGlobal

func (c *ConfigurationImpl) GetGlobal() GlobalConfig

GetGlobal cl5.global前缀开头的所有配置项

func (*ConfigurationImpl) GetProvider

func (c *ConfigurationImpl) GetProvider() ProviderConfig

GetProvider consumer前缀开头的所有配置项

func (*ConfigurationImpl) Init

func (c *ConfigurationImpl) Init()

初始化整体配置对象

func (*ConfigurationImpl) SetDefault

func (c *ConfigurationImpl) SetDefault()

设置consumerConfig配置的默认值

func (*ConfigurationImpl) Verify

func (c *ConfigurationImpl) Verify() error

检验configuration配置

type ConsumerConfig

type ConsumerConfig interface {
	BaseConfig
	// GetLocalCache get local cache config
	GetLocalCache() LocalCacheConfig
	// GetServiceRouter get service router config
	GetServiceRouter() ServiceRouterConfig
	// GetLoadbalancer get load balancer config
	GetLoadbalancer() LoadbalancerConfig
	// GetCircuitBreaker get circuit breaker config
	GetCircuitBreaker() CircuitBreakerConfig
	// GetHealthCheck get health check config
	GetHealthCheck() HealthCheckConfig
	// GetSubScribe get subscribe config
	GetSubScribe() SubscribeConfig
	// GetServiceSpecific 服务独立配置
	GetServiceSpecific(namespace string, service string) ServiceSpecificConfig
}

ConsumerConfig consumer config object

type ConsumerConfigImpl

type ConsumerConfigImpl struct {
	LocalCache       *LocalCacheConfigImpl     `yaml:"localCache" json:"localCache"`
	ServiceRouter    *ServiceRouterConfigImpl  `yaml:"serviceRouter" json:"serviceRouter"`
	Loadbalancer     *LoadBalancerConfigImpl   `yaml:"loadbalancer" json:"loadbalancer"`
	CircuitBreaker   *CircuitBreakerConfigImpl `yaml:"circuitBreaker" json:"circuitBreaker"`
	HealthCheck      *HealthCheckConfigImpl    `yaml:"healthCheck" json:"healthCheck"`
	Subscribe        *SubscribeImpl            `yaml:"subscribe" json:"subscribe"`
	ServicesSpecific []*ServiceSpecific        `yaml:"servicesSpecific" json:"servicesSpecific"`
}

ConsumerConfigImpl 消费者配置

func (*ConsumerConfigImpl) GetCircuitBreaker

func (c *ConsumerConfigImpl) GetCircuitBreaker() CircuitBreakerConfig

GetCircuitBreaker consumer.circuitbreaker前缀开头的所有配置

func (*ConsumerConfigImpl) GetHealthCheck

func (c *ConsumerConfigImpl) GetHealthCheck() HealthCheckConfig

GetHealthCheck get health check config

func (*ConsumerConfigImpl) GetLoadbalancer

func (c *ConsumerConfigImpl) GetLoadbalancer() LoadbalancerConfig

GetLoadbalancer consumer.loadbalancer前缀开头的所有配置

func (*ConsumerConfigImpl) GetLocalCache

func (c *ConsumerConfigImpl) GetLocalCache() LocalCacheConfig

GetLocalCache consumer.localCache前缀开头的所有配置

func (*ConsumerConfigImpl) GetServiceRouter

func (c *ConsumerConfigImpl) GetServiceRouter() ServiceRouterConfig

GetServiceRouter consumer.serviceRouter前缀开头的所有配置

func (*ConsumerConfigImpl) GetServiceSpecific

func (c *ConsumerConfigImpl) GetServiceSpecific(namespace string, service string) ServiceSpecificConfig

GetServiceSpecific 服务独立配置

func (*ConsumerConfigImpl) GetSubScribe

func (c *ConsumerConfigImpl) GetSubScribe() SubscribeConfig

GetSubScribe 订阅配置

func (*ConsumerConfigImpl) Init

func (c *ConsumerConfigImpl) Init()

初始化ConsumerConfigImpl

func (*ConsumerConfigImpl) SetDefault

func (c *ConsumerConfigImpl) SetDefault()

设置consumerConfig配置的默认值

func (*ConsumerConfigImpl) Verify

func (c *ConsumerConfigImpl) Verify() error

检验consumerConfig配置

type ErrorCountConfig

type ErrorCountConfig interface {
	// 连续错误数阈值
	GetContinuousErrorThreshold() int
	// 设置连续错误数阈值
	SetContinuousErrorThreshold(int)
	// 连续错误数统计时间窗口
	GetMetricStatTimeWindow() time.Duration
	// 设置连续错误数统计时间窗口
	SetMetricStatTimeWindow(time.Duration)
	// 连续错误数统计滑桶数量
	GetMetricNumBuckets() int
	// 设置连续错误数统计滑桶数量
	SetMetricNumBuckets(int)
	// 获取单个滑桶的时间间隔
	GetBucketInterval() time.Duration
}

ErrorCountConfig 连续错误数熔断配置

type ErrorRateConfig

type ErrorRateConfig interface {
	// 触发错误率熔断的请求量阈值
	GetRequestVolumeThreshold() int
	// 设置触发错误率熔断的请求量阈值
	SetRequestVolumeThreshold(int)
	// 触发熔断的错误率阈值,取值范围(0, 100]
	GetErrorRatePercent() int
	// 设置错误率阈值
	SetErrorRatePercent(int)
	// 错误率统计时间窗口
	GetMetricStatTimeWindow() time.Duration
	// 设置错误率统计时间窗口
	SetMetricStatTimeWindow(time.Duration)
	// 统计窗口细分的桶数量
	GetMetricNumBuckets() int
	// 设置统计窗口细分的桶数量
	SetMetricNumBuckets(int)
	// 获取单个滑桶的时间间隔
	GetBucketInterval() time.Duration
}

ErrorRateConfig 错误率熔断配置

type GlobalConfig

type GlobalConfig interface {
	BaseConfig
	// GetSystem .
	GetSystem() SystemConfig
	// GetAPI global.api前缀开头的所有配置项
	GetAPI() APIConfig
	// GetServerConnector global.serverConnector前缀开头的所有配置项
	GetServerConnector() ServerConnectorConfig
	// GetStatReporter global.statReporter前缀开头的所有配置项
	GetStatReporter() StatReporterConfig
	// GetLocation global.location前缀开头的所有配置项
	GetLocation() LocationConfig
}

GlobalConfig 全局配置对象

type GlobalConfigImpl

type GlobalConfigImpl struct {
	System          *SystemConfigImpl          `yaml:"system" json:"system"`
	API             *APIConfigImpl             `yaml:"api" json:"api"`
	ServerConnector *ServerConnectorConfigImpl `yaml:"serverConnector" json:"serverConnector"`
	StatReporter    *StatReporterConfigImpl    `yaml:"statReporter" json:"statReporter"`
	Location        *LocationConfigImpl        `yaml:"location" json:"location"`
}

GlobalConfigImpl 全局配置

func (*GlobalConfigImpl) GetAPI

func (g *GlobalConfigImpl) GetAPI() APIConfig

GetAPI global.api前缀开头的所有配置项

func (*GlobalConfigImpl) GetLocation added in v1.1.0

func (g *GlobalConfigImpl) GetLocation() LocationConfig

func (*GlobalConfigImpl) GetServerConnector

func (g *GlobalConfigImpl) GetServerConnector() ServerConnectorConfig

GetServerConnector global.serverConnector前缀开头的所有配置项

func (*GlobalConfigImpl) GetStatReporter

func (g *GlobalConfigImpl) GetStatReporter() StatReporterConfig

GetStatReporter cl5.global.statReporter前缀开头的所有配置项

func (*GlobalConfigImpl) GetSystem

func (g *GlobalConfigImpl) GetSystem() SystemConfig

GetSystem 获取系统配置

func (*GlobalConfigImpl) Init

func (g *GlobalConfigImpl) Init()

全局配置初始化

func (*GlobalConfigImpl) SetDefault

func (g *GlobalConfigImpl) SetDefault()

设置globalConfig配置的默认值

func (*GlobalConfigImpl) Verify

func (g *GlobalConfigImpl) Verify() error

检验globalConfig配置

type HealthCheckConfig

type HealthCheckConfig interface {
	BaseConfig
	PluginConfig
	// GetWhen get when to active health check
	GetWhen() When
	// SetWhen set when to active health check
	SetWhen(When)
	// GetInterval get health check interval
	GetInterval() time.Duration
	// SetInterval set health check interval
	SetInterval(duration time.Duration)
	// GetTimeout get health check max timeout
	GetTimeout() time.Duration
	// SetTimeout set health check max timeout
	SetTimeout(duration time.Duration)
	// GetConcurrency get concurrency to execute the health check jobs
	GetConcurrency() int
	// SetConcurrency set concurrency to execute the health check jobs
	SetConcurrency(int)
	// GetChain get health checking chain
	GetChain() []string
	// SetChain set health checking chain
	SetChain([]string)
}

HealthCheckConfig active health check config

type HealthCheckConfigImpl

type HealthCheckConfigImpl struct {
	When        When          `yaml:"when" json:"when"`
	Interval    time.Duration `yaml:"interval" json:"interval"`
	Timeout     time.Duration `yaml:"timeout" json:"timeout"`
	Chain       []string      `yaml:"chain" json:"chain"`
	Concurrency int           `yaml:"concurrency" json:"concurrency"`
	Plugin      PluginConfigs `yaml:"plugin" json:"plugin"`
}

HealthCheckConfigImpl health check config implementation

func (*HealthCheckConfigImpl) GetChain

func (h *HealthCheckConfigImpl) GetChain() []string

GetChain get health checking chain

func (*HealthCheckConfigImpl) GetConcurrency

func (h *HealthCheckConfigImpl) GetConcurrency() int

GetConcurrency get concurrency to execute the health check jobs

func (*HealthCheckConfigImpl) GetInterval

func (h *HealthCheckConfigImpl) GetInterval() time.Duration

GetInterval get health check interval

func (*HealthCheckConfigImpl) GetPluginConfig

func (h *HealthCheckConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig get plugin config by name

func (*HealthCheckConfigImpl) GetTimeout

func (h *HealthCheckConfigImpl) GetTimeout() time.Duration

GetTimeout get health check max timeout

func (*HealthCheckConfigImpl) GetWhen

func (h *HealthCheckConfigImpl) GetWhen() When

GetWhen get when to active health check

func (*HealthCheckConfigImpl) Init

func (h *HealthCheckConfigImpl) Init()

Init 初始化CircuitBreakerConfigImpl配置

func (*HealthCheckConfigImpl) SetChain

func (h *HealthCheckConfigImpl) SetChain(chain []string)

SetChain set health checking chain

func (*HealthCheckConfigImpl) SetConcurrency

func (h *HealthCheckConfigImpl) SetConcurrency(value int)

SetConcurrency set concurrency to execute the health check jobs

func (*HealthCheckConfigImpl) SetDefault

func (h *HealthCheckConfigImpl) SetDefault()

SetDefault set default values to healthCheckConfig

func (*HealthCheckConfigImpl) SetInterval

func (h *HealthCheckConfigImpl) SetInterval(duration time.Duration)

SetInterval set health check interval

func (*HealthCheckConfigImpl) SetPluginConfig

func (h *HealthCheckConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig set plugin config by name

func (*HealthCheckConfigImpl) SetTimeout

func (h *HealthCheckConfigImpl) SetTimeout(duration time.Duration)

SetTimeout set health check max timeout

func (*HealthCheckConfigImpl) SetWhen

func (h *HealthCheckConfigImpl) SetWhen(when When)

SetWhen set when to active health check

func (*HealthCheckConfigImpl) Verify

func (h *HealthCheckConfigImpl) Verify() error

Verify verify the healthCheckConfig

type LoadBalancerConfigImpl

type LoadBalancerConfigImpl struct {
	// 负载均衡类型
	Type string `yaml:"type" json:"type"`
	// 插件相关配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

LoadBalancerConfigImpl 负载均衡配置

func (*LoadBalancerConfigImpl) GetPluginConfig

func (l *LoadBalancerConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig consumer.loadbalancer.plugin

func (*LoadBalancerConfigImpl) GetType

func (l *LoadBalancerConfigImpl) GetType() string

GetType 负载均衡类型

func (*LoadBalancerConfigImpl) Init

func (l *LoadBalancerConfigImpl) Init()

Init 负载均衡配置初始化

func (*LoadBalancerConfigImpl) SetDefault

func (l *LoadBalancerConfigImpl) SetDefault()

SetDefault 设置LocalCacheConfig配置的默认值

func (*LoadBalancerConfigImpl) SetPluginConfig

func (l *LoadBalancerConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*LoadBalancerConfigImpl) SetType

func (l *LoadBalancerConfigImpl) SetType(typ string)

SetType 设置负载均衡类型

func (*LoadBalancerConfigImpl) Verify

func (l *LoadBalancerConfigImpl) Verify() error

Verify 检验LocalCacheConfig配置

type LoadbalancerConfig

type LoadbalancerConfig interface {
	BaseConfig
	PluginConfig
	// GetType 负载均衡类型
	GetType() string
	// SetType 设置负载均衡类型
	SetType(string)
}

LoadbalancerConfig 负载均衡相关配置项

type LocalCacheConfig

type LocalCacheConfig interface {
	BaseConfig
	PluginConfig
	// GetServiceExpireTime consumer.localCache.service.expireTime,
	// 服务的超时淘汰时间
	GetServiceExpireTime() time.Duration
	// SetServiceExpireTime 设置服务的超时淘汰时间
	SetServiceExpireTime(time.Duration)
	// GetServiceRefreshInterval consumer.localCache.service.refreshInterval
	// 服务的定期刷新时间
	GetServiceRefreshInterval() time.Duration
	// SetServiceRefreshInterval 设置服务的定期刷新时间
	SetServiceRefreshInterval(time.Duration)
	// GetPersistDir consumer.localCache.persistDir
	// 本地缓存持久化路径
	GetPersistDir() string
	// SetPersistDir 设置本地缓存持久化路径
	SetPersistDir(string)
	// GetType consumer.localCache.type
	// 本地缓存类型,默认default,可修改成具体的缓存插件名
	GetType() string
	// SetType 设置本地缓存类型
	SetType(string)
	// GetPersistMaxWriteRetry consumer.localCache.persistMaxWriteRetry
	// 缓存最大写重试次数
	GetPersistMaxWriteRetry() int
	// SetPersistMaxWriteRetry 设置缓存最大写重试次数
	SetPersistMaxWriteRetry(int)
	// GetPersistMaxReadRetry consumer.localCache.persistMaxReadRetry
	// 缓存最大读重试次数
	GetPersistMaxReadRetry() int
	// SetPersistMaxReadRetry 设置缓存最大读重试次数
	SetPersistMaxReadRetry(int)
	// GetPersistRetryInterval consumer.localCache.persistRetryInterval
	// 缓存持久化重试间隔
	GetPersistRetryInterval() time.Duration
	// SetPersistRetryInterval 设置缓存持久化重试间隔
	SetPersistRetryInterval(time.Duration)
	// GetPersistAvailableInterval 获取缓存文件有效时间
	GetPersistAvailableInterval() time.Duration
	// SetPersistAvailableInterval 设置缓存文件有效时间
	SetPersistAvailableInterval(interval time.Duration)
	// GetStartUseFileCache 获取是否可以直接使用缓存标签
	GetStartUseFileCache() bool
	// SetStartUseFileCache 设置是否可以直接使用缓存
	SetStartUseFileCache(useCacheFile bool)
}

LocalCacheConfig 本地缓存相关配置项

type LocalCacheConfigImpl

type LocalCacheConfigImpl struct {
	// consumer.localCache.service.expireTime,
	// 服务的超时淘汰时间
	ServiceExpireTime *time.Duration `yaml:"serviceExpireTime" json:"serviceExpireTime"`
	// consumer.localCache.service.refreshInterval
	// 服务的定期刷新时间
	ServiceRefreshInterval *time.Duration `yaml:"serviceRefreshInterval" json:"serviceRefreshInterval"`
	// consumer.localCache.persistDir
	// 本地缓存持久化路径
	PersistDir string `yaml:"persistDir" json:"persistDir"`
	// consumer.localCache.type
	// 本地缓存类型,默认inmemory,可修改成具体的缓存插件名
	Type string `yaml:"type" json:"type"`
	// consumer.localCache.persistMaxWriteRetry
	PersistMaxWriteRetry int `yaml:"persistMaxWriteRetry" json:"persistMaxWriteRetry"`
	// consumer.localCache.persistReadRetry
	PersistMaxReadRetry int `yaml:"persistMaxReadRetry" json:"persistMaxReadRetry"`
	// consumer.localCache.persistRetryInterval
	PersistRetryInterval *time.Duration `yaml:"persistRetryInterval" json:"persistRetryInterval"`
	// 缓存文件有效时间差值
	PersistAvailableInterval *time.Duration `yaml:"persistAvailableInterval" json:"persistAvailableInterval"`
	// 启动后,首次名字服务是否可以使用缓存文件
	StartUseFileCache *bool `yaml:"startUseFileCache" json:"startUseFileCache"`
	// 插件相关配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

LocalCacheConfigImpl 本地缓存配置

func (*LocalCacheConfigImpl) GetPersistAvailableInterval

func (l *LocalCacheConfigImpl) GetPersistAvailableInterval() time.Duration

GetPersistAvailableInterval

func (*LocalCacheConfigImpl) GetPersistDir

func (l *LocalCacheConfigImpl) GetPersistDir() string

GetPersistDir consumer.localCache.persist.path 本地缓存持久化路径

func (*LocalCacheConfigImpl) GetPersistMaxReadRetry

func (l *LocalCacheConfigImpl) GetPersistMaxReadRetry() int

GetPersistMaxReadRetry

func (*LocalCacheConfigImpl) GetPersistMaxWriteRetry

func (l *LocalCacheConfigImpl) GetPersistMaxWriteRetry() int

GetPersistMaxWriteRetry

func (*LocalCacheConfigImpl) GetPersistRetryInterval

func (l *LocalCacheConfigImpl) GetPersistRetryInterval() time.Duration

GetPersistRetryInterval

func (*LocalCacheConfigImpl) GetPluginConfig

func (l *LocalCacheConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig consumer.localCache.plugin

func (*LocalCacheConfigImpl) GetServiceExpireTime

func (l *LocalCacheConfigImpl) GetServiceExpireTime() time.Duration

GetServiceExpireTime consumer.localCache.service.expireTime, 服务的超时淘汰时间

func (*LocalCacheConfigImpl) GetServiceRefreshInterval

func (l *LocalCacheConfigImpl) GetServiceRefreshInterval() time.Duration

GetServiceRefreshInterval consumer.localCache.service.refreshInterval 服务的定期刷新间隔

func (*LocalCacheConfigImpl) GetStartUseFileCache

func (l *LocalCacheConfigImpl) GetStartUseFileCache() bool

GetStartUseFileCache 获取是否可以直接使用缓存标签

func (*LocalCacheConfigImpl) GetType

func (l *LocalCacheConfigImpl) GetType() string

GetType consumer.localCache.type 本地缓存类型,默认default,可修改成具体的缓存插件名

func (*LocalCacheConfigImpl) Init

func (l *LocalCacheConfigImpl) Init()

Init localche配置初始化

func (*LocalCacheConfigImpl) SetDefault

func (l *LocalCacheConfigImpl) SetDefault()

SetDefault 设置LocalCacheConfig配置的默认值

func (*LocalCacheConfigImpl) SetPersistAvailableInterval

func (l *LocalCacheConfigImpl) SetPersistAvailableInterval(interval time.Duration)

SetPersistAvailableInterval

func (*LocalCacheConfigImpl) SetPersistDir

func (l *LocalCacheConfigImpl) SetPersistDir(dir string)

SetPersistDir 设置本地缓存持久化路径

func (*LocalCacheConfigImpl) SetPersistMaxReadRetry

func (l *LocalCacheConfigImpl) SetPersistMaxReadRetry(maxReadRetry int)

SetPersistMaxReadRetry

func (*LocalCacheConfigImpl) SetPersistMaxWriteRetry

func (l *LocalCacheConfigImpl) SetPersistMaxWriteRetry(maxWriteRetry int)

SetPersistMaxWriteRetry

func (*LocalCacheConfigImpl) SetPersistRetryInterval

func (l *LocalCacheConfigImpl) SetPersistRetryInterval(interval time.Duration)

SetPersistRetryInterval

func (*LocalCacheConfigImpl) SetPluginConfig

func (l *LocalCacheConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*LocalCacheConfigImpl) SetServiceExpireTime

func (l *LocalCacheConfigImpl) SetServiceExpireTime(expireTime time.Duration)

SetServiceExpireTime 设置服务超时淘汰时间

func (*LocalCacheConfigImpl) SetServiceRefreshInterval

func (l *LocalCacheConfigImpl) SetServiceRefreshInterval(interval time.Duration)

SetServiceRefreshInterval 设置服务定时刷新间隔

func (*LocalCacheConfigImpl) SetStartUseFileCache

func (l *LocalCacheConfigImpl) SetStartUseFileCache(useCacheFile bool)

SetStartUseFileCache 设置是否可以直接使用缓存

func (*LocalCacheConfigImpl) SetType

func (l *LocalCacheConfigImpl) SetType(typ string)

SetType 设置本地缓存类型

func (*LocalCacheConfigImpl) Verify

func (l *LocalCacheConfigImpl) Verify() error

Verify 检验LocalCacheConfig配置

type LocationConfig added in v1.1.0

type LocationConfig interface {
	BaseConfig
	PluginConfig
	// GetProvider 获取地理位置的提供者插件名称
	GetProvider() string
	// SetProvider 设置地理位置的提供者插件名称
	SetProvider(string)
}

LocationConfig SDK获取自身当前地理位置配置

type LocationConfigImpl added in v1.1.0

type LocationConfigImpl struct {
	Provider string `yaml:"provider" json:"provider"`
	// 插件相关配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

func (*LocationConfigImpl) GetPluginConfig added in v1.1.0

func (a *LocationConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig consumer.loadbalancer.plugin

func (*LocationConfigImpl) GetProvider added in v1.1.0

func (a *LocationConfigImpl) GetProvider() string

GetProvider 获取地理位置的提供者插件名称

func (*LocationConfigImpl) Init added in v1.1.0

func (a *LocationConfigImpl) Init()

Init 配置初始化

func (*LocationConfigImpl) SetDefault added in v1.1.0

func (a *LocationConfigImpl) SetDefault()

SetDefault 设置LocalCacheConfig配置的默认值

func (*LocationConfigImpl) SetPluginConfig added in v1.1.0

func (a *LocationConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*LocationConfigImpl) SetProvider added in v1.1.0

func (a *LocationConfigImpl) SetProvider(provider string)

SetProvider 设置地理位置的提供者插件名称

func (*LocationConfigImpl) Verify added in v1.1.0

func (a *LocationConfigImpl) Verify() error

Verify 检验LocalCacheConfig配置

type Matcher added in v1.0.1

type Matcher struct {
	Type  string `yaml:"type"`
	Value string `yaml:"value"`
}

Matcher 标签匹配类型

type NearbyConfig

type NearbyConfig interface {
	BaseConfig
	// SetMatchLevel 设置匹配级别,consumer.serviceRouter.plugin.nearbyBasedRouter.matchLevel
	SetMatchLevel(level string)
	// GetMatchLevel 获取匹配级别,consumer.serviceRouter.plugin.nearbyBasedRouter.matchLevel
	GetMatchLevel() string
	// SetLowestMatchLevel .
	// Deprecated: 设置可以降级的最低匹配级别, 已废弃,请使用SetMaxMatchLevel
	SetLowestMatchLevel(level string)
	// GetLowestMatchLevel .
	// Deprecated: 获取可以降级的最低匹配级别,已废弃,请使用GetMaxMatchLevel
	GetLowestMatchLevel() string
	// SetMaxMatchLevel 设置可以降级的最低匹配级别,consumer.serviceRouter.plugin.nearbyBasedRouter.maxMatchLevel
	SetMaxMatchLevel(level string)
	// GetMaxMatchLevel 获取可以降级的最低匹配级别,consumer.serviceRouter.plugin.nearbyBasedRouter.maxMatchLevel
	GetMaxMatchLevel() string
	// SetStrictNearby 设置是否进行严格就近,consumer.serviceRouter.plugin.nearbyBasedRouter.strictNearby
	SetStrictNearby(s bool)
	// IsStrictNearby 获取是否进行严格就近,consumer.serviceRouter.plugin.nearbyBasedRouter.strictNearby
	IsStrictNearby() bool
	// IsEnableDegradeByUnhealthyPercent 是否开启根据不健康实例比例进行降级就近匹配,
	// consumer.serviceRouter.plugin.nearbyBasedRouter.enableDegradeByUnhealthyPercent
	IsEnableDegradeByUnhealthyPercent() bool
	// SetEnableDegradeByUnhealthyPercent 设置是否开启根据不健康实例比例进行降级就近匹配
	// consumer.serviceRouter.plugin.nearbyBasedRouter.enableDegradeByUnhealthyPercent
	SetEnableDegradeByUnhealthyPercent(e bool)
	// GetUnhealthyPercentToDegrade 获取触发降级匹配的不健康实例比例,
	// consumer.serviceRouter.plugin.nearbyBasedRouter.unhealthyPercentToDegrade
	GetUnhealthyPercentToDegrade() int
	// SetUnhealthyPercentToDegrade 设置触发降级匹配的不健康实例比例,consumer.serviceRouter.plugin.nearbyBasedRouter.unhealthyPercentToDegrade
	SetUnhealthyPercentToDegrade(u int)
}

NearbyConfig 就近路由配置

type PluginConfig

type PluginConfig interface {
	// GetPluginConfig 获取plugin.<name>下的插件配置,将map[string]interface形式的配置marshal进value中
	GetPluginConfig(pluginName string) BaseConfig
	// SetPluginConfig 设置插件配置,将value的内容unmarshal为map[string]interface{}形式
	SetPluginConfig(plugName string, value BaseConfig) error
}

PluginConfig 插件配置对象

type PluginConfigs

type PluginConfigs map[string]interface{}

PluginConfigs 插件配置实现类

func (PluginConfigs) GetPluginConfig

func (p PluginConfigs) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig 根据插件名获取配置

func (PluginConfigs) Init

func (p PluginConfigs) Init(typ common.Type)

Init 初始化配置对象

func (PluginConfigs) SetDefault

func (p PluginConfigs) SetDefault(typ common.Type)

SetDefault 设置默认值

func (PluginConfigs) SetPluginConfig

func (p PluginConfigs) SetPluginConfig(plugType common.Type, plugName string, value BaseConfig) error

SetPluginConfig 设置单独一个插件的值

func (PluginConfigs) Verify

func (p PluginConfigs) Verify() error

Verify 校验插件配置

type ProviderConfig

type ProviderConfig interface {
	BaseConfig
	// GetRateLimit 获取限流配置
	GetRateLimit() RateLimitConfig
}

ProviderConfig 被调端配置对象

type ProviderConfigImpl

type ProviderConfigImpl struct {
	// 限流配置
	RateLimit *RateLimitConfigImpl `yaml:"rateLimit" json:"rateLimit"`
}

ProviderConfigImpl 服务提供者配置

func (*ProviderConfigImpl) GetRateLimit

func (p *ProviderConfigImpl) GetRateLimit() RateLimitConfig

GetRateLimit 是否启用限流能力

func (*ProviderConfigImpl) Init

func (p *ProviderConfigImpl) Init()

Init 配置初始化

func (*ProviderConfigImpl) SetDefault

func (p *ProviderConfigImpl) SetDefault()

SetDefault 设置默认参数

func (*ProviderConfigImpl) Verify

func (p *ProviderConfigImpl) Verify() error

Verify 校验配置参数

type RateLimitConfig

type RateLimitConfig interface {
	BaseConfig
	PluginConfig
	// IsEnable 是否启用限流能力
	IsEnable() bool
	// SetEnable 设置是否启用限流能力
	SetEnable(bool)
	// GetMaxWindowSize 获取最大限流窗口数量
	GetMaxWindowSize() int
	// SetMaxWindowSize 设置最大限流窗口数量
	SetMaxWindowSize(maxSize int)
	// GetPurgeInterval 获取超时淘汰周期
	GetPurgeInterval() time.Duration
	// SetPurgeInterval 设置超时淘汰周期
	SetPurgeInterval(time.Duration)
	// GetRules GetRules
	GetRules() []RateLimitRule
	// SetRules SetRules
	SetRules([]RateLimitRule)
}

RateLimitConfig 限流相关配置

type RateLimitConfigImpl

type RateLimitConfigImpl struct {
	// 是否启动限流
	Enable *bool `yaml:"enable" json:"enable"`
	// 各个限流插件的配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
	// 最大限流窗口数量
	MaxWindowSize int `yaml:"maxWindowSize" json:"maxWindowSize"`
	// 超时window检查周期
	PurgeInterval time.Duration `yaml:"purgeInterval" json:"purgeInterval"`
	// 本地限流规则
	Rules []RateLimitRule `yaml:"rules"`
}

RateLimitConfigImpl 限流配置对象

func (*RateLimitConfigImpl) GetMaxWindowSize

func (r *RateLimitConfigImpl) GetMaxWindowSize() int

GetMaxWindowSize .

func (*RateLimitConfigImpl) GetPluginConfig

func (r *RateLimitConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig 获取插件配置

func (*RateLimitConfigImpl) GetPurgeInterval

func (r *RateLimitConfigImpl) GetPurgeInterval() time.Duration

GetPurgeInterval .

func (*RateLimitConfigImpl) GetRules added in v1.0.1

func (r *RateLimitConfigImpl) GetRules() []RateLimitRule

GetRules 获取规则

func (*RateLimitConfigImpl) Init

func (r *RateLimitConfigImpl) Init()

Init 配置初始化

func (*RateLimitConfigImpl) IsEnable

func (r *RateLimitConfigImpl) IsEnable() bool

IsEnable 是否启用限流能力

func (*RateLimitConfigImpl) SetDefault

func (r *RateLimitConfigImpl) SetDefault()

SetDefault 设置默认参数

func (*RateLimitConfigImpl) SetEnable

func (r *RateLimitConfigImpl) SetEnable(value bool)

SetEnable 设置是否启用限流能力

func (*RateLimitConfigImpl) SetMaxWindowSize

func (r *RateLimitConfigImpl) SetMaxWindowSize(maxSize int)

SetMaxWindowSize .

func (*RateLimitConfigImpl) SetPluginConfig

func (r *RateLimitConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 设置插件配置

func (*RateLimitConfigImpl) SetPurgeInterval

func (r *RateLimitConfigImpl) SetPurgeInterval(v time.Duration)

SetPurgeInterval .

func (*RateLimitConfigImpl) SetRules added in v1.0.1

func (r *RateLimitConfigImpl) SetRules(rules []RateLimitRule)

SetRules 。设置规则

func (*RateLimitConfigImpl) Verify

func (r *RateLimitConfigImpl) Verify() error

Verify 校验配置参数

type RateLimitRule added in v1.0.1

type RateLimitRule struct {
	Namespace     string             `yaml:"namespace"`
	Service       string             `yaml:"service"`
	Labels        map[string]Matcher `yaml:"labels"`
	MaxAmount     int                `yaml:"maxAmount"`
	ValidDuration time.Duration      `yaml:"validDuration"`
}

RateLimitRule 限流规则

func (*RateLimitRule) Verify added in v1.0.1

func (r *RateLimitRule) Verify() error

Verify 校验限流规则

type ServerClusterConfig

type ServerClusterConfig interface {
	BaseConfig
	// GetNamespace 获取命名空间
	GetNamespace() string
	// SetNamespace 设置命名空间
	SetNamespace(string)
	// GetService 获取服务名
	GetService() string
	// SetService 设置服务名
	SetService(string)
	// GetRefreshInterval 系统服务的刷新间隔
	GetRefreshInterval() time.Duration
	// SetRefreshInterval 设置系统服务的刷新间隔
	SetRefreshInterval(time.Duration)
}

ServerClusterConfig 单个系统服务集群

type ServerClusterConfigImpl

type ServerClusterConfigImpl struct {
	Namespace       string         `yaml:"namespace" json:"namespace"`
	Service         string         `yaml:"service" json:"service"`
	RefreshInterval *time.Duration `yaml:"refreshInterval" json:"refreshInterval"`
}

ServerClusterConfigImpl 单个服务集群配置

func NewServerClusterConfig

func NewServerClusterConfig(svcKey model.ServiceKey) *ServerClusterConfigImpl

NewServerClusterConfig 通过服务信息创建服务集群配置

func (*ServerClusterConfigImpl) GetNamespace

func (s *ServerClusterConfigImpl) GetNamespace() string

GetNamespace 获取命名空间

func (*ServerClusterConfigImpl) GetRefreshInterval

func (s *ServerClusterConfigImpl) GetRefreshInterval() time.Duration

GetRefreshInterval 获取系统服务刷新间隔

func (*ServerClusterConfigImpl) GetService

func (s *ServerClusterConfigImpl) GetService() string

GetService 获取服务名

func (*ServerClusterConfigImpl) SetDefault

func (s *ServerClusterConfigImpl) SetDefault()

设置ServerClusterConfig默认配置

func (*ServerClusterConfigImpl) SetNamespace

func (s *ServerClusterConfigImpl) SetNamespace(namespace string)

SetNamespace 设置命名空间

func (*ServerClusterConfigImpl) SetRefreshInterval

func (s *ServerClusterConfigImpl) SetRefreshInterval(interval time.Duration)

SetRefreshInterval 获取系统服务刷新间隔

func (*ServerClusterConfigImpl) SetService

func (s *ServerClusterConfigImpl) SetService(service string)

SetService 设置服务名

func (*ServerClusterConfigImpl) Verify

func (s *ServerClusterConfigImpl) Verify() error

校验ServerClusterConfig配置

type ServerConnectorConfig

type ServerConnectorConfig interface {
	BaseConfig
	PluginConfig
	// GetAddresses global.serverConnector.addresses
	// 远端server地址,格式为<host>:<port>
	GetAddresses() []string
	// SetAddresses 设置远端server地址,格式为<host>:<port>
	SetAddresses([]string)
	// GetProtocol global.serverConnector.protocol
	// 与server对接的协议
	GetProtocol() string
	// SetProtocol 设置与server对接的协议
	SetProtocol(string)
	// GetConnectTimeout global.serverConnector.connectTimeout
	// 与server的连接超时时间
	GetConnectTimeout() time.Duration
	// SetConnectTimeout 设置与server的连接超时时间
	SetConnectTimeout(time.Duration)
	// GetMessageTimeout global.registry.messageTimeout
	// 远程请求超时时间
	GetMessageTimeout() time.Duration
	// SetMessageTimeout 设置远程请求超时时间
	SetMessageTimeout(time.Duration)
	// GetRequestQueueSize global.serverConnector.clientRequestQueueSize
	// 新请求的队列BUFFER容量
	GetRequestQueueSize() int32
	// SetRequestQueueSize 设置新请求的队列BUFFER容量
	SetRequestQueueSize(int32)
	// GetServerSwitchInterval global.serverConnector.serverSwitchInterval
	// server的切换时延
	GetServerSwitchInterval() time.Duration
	// SetServerSwitchInterval 设置server的切换时延
	SetServerSwitchInterval(time.Duration)
	// GetReconnectInterval 获取一次连接失败后,到下一次重连的间隔时间
	GetReconnectInterval() time.Duration
	// SetReconnectInterval 设置重试连接的间隔时间
	SetReconnectInterval(time.Duration)
	// GetConnectionIdleTimeout global.serverConnector.connectionIdleTimeout
	// 连接会被释放的空闲的时长
	GetConnectionIdleTimeout() time.Duration
	// SetConnectionIdleTimeout 设置连接会被释放的空闲的时长
	SetConnectionIdleTimeout(time.Duration)
}

ServerConnectorConfig 与名字服务服务端的连接配置

type ServerConnectorConfigImpl

type ServerConnectorConfigImpl struct {
	Addresses []string `yaml:"addresses" json:"addresses"`

	Protocol string `yaml:"protocol" json:"protocol"`

	ConnectTimeout *time.Duration `yaml:"connectTimeout" json:"connectTimeout"`

	// 远程请求超时时间
	MessageTimeout *time.Duration `yaml:"messageTimeout" json:"messageTimeout"`

	ConnectionIdleTimeout *time.Duration `yaml:"connectionIdleTimeout" json:"connectionIdleTimeout"`

	RequestQueueSize *int32 `yaml:"requestQueueSize" json:"requestQueueSize"`

	ServerSwitchInterval *time.Duration `yaml:"serverSwitchInterval" json:"serverSwitchInterval"`

	ReconnectInterval *time.Duration `yaml:"reconnectInterval" json:"reconnectInterval"`

	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

对接注册中心相关配置

func (*ServerConnectorConfigImpl) GetAddresses

func (s *ServerConnectorConfigImpl) GetAddresses() []string

GetAddresses global.serverConnector.addresses 远端cl5 server地址,格式为<host>:<port>

func (*ServerConnectorConfigImpl) GetConnectTimeout

func (s *ServerConnectorConfigImpl) GetConnectTimeout() time.Duration

GetConnectTimeout global.serverConnector.connectTimeout 与server的连接超时时间

func (*ServerConnectorConfigImpl) GetConnectionIdleTimeout

func (s *ServerConnectorConfigImpl) GetConnectionIdleTimeout() time.Duration

GetConnectionExpireInterval global.serverConnector.connectionIdleTimeout 连接空闲后超时时间

func (*ServerConnectorConfigImpl) GetMessageTimeout

func (s *ServerConnectorConfigImpl) GetMessageTimeout() time.Duration

GetMessageTimeout global.serverConnector.messageTimeout 远程请求超时时间

func (*ServerConnectorConfigImpl) GetPluginConfig

func (s *ServerConnectorConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig global.serverConnector.plugin

func (*ServerConnectorConfigImpl) GetProtocol

func (s *ServerConnectorConfigImpl) GetProtocol() string

GetProtocol global.serverConnector.protocol 与cl5 server对接的协议

func (*ServerConnectorConfigImpl) GetReconnectInterval

func (s *ServerConnectorConfigImpl) GetReconnectInterval() time.Duration

GetReconnectInterval 一次连接失败后,到下一次连接之间的最小间隔时间

func (*ServerConnectorConfigImpl) GetRequestQueueSize

func (s *ServerConnectorConfigImpl) GetRequestQueueSize() int32

GetRequestQueueSize global.serverConnector.requestQueueSize 新请求的队列BUFFER容量

func (*ServerConnectorConfigImpl) GetServerSwitchInterval

func (s *ServerConnectorConfigImpl) GetServerSwitchInterval() time.Duration

GetServerSwitchInterval global.serverConnector.serverSwitchInterval server的切换时延

func (*ServerConnectorConfigImpl) Init

func (s *ServerConnectorConfigImpl) Init()

Init 配置初始化

func (*ServerConnectorConfigImpl) SetAddresses

func (s *ServerConnectorConfigImpl) SetAddresses(addresses []string)

SetAddresses 设置远端cl5 server地址,格式为<host>:<port>

func (*ServerConnectorConfigImpl) SetConnectTimeout

func (s *ServerConnectorConfigImpl) SetConnectTimeout(timeout time.Duration)

SetConnectTimeout 设置与server的连接超时时间

func (*ServerConnectorConfigImpl) SetConnectionIdleTimeout

func (s *ServerConnectorConfigImpl) SetConnectionIdleTimeout(timeout time.Duration)

SetConnectionIdleTimeout 设置连接空闲后超时时间

func (*ServerConnectorConfigImpl) SetDefault

func (s *ServerConnectorConfigImpl) SetDefault()

SetDefault 设置ServerConnector配置的默认值

func (*ServerConnectorConfigImpl) SetMessageTimeout

func (s *ServerConnectorConfigImpl) SetMessageTimeout(timeout time.Duration)

SetMessageTimeout 设置远程请求超时时间

func (*ServerConnectorConfigImpl) SetPluginConfig

func (s *ServerConnectorConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*ServerConnectorConfigImpl) SetProtocol

func (s *ServerConnectorConfigImpl) SetProtocol(protocol string)

SetProtocol 设置与cl5 server对接的协议

func (*ServerConnectorConfigImpl) SetReconnectInterval

func (s *ServerConnectorConfigImpl) SetReconnectInterval(interval time.Duration)

SetReconnectInterval 一次连接失败后,到下一次连接之间的最小间隔时间

func (*ServerConnectorConfigImpl) SetRequestQueueSize

func (s *ServerConnectorConfigImpl) SetRequestQueueSize(queueSize int32)

SetRequestQueueSize 设置新请求的队列BUFFER容量

func (*ServerConnectorConfigImpl) SetServerSwitchInterval

func (s *ServerConnectorConfigImpl) SetServerSwitchInterval(interval time.Duration)

SetServerSwitchInterval server的切换时延

func (*ServerConnectorConfigImpl) Verify

func (s *ServerConnectorConfigImpl) Verify() error

Verify 检验ServerConnector配置

type ServerServices

type ServerServices map[ClusterType]ClusterService

ServerServices 系统服务列表数据

func GetServerServices

func GetServerServices(cfg Configuration) ServerServices

获取系统服务列表

func (ServerServices) GetClusterService

func (s ServerServices) GetClusterService(clsType ClusterType) *ClusterService

GetClusterService 获取集群服务

type ServiceRouterConfig

type ServiceRouterConfig interface {
	BaseConfig
	PluginConfig
	// GetChain consumer.serviceRouter.chain
	// 路由责任链配置
	GetChain() []string
	// SetChain 设置路由责任链配置
	SetChain([]string)
	// GetPercentOfMinInstances 获取PercentOfMinInstances参数
	GetPercentOfMinInstances() float64
	// SetPercentOfMinInstances 设置PercentOfMinInstances参数
	SetPercentOfMinInstances(float64)
	// IsEnableRecoverAll 是否启用全死全活机制
	IsEnableRecoverAll() bool
	// SetEnableRecoverAll 设置启用全死全活机制
	SetEnableRecoverAll(bool)
	// GetNearbyConfig 获取就近路由配置
	GetNearbyConfig() NearbyConfig
}

ServiceRouterConfig 服务路由相关配置项

type ServiceRouterConfigImpl

type ServiceRouterConfigImpl struct {
	// 服务路由责任链
	Chain []string `yaml:"chain" json:"chain"`
	// 插件相关配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
	// 进行过滤时的最大过滤比例
	PercentOfMinInstances *float64 `yaml:"percentOfMinInstances" json:"percentOfMinInstances"`
	// 是否启用全死全活机制
	EnableRecoverAll *bool `yaml:"enableRecoverAll" json:"enableRecoverAll"`
}

ServiceRouterConfigImpl 服务路由配置

func (*ServiceRouterConfigImpl) GetChain

func (s *ServiceRouterConfigImpl) GetChain() []string

GetChain consumer.serviceRouter.filterChain 路由责任链配置

func (*ServiceRouterConfigImpl) GetNearbyConfig

func (s *ServiceRouterConfigImpl) GetNearbyConfig() NearbyConfig

GetNearbyConfig 获取就近路由配置

func (*ServiceRouterConfigImpl) GetPercentOfMinInstances

func (s *ServiceRouterConfigImpl) GetPercentOfMinInstances() float64

GetPercentOfMinInstances 获取PercentOfMinInstances参数

func (*ServiceRouterConfigImpl) GetPluginConfig

func (s *ServiceRouterConfigImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig consumer.serviceRouter.plugin

func (*ServiceRouterConfigImpl) Init

func (s *ServiceRouterConfigImpl) Init()

Init 配置初始化

func (*ServiceRouterConfigImpl) IsEnableRecoverAll

func (s *ServiceRouterConfigImpl) IsEnableRecoverAll() bool

IsEnableRecoverAll 是否启用全死全活机制

func (*ServiceRouterConfigImpl) SetChain

func (s *ServiceRouterConfigImpl) SetChain(chain []string)

SetChain 设置路由责任链配置

func (*ServiceRouterConfigImpl) SetDefault

func (s *ServiceRouterConfigImpl) SetDefault()

SetDefault 设置ServiceRouterConfig配置的默认值

func (*ServiceRouterConfigImpl) SetEnableRecoverAll

func (s *ServiceRouterConfigImpl) SetEnableRecoverAll(recoverAll bool)

SetEnableRecoverAll 设置启用全死全活机制

func (*ServiceRouterConfigImpl) SetPercentOfMinInstances

func (s *ServiceRouterConfigImpl) SetPercentOfMinInstances(percent float64)

SetPercentOfMinInstances 设置PercentOfMinInstances参数

func (*ServiceRouterConfigImpl) SetPluginConfig

func (s *ServiceRouterConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*ServiceRouterConfigImpl) Verify

func (s *ServiceRouterConfigImpl) Verify() error

Verify 检验ServiceRouterConfig配置

type ServiceSpecific

type ServiceSpecific struct {
	Namespace      string                    `yaml:"namespace" json:"namespace"`
	Service        string                    `yaml:"service" json:"service"`
	ServiceRouter  *ServiceRouterConfigImpl  `yaml:"serviceRouter" json:"serviceRouter"`
	CircuitBreaker *CircuitBreakerConfigImpl `yaml:"circuitBreaker" json:"circuitBreaker"`
}

func (*ServiceSpecific) GetServiceCircuitBreaker

func (s *ServiceSpecific) GetServiceCircuitBreaker() CircuitBreakerConfig

func (*ServiceSpecific) GetServiceRouter

func (s *ServiceSpecific) GetServiceRouter() ServiceRouterConfig

func (*ServiceSpecific) Init

func (s *ServiceSpecific) Init()

func (*ServiceSpecific) SetDefault

func (s *ServiceSpecific) SetDefault()

func (*ServiceSpecific) Verify

func (s *ServiceSpecific) Verify() error

type ServiceSpecificConfig

type ServiceSpecificConfig interface {
	BaseConfig

	GetServiceCircuitBreaker() CircuitBreakerConfig

	GetServiceRouter() ServiceRouterConfig
}

ServiceSpecificConfig 配置

type ServicesSpecificImpl

type ServicesSpecificImpl struct {
	Services []*ServiceSpecific
}

type StatReporterConfig

type StatReporterConfig interface {
	BaseConfig
	PluginConfig
	// IsEnable 是否启用上报
	IsEnable() bool
	// SetEnable 设置是否启用上报
	SetEnable(bool)
	// GetChain 统计上报器插件链
	GetChain() []string
	// SetChain 设置统计上报器插件链
	SetChain([]string)
}

StatReporterConfig 统计上报配置

type StatReporterConfigImpl

type StatReporterConfigImpl struct {
	// 是否启动上报
	Enable *bool `yaml:"enable" json:"enable"`
	// 上报插件链
	Chain []string `yaml:"chain" json:"chain"`
	// 插件相关配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

StatReporterConfigImpl global.statReporter

func (*StatReporterConfigImpl) GetChain

func (s *StatReporterConfigImpl) GetChain() []string

GetChain 插件链条

func (*StatReporterConfigImpl) GetPluginConfig

func (s *StatReporterConfigImpl) GetPluginConfig(name string) BaseConfig

GetPluginConfig 获取一个插件的配置

func (*StatReporterConfigImpl) Init

func (s *StatReporterConfigImpl) Init()

Init 配置初始化

func (*StatReporterConfigImpl) IsEnable

func (s *StatReporterConfigImpl) IsEnable() bool

IsEnable 是否启用上报

func (*StatReporterConfigImpl) SetChain

func (s *StatReporterConfigImpl) SetChain(chain []string)

SetChain 设置插件链条

func (*StatReporterConfigImpl) SetDefault

func (s *StatReporterConfigImpl) SetDefault()

SetDefault 设置statReporter默认值

func (*StatReporterConfigImpl) SetEnable

func (s *StatReporterConfigImpl) SetEnable(enable bool)

SetEnable 设置是否启用上报

func (*StatReporterConfigImpl) SetPluginConfig

func (s *StatReporterConfigImpl) SetPluginConfig(plugName string, value BaseConfig) error

SetPluginConfig 输出插件具体配置

func (*StatReporterConfigImpl) Verify

func (s *StatReporterConfigImpl) Verify() error

Verify 检测statReporter配置

type SubscribeConfig

type SubscribeConfig interface {
	BaseConfig
	PluginConfig
	// GetType 获取插件
	GetType() string
	// SetType 设置插件
	SetType(string)
}

SubscribeConfig .订阅配置

type SubscribeImpl

type SubscribeImpl struct {
	// 上报插件链
	Type string `yaml:"type" json:"type"`
	// 插件相关配置
	Plugin PluginConfigs `yaml:"plugin" json:"plugin"`
}

func (*SubscribeImpl) GetPluginConfig

func (s *SubscribeImpl) GetPluginConfig(pluginName string) BaseConfig

GetPluginConfig

func (*SubscribeImpl) GetType

func (s *SubscribeImpl) GetType() string

GetType 获取插件

func (*SubscribeImpl) Init

func (s *SubscribeImpl) Init()

func (*SubscribeImpl) SetDefault

func (s *SubscribeImpl) SetDefault()

func (*SubscribeImpl) SetPluginConfig

func (s *SubscribeImpl) SetPluginConfig(plugName string, value BaseConfig) error

SetPluginConfig

func (*SubscribeImpl) SetType

func (s *SubscribeImpl) SetType(typeStr string)

SetType 设置插件

func (*SubscribeImpl) Verify

func (s *SubscribeImpl) Verify() error

Verify

type SystemConfig

type SystemConfig interface {
	BaseConfig
	// GetMode global.systemConfig.mode
	// SDK运行模式,agent还是noagent
	GetMode() model.RunMode
	// SetMode 设置SDK运行模式
	SetMode(model.RunMode)
	// GetDiscoverCluster global.systemConfig.discoverCluster
	// 服务发现集群
	GetDiscoverCluster() ServerClusterConfig
	// GetHealthCheckCluster global.systemConfig.healthCheckCluster
	// 健康检查集群
	GetHealthCheckCluster() ServerClusterConfig
	// GetMonitorCluster global.systemConfig.monitorCluster
	// 监控上报集群
	GetMonitorCluster() ServerClusterConfig
	// GetVariable global.systemConfig.variables
	// 获取一个路由环境变量
	GetVariable(key string) (string, bool)
	// SetVariable global.systemConfig.variables
	// 设置一个路由环境变量
	SetVariable(key, value string)
	// UnsetVariable 取消一个路由环境变量
	UnsetVariable(key string)
}

SystemConfig 系统配置信息

type SystemConfigImpl

type SystemConfigImpl struct {
	// SDK运行模式
	Mode model.RunMode `yaml:"mode" json:"mode"`
	// 服务发现集群
	DiscoverCluster *ServerClusterConfigImpl `yaml:"discoverCluster" json:"discoverCluster"`
	// 健康检查集群
	HealthCheckCluster *ServerClusterConfigImpl `yaml:"healthCheckCluster" json:"healthCheckCluster"`
	// 监控上报集群
	MonitorCluster *ServerClusterConfigImpl `yaml:"monitorCluster" json:"monitorCluster"`
	// 传入的路由规则variables
	Variables map[string]string `yaml:"variables" json:"variables"`
}

SystemConfigImpl 系统配置

func (*SystemConfigImpl) GetDiscoverCluster

func (s *SystemConfigImpl) GetDiscoverCluster() ServerClusterConfig

GetDiscoverCluster 服务发现集群

func (*SystemConfigImpl) GetHealthCheckCluster

func (s *SystemConfigImpl) GetHealthCheckCluster() ServerClusterConfig

GetHealthCheckCluster 健康检查集群

func (*SystemConfigImpl) GetMode

func (s *SystemConfigImpl) GetMode() model.RunMode

GetMode SDK运行模式,agent还是noagent

func (*SystemConfigImpl) GetMonitorCluster

func (s *SystemConfigImpl) GetMonitorCluster() ServerClusterConfig

GetMonitorCluster 监控上报集群

func (*SystemConfigImpl) GetVariable

func (s *SystemConfigImpl) GetVariable(key string) (string, bool)

GetVariable 获取一个路由variable

func (*SystemConfigImpl) Init

func (s *SystemConfigImpl) Init()

systemConfig init

func (*SystemConfigImpl) SetDefault

func (s *SystemConfigImpl) SetDefault()

设置systemConfig默认值

func (*SystemConfigImpl) SetMode

func (s *SystemConfigImpl) SetMode(mode model.RunMode)

SetMode 设置SDK运行模式

func (*SystemConfigImpl) SetVariable

func (s *SystemConfigImpl) SetVariable(key, value string)

SetVariable 设置一个路由variable

func (*SystemConfigImpl) UnsetVariable

func (s *SystemConfigImpl) UnsetVariable(key string)

UnsetVariable 取消一个路由variable

func (*SystemConfigImpl) Verify

func (s *SystemConfigImpl) Verify() error

校验systemConfig配置

type When

type When string

When when to active health check

Jump to

Keyboard shortcuts

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