Documentation ¶
Index ¶
- Constants
- Variables
- func GetConfigContents(key string) (string, error)
- func Init() error
- func InitRouter() error
- func ReadMicroserviceConfigFromBytes(data []byte) error
- func SetKeyValueByFile(key, f string) (string, error)
- type DarkLaunchRule
- type Match
- type RouteRule
- type RouteTag
- type RouterConfig
- type RuleItem
Constants ¶
const ( CseRegistryAddress = "CSE_REGISTRY_ADDR" CseConfigCenterAddress = "CSE_CONFIG_CENTER_ADDR" CseMonitorServer = "CSE_MONITOR_SERVER_ADDR" )
constant environment keys service center, config center, monitor server addresses
const ( DarkLaunchPrefix = "cse.darklaunch.policy." DarkLaunchTypeRule = "RULE" DarkLaunchTypeRate = "RATE" TemplateKey = "sourceTemplate" )
constant for route rule keys
Variables ¶
var ErrNoName = errors.New("Service name is missing")
ErrNoName is used to represent the service name missing error
var GlobalDefinition *model.GlobalCfg
GlobalDefinition is having the information about region, load balancing, service center, config center, protocols, and handlers for the micro service
var HystricConfig *model.HystrixConfigWrapper
HystricConfig is having info about isolation, circuit breaker, fallback properities of the micro service
var MicroserviceDefinition *model.MicroserviceCfg
MicroserviceDefinition is having the info about application id, provider info, description of the service, and description of the instance
var NodeIP string
NodeIP gives the information of node ip
var PassLagerDefinition *model.PassLagerCfg
PassLagerDefinition is having the information about loging
var SelfMetadata map[string]string
SelfMetadata is gives meta data of the self micro service
var SelfServiceID string
SelfServiceID 单进程多微服务根本没法记录依赖关系,因为一个进程里有多个微服务,你在调用别的微服务时到底该怎么添加依赖关系? 只能随意赋值个id
var SelfServiceName string
SelfServiceName is self micro service name
var SelfVersion string
SelfVersion gives version of the self micro service
var Stage string
Stage gives the information of environment stage
Functions ¶
func GetConfigContents ¶
GetConfigContents get configuration contents
func Init ¶
func Init() error
Init is initialize the configuration directory, lager, archaius, route rule, and schema
func ReadMicroserviceConfigFromBytes ¶
ReadMicroserviceConfigFromBytes read micro service configurations from bytes
func SetKeyValueByFile ¶
SetKeyValueByFile is for adding configurations of the file to the archaius through external configuration source
Types ¶
type DarkLaunchRule ¶
type DarkLaunchRule struct { Type string `json:"policyType"` // RULE/RATE Items []*RuleItem `json:"ruleItems"` }
DarkLaunchRule dark launch rule
type Match ¶
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 RouteRule ¶
type RouteRule struct { Precedence int `yaml:"precedence"` Routes []*RouteTag `yaml:"route"` Match Match `yaml:"match"` }
RouteRule is having route rule parameters
func TranslateRules ¶
func TranslateRules(rule *DarkLaunchRule) []*RouteRule
TranslateRules translate rules
type RouteTag ¶
RouteTag gives route tag information
func GenerateRouteTags ¶
GenerateRouteTags generate route tags
type RouterConfig ¶
type RouterConfig struct { Destinations map[string][]*RouteRule `yaml:"routeRule"` SourceTemplates map[string]*Match `yaml:"sourceTemplate"` }
RouterConfig is the struct having info about route rule destinations, source templates
func GetRouterConfig ¶
func GetRouterConfig() *RouterConfig
GetRouterConfig get router configuurations