config

package
v0.0.0-...-5dc8409 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
const (
	DarkLaunchPrefix   = "cse.darklaunch.policy."
	DarkLaunchTypeRule = "RULE"
	DarkLaunchTypeRate = "RATE"
	TemplateKey        = "sourceTemplate"
)

constant for route rule keys

Variables

View Source
var ErrNoName = errors.New("Service name is missing")

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

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

View Source
var MicroserviceDefinition *model.MicroserviceCfg

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

View Source
var NodeIP string

NodeIP gives the information of node ip

View Source
var PassLagerDefinition *model.PassLagerCfg

PassLagerDefinition is having the information about loging

View Source
var SelfMetadata map[string]string

SelfMetadata is gives meta data of the self micro service

View Source
var SelfServiceID string

SelfServiceID 单进程多微服务根本没法记录依赖关系,因为一个进程里有多个微服务,你在调用别的微服务时到底该怎么添加依赖关系? 只能随意赋值个id

View Source
var SelfServiceName string

SelfServiceName is self micro service name

View Source
var SelfVersion string

SelfVersion gives version of the self micro service

View Source
var Stage string

Stage gives the information of environment stage

Functions

func GetConfigContents

func GetConfigContents(key string) (string, error)

GetConfigContents get configuration contents

func Init

func Init() error

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

func InitRouter

func InitRouter() error

InitRouter initialize router

func ReadMicroserviceConfigFromBytes

func ReadMicroserviceConfigFromBytes(data []byte) error

ReadMicroserviceConfigFromBytes read micro service configurations from bytes

func SetKeyValueByFile

func SetKeyValueByFile(key, f string) (string, error)

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

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

RouteTag gives route tag information

func GenerateRouteTags

func GenerateRouteTags(versions []string) []*RouteTag

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 GetRouteRules

func GetRouteRules() (*RouterConfig, error)

GetRouteRules get route rules

func GetRouterConfig

func GetRouterConfig() *RouterConfig

GetRouterConfig get router configuurations

type RuleItem

type RuleItem struct {
	GroupName       string `json:"groupName"`
	GroupCondition  string `json:"groupCondition"`  // version=0.0.1
	PolicyCondition string `json:"policyCondition"` // 80/test!=2
}

RuleItem rule item

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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