config

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: Apache-2.0 Imports: 19 Imported by: 20

Documentation

Index

Constants

View Source
const (
	DefaultForceFallback                 = false
	DefaultTimeoutEnabled                = false
	DefaultConsumerCircuitBreakerEnabled = false
	DefaultProviderCircuitBreakerEnabled = false
	DefaultCircuitBreakerForceOpen       = false
	DefaultCircuitBreakerForceClosed     = false
	DefaultFallbackEnable                = true
	DefaultMaxConcurrent                 = 1000
	DefaultSleepWindow                   = 15000
	DefaultTimeout                       = 30000
	DefaultErrorPercentThreshold         = 50
	DefaultRequestVolumeThreshold        = 20
	PolicyNull                           = "returnnull"
	PolicyThrowException                 = "throwexception"
)

constant for hystrix parameters

View Source
const (
	DefaultAbortPercent = 0
	DefaultAbortStatus  = 0
	DefaultDelayPercent = 0
)

constant for default values of abort and delay

View Source
const (
	FixedPrefix = "cse"

	NamespaceIsolation                = "isolation"
	NamespaceCircuitBreaker           = "circuitBreaker"
	NamespaceFallback                 = "fallback" //降级
	NamespaceFallbackpolicy           = "fallbackpolicy"
	PropertyTimeoutInMilliseconds     = "timeoutInMilliseconds"
	PropertyTimeoutEnabled            = "timeout.enabled"
	PropertyMaxConcurrentRequests     = "maxConcurrentRequests"
	PropertyErrorThresholdPercentage  = "errorThresholdPercentage"  //失败率
	PropertyRequestVolumeThreshold    = "requestVolumeThreshold"    //窗口请求数
	PropertySleepWindowInMilliseconds = "sleepWindowInMilliseconds" //熔断时间窗
	PropertyEnabled                   = "enabled"
	PropertyForce                     = "force"
	PropertyPolicy                    = "policy"
	PropertyForceClosed               = "forceClosed"
	PropertyForceOpen                 = "forceOpen"
	PropertyFault                     = "fault"
	PropertyGlobal                    = "_global"
	PropertyGovernance                = "governance"
	PropertyConsumer                  = "Consumer"
	PropertySchema                    = "schemas"
	PropertyOperations                = "operations"
	PropertyProtocol                  = "protocols"
	PropertyAbort                     = "abort"
	PropertyPercent                   = "percent"
	PropertyFixedDelay                = "fixedDelay"
	PropertyDelay                     = "delay"
	PropertyHTTPStatus                = "httpStatus"

	LoadBalance = "loadbalance"
)

constant for hystrix keys

View Source
const (

	//DefaultStrategy is default value for strategy
	DefaultStrategy = "RoundRobin"
	//DefaultSessionTimeout is default value for timeout
	DefaultSessionTimeout = 30
	//DefaultFailedTimes is default value for failed times
	DefaultFailedTimes = 5
)
View Source
const DefaultConfigPath = "/etc/.kube/config"

DefaultConfigPath set the default config path

View Source
const DefaultRouterType = "cse"

DefaultRouterType set the default router type

Variables

View Source
var ErrNoName = errors.New("micro service name is missing in description file")

ErrNoName is used to represent the service name missing error

View Source
var GlobalDefinition *model.GlobalCfg

GlobalDefinition is having the information about region, load balancing, service center, config center, protocols, and handlers for the micro service

HystrixConfig is having info about isolation, circuit breaker, fallback properities of the micro service

View Source
var MicroserviceDefinition *model.MicroserviceCfg

MicroserviceDefinition has info about application id, provider info, description of the service, and description of the instance

View Source
var MonitorCfgDef *model.MonitorCfg

MonitorCfgDef has monitorv info, including zipkin and apm.

View Source
var NodeIP string

NodeIP gives the information of node ip

Functions

func BackOffKind added in v0.7.1

func BackOffKind(source, service string) string

BackOffKind get kind

func BackOffMaxMs added in v0.7.1

func BackOffMaxMs(source, service string) int

BackOffMaxMs get max time

func BackOffMinMs added in v0.7.1

func BackOffMinMs(source, service string) int

BackOffMinMs get min time

func GetAPM added in v1.8.0

func GetAPM() model.APMStruct

GetAPM return monitor config info

func GetAbortPercent

func GetAbortPercent(protocol, microServiceName, schema, operation string) int

GetAbortPercent get abort percentage

func GetAbortStatus

func GetAbortStatus(protocol, microServiceName, schema, operation string) int

GetAbortStatus get abort status

func GetCircuitBreakerEnabled

func GetCircuitBreakerEnabled(command, t string) bool

GetCircuitBreakerEnabled get circuit breaker enabled

func GetCircuitBreakerEnabledKey

func GetCircuitBreakerEnabledKey(command string) string

GetCircuitBreakerEnabledKey get circuit breaker enabled key

func GetConfigCenterConf added in v1.3.0

func GetConfigCenterConf() model.ConfigClient

GetConfigCenterConf return config center conf

func GetContractDiscoveryAPIVersion

func GetContractDiscoveryAPIVersion() string

GetContractDiscoveryAPIVersion returns the APIVersion of contract discovery registry

func GetContractDiscoveryAddress

func GetContractDiscoveryAddress() string

GetContractDiscoveryAddress returns the Address of contract discovery registry

func GetContractDiscoveryDisable

func GetContractDiscoveryDisable() bool

GetContractDiscoveryDisable returns the Disable of contract discovery registry

func GetContractDiscoveryTenant

func GetContractDiscoveryTenant() string

GetContractDiscoveryTenant returns the Tenant of contract discovery registry

func GetContractDiscoveryType

func GetContractDiscoveryType() string

GetContractDiscoveryType returns the Type of contract discovery registry

func GetDataCenter added in v1.4.0

func GetDataCenter() *model.DataCenterInfo

GetDataCenter return data center info

func GetDefaultCircuitBreakerEnabledKey

func GetDefaultCircuitBreakerEnabledKey(t string) string

GetDefaultCircuitBreakerEnabledKey get default circuit breaker enabled key

func GetDefaultErrorPercentThreshold

func GetDefaultErrorPercentThreshold(t string) string

GetDefaultErrorPercentThreshold get default error percentage threshold value

func GetDefaultFallbackPolicyKey

func GetDefaultFallbackPolicyKey(t string) string

GetDefaultFallbackPolicyKey get default fallback policy key

func GetDefaultForceCloseKey

func GetDefaultForceCloseKey(t string) string

GetDefaultForceCloseKey get default force close key

func GetDefaultForceFallbackKey

func GetDefaultForceFallbackKey(t string) string

GetDefaultForceFallbackKey get default force fallback key

func GetDefaultForceOpenKey

func GetDefaultForceOpenKey(t string) string

GetDefaultForceOpenKey get default force open key

func GetDefaultGetFallbackEnabledKey

func GetDefaultGetFallbackEnabledKey(t string) string

GetDefaultGetFallbackEnabledKey get default fallback enabled key

func GetDefaultMaxConcurrentKey

func GetDefaultMaxConcurrentKey(t string) string

GetDefaultMaxConcurrentKey get default maximum concurrent key

func GetDefaultRequestVolumeThresholdKey

func GetDefaultRequestVolumeThresholdKey(t string) string

GetDefaultRequestVolumeThresholdKey get default request volume threshold key

func GetDefaultSleepWindowKey

func GetDefaultSleepWindowKey(t string) string

GetDefaultSleepWindowKey get default sleep window key

func GetDefaultTimeoutKey

func GetDefaultTimeoutKey(t string) string

GetDefaultTimeoutKey get default timeout key

func GetDelayPercent

func GetDelayPercent(protocol, microServiceName, schema, operation string) int

GetDelayPercent get delay percentage

func GetErrorPercentThreshold

func GetErrorPercentThreshold(command, t string) int

GetErrorPercentThreshold get error percent threshold

func GetErrorPercentThresholdKey

func GetErrorPercentThresholdKey(command string) string

GetErrorPercentThresholdKey get error percentage threshold key

func GetFallbackEnabled

func GetFallbackEnabled(command, t string) bool

GetFallbackEnabled get fallback enabled

func GetFallbackEnabledKey

func GetFallbackEnabledKey(command string) string

GetFallbackEnabledKey get fallback enabled key

func GetFallbackPolicyKey

func GetFallbackPolicyKey(command string) string

GetFallbackPolicyKey get fallback policy key

func GetFaultAbortHTTPStatusKey

func GetFaultAbortHTTPStatusKey(key, protocol string) string

GetFaultAbortHTTPStatusKey get fault abort http status key

func GetFaultAbortPercentKey

func GetFaultAbortPercentKey(key, protocol string) string

GetFaultAbortPercentKey get fault abort percentage key

func GetFaultDelayPercentKey

func GetFaultDelayPercentKey(key, protocol string) string

GetFaultDelayPercentKey get fault daley percentage key

func GetFaultFixedDelayKey

func GetFaultFixedDelayKey(key, protocol string) string

GetFaultFixedDelayKey get fault fixed delay key

func GetFaultInjectionGlobalKey

func GetFaultInjectionGlobalKey() string

GetFaultInjectionGlobalKey get fault injection global key

func GetFaultInjectionOperationKey

func GetFaultInjectionOperationKey(microServiceName, schema, operation string) string

GetFaultInjectionOperationKey get fault injection operation key

func GetFaultInjectionSchemaKey

func GetFaultInjectionSchemaKey(microServiceName, schema string) string

GetFaultInjectionSchemaKey get fault injection schema key

func GetFaultInjectionServiceKey

func GetFaultInjectionServiceKey(microServiceName string) string

GetFaultInjectionServiceKey get fault injection service key

func GetFilterNamesKey

func GetFilterNamesKey() string

GetFilterNamesKey get filer name and key

func GetFixedDelay

func GetFixedDelay(protocol, microServiceName, schema, operation string) time.Duration

GetFixedDelay get fixed delay

func GetForceClose

func GetForceClose(service, t string) bool

GetForceClose get force close

func GetForceCloseKey

func GetForceCloseKey(command string) string

GetForceCloseKey get force close key

func GetForceFallback

func GetForceFallback(service, t string) bool

GetForceFallback get force fallback

func GetForceFallbackKey

func GetForceFallbackKey(command string) string

GetForceFallbackKey get force fallback key

func GetForceOpen

func GetForceOpen(service, t string) bool

GetForceOpen get foce open

func GetForceOpenKey

func GetForceOpenKey(command string) string

GetForceOpenKey get force open key

func GetHystrixConfig

func GetHystrixConfig() *model.HystrixConfig

GetHystrixConfig return cb config

func GetHystrixSpecificKey

func GetHystrixSpecificKey(namespace, cmd, property string) string

GetHystrixSpecificKey get hystrix specific key

func GetLoadBalancing

func GetLoadBalancing() *model.LoadBalancing

GetLoadBalancing return lb config

func GetMaxConcurrentKey

func GetMaxConcurrentKey(command string) string

GetMaxConcurrentKey get maximum concurrent key

func GetMaxConcurrentRequests

func GetMaxConcurrentRequests(command, t string) int

GetMaxConcurrentRequests get max concurrent requests

func GetPolicy

func GetPolicy(service, t string) string

GetPolicy get fallback policy

func GetRegistratorAPIVersion

func GetRegistratorAPIVersion() string

GetRegistratorAPIVersion returns the APIVersion of service registry

func GetRegistratorAddress

func GetRegistratorAddress() string

GetRegistratorAddress returns the Address of service registry

func GetRegistratorAutoRegister

func GetRegistratorAutoRegister() string

GetRegistratorAutoRegister returns the AutoRegister of service registry

func GetRegistratorDisable

func GetRegistratorDisable() bool

GetRegistratorDisable returns the Disable of service registry

func GetRegistratorScope

func GetRegistratorScope() string

GetRegistratorScope returns the Scope of service registry

func GetRegistratorTenant

func GetRegistratorTenant() string

GetRegistratorTenant returns the Tenant of service registry

func GetRegistratorType

func GetRegistratorType() string

GetRegistratorType returns the Type of service registry

func GetRequestVolumeThreshold

func GetRequestVolumeThreshold(command, t string) int

GetRequestVolumeThreshold get request volume threshold

func GetRequestVolumeThresholdKey

func GetRequestVolumeThresholdKey(command string) string

GetRequestVolumeThresholdKey get request volume threshold key

func GetRetryOnNext

func GetRetryOnNext(source, service string) int

GetRetryOnNext return value of GetRetryOnNext

func GetRetryOnSame

func GetRetryOnSame(source, service string) int

GetRetryOnSame return value of RetryOnSame

func GetRouterEndpoints added in v0.7.1

func GetRouterEndpoints() string

GetRouterEndpoints returns the router address

func GetRouterType added in v0.7.1

func GetRouterType() string

GetRouterType returns the type of router

func GetServerListFilters

func GetServerListFilters() (filters []string)

GetServerListFilters get server list filters

func GetServiceDiscoveryAPIVersion

func GetServiceDiscoveryAPIVersion() string

GetServiceDiscoveryAPIVersion returns the APIVersion of SD registry

func GetServiceDiscoveryAddress

func GetServiceDiscoveryAddress() string

GetServiceDiscoveryAddress returns the Address of SD registry

func GetServiceDiscoveryConfigPath added in v0.7.1

func GetServiceDiscoveryConfigPath() string

GetServiceDiscoveryConfigPath returns the configpath of SD registry

func GetServiceDiscoveryDisable

func GetServiceDiscoveryDisable() bool

GetServiceDiscoveryDisable returns the Disable of SD registry

func GetServiceDiscoveryHealthCheck

func GetServiceDiscoveryHealthCheck() bool

GetServiceDiscoveryHealthCheck returns the HealthCheck of SD registry

func GetServiceDiscoveryRefreshInterval

func GetServiceDiscoveryRefreshInterval() string

GetServiceDiscoveryRefreshInterval returns the RefreshInterval of SD registry

func GetServiceDiscoveryTenant

func GetServiceDiscoveryTenant() string

GetServiceDiscoveryTenant returns the Tenant of SD registry

func GetServiceDiscoveryType

func GetServiceDiscoveryType() string

GetServiceDiscoveryType returns the Type of SD registry

func GetServiceDiscoveryWatch

func GetServiceDiscoveryWatch() bool

GetServiceDiscoveryWatch returns the Watch of SD registry

func GetSessionTimeout

func GetSessionTimeout(source, service string) int

GetSessionTimeout return session timeout

func GetSleepWindow

func GetSleepWindow(command, t string) int

GetSleepWindow get sleep window

func GetSleepWindowKey

func GetSleepWindowKey(command string) string

GetSleepWindowKey get sleep window key

func GetStrategyName

func GetStrategyName(source, service string) string

GetStrategyName get strategy name

func GetTimeout

func GetTimeout(service, t string) int

GetTimeout get timeout durations

func GetTimeoutDuration added in v1.1.1

func GetTimeoutDuration(service, t string) time.Duration

GetTimeoutDuration get timeout durations from cache first, then get from archaius

func GetTimeoutDurationFromArchaius added in v1.6.1

func GetTimeoutDurationFromArchaius(service, t string) time.Duration

GetTimeoutDurationFromArchaius get timeout durations from archaius

func GetTimeoutKey

func GetTimeoutKey(command string) string

GetTimeoutKey get timeout key

func GetTransportConf added in v1.3.0

func GetTransportConf() model.Transport

GetTransportConf return transport settings

func Init

func Init() error

Init is initialize the configuration directory, archaius, route rule, and schema

func InitArchaius added in v1.1.0

func InitArchaius() error

InitArchaius initialize the archaius

func ReadGlobalConfigFromArchaius added in v1.7.2

func ReadGlobalConfigFromArchaius() error

ReadGlobalConfigFromArchaius for to unmarshal the global config file(chassis.yaml) information

func ReadHystrixFromArchaius

func ReadHystrixFromArchaius() error

ReadHystrixFromArchaius is unmarshal hystrix configuration file(circuit_breaker.yaml)

func ReadLBFromArchaius

func ReadLBFromArchaius() error

ReadLBFromArchaius for to unmarshal the global config file(chassis.yaml) information

func ReadMicroserviceConfigFromBytes

func ReadMicroserviceConfigFromBytes(data []byte) error

ReadMicroserviceConfigFromBytes read micro service configurations from bytes

func ReadMonitorFromArchaius added in v1.8.0

func ReadMonitorFromArchaius() error

ReadMonitorFromArchaius read monitor config from archauis pkg

func ReadMonitorFromFile added in v1.8.0

func ReadMonitorFromFile() error

ReadMonitorFromFile read monitor config from local file conf/monitoring.yaml

func RetryEnabled

func RetryEnabled(source, service string) bool

RetryEnabled retry enabled

func StrategySuccessiveFailedTimes

func StrategySuccessiveFailedTimes(source, service string) int

StrategySuccessiveFailedTimes strategy successive failed times

Types

type DarkLaunchRule added in v1.7.1

type DarkLaunchRule struct {
	Type  string      `json:"policyType"` // RULE/RATE
	Items []*RuleItem `json:"ruleItems"`
}

DarkLaunchRule dark launch rule Deprecated

type LimiterConfig added in v1.8.1

type LimiterConfig struct {
	Match string
	QPS   string
}

LimiterConfig is rate limiter policy

type Match added in v1.7.1

type Match struct {
	Refer       string                       `yaml:"refer"`
	Source      string                       `yaml:"source"`
	SourceTags  map[string]string            `yaml:"sourceTags"`
	HTTPHeaders map[string]map[string]string `yaml:"httpHeaders"`
	Headers     map[string]map[string]string `yaml:"headers"`
}

Match is checking source, source tags, and http headers

type MatchPolicy added in v1.8.1

type MatchPolicy struct {
}

MatchPolicy specify a request mach policy

type OneServiceRule added in v1.7.1

type OneServiceRule []*RouteRule

OneServiceRule save route rule for one service

func NewServiceRule added in v1.7.1

func NewServiceRule(raw string) (*OneServiceRule, error)

NewServiceRule create a rule by raw data

func (OneServiceRule) Len added in v1.7.1

func (o OneServiceRule) Len() int

Len return the length of rule

func (OneServiceRule) Value added in v1.7.1

func (o OneServiceRule) Value() []*RouteRule

Value return the rule

type Prefix added in v1.7.1

type Prefix struct {
	RouteRule       map[string]string `yaml:"routeRule"`      //service name is key,value is route rule yaml config
	SourceTemplates map[string]string `yaml:"sourceTemplate"` //template name is key, value is template policy
}

Prefix hold all config items

type RouteRule added in v1.7.1

type RouteRule struct {
	Precedence int         `yaml:"precedence"`
	Routes     []*RouteTag `yaml:"route"`
	Match      Match       `yaml:"match"`
}

RouteRule is having route rule parameters

type RouteTag added in v1.7.1

type RouteTag struct {
	Tags   map[string]string `yaml:"tags"`
	Weight int               `yaml:"weight"`
	Label  string
}

RouteTag gives route tag information

type Router added in v1.7.1

type Router struct {
	Infra   string `yaml:"infra"`
	Address string `yaml:"address"`
}

Router define where rule comes from

type RouterConfig added in v1.7.1

type RouterConfig struct {
	Router          Router                  `yaml:"router"`
	Destinations    map[string][]*RouteRule `yaml:"routeRule"`
	SourceTemplates map[string]*Match       `yaml:"sourceTemplate"`
}

RouterConfig is the struct having info about route rule destinations, source templates Deprecated

var OldRouterDefinition *RouterConfig

OldRouterDefinition is route rule config Deprecated

type RuleItem added in v1.7.1

type RuleItem struct {
	GroupName       string   `json:"groupName"`
	GroupCondition  string   `json:"groupCondition"`  // version=0.0.1
	PolicyCondition string   `json:"policyCondition"` // 80/test!=2
	CaseInsensitive bool     `json:"caseInsensitive"`
	Versions        []string `json:"versions"`
}

RuleItem rule item Deprecated

type ServiceComb added in v1.7.1

type ServiceComb struct {
	Prefix Prefix `yaml:"servicecomb"`
}

ServiceComb hold all config items

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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