Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( MetaWeight = "weight" MetaCluster = "cluster" MetaZone = "zone" MetaColor = "color" )
metadata common key
Variables ¶
View Source
var ( // ErrDuplication duplication treeid. ErrDuplication = errors.New("discovery: instance duplicate registration") )
View Source
var NewClient = New
Functions ¶
This section is empty.
Types ¶
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery is discovery client.
type Instance ¶
type Instance struct { // Region is region. Region string `json:"region"` // Zone is IDC. Zone string `json:"zone"` // Env prod/pre、uat/fat1 Env string `json:"env"` // AppID is mapping servicetree appid. AppID string `json:"appid"` // Hostname is hostname from docker. Hostname string `json:"hostname"` // Addrs is the address of app instance // format: scheme://host Addrs []string `json:"addrs"` // Version is publishing version. Version string `json:"version"` // LastTs is instance latest updated timestamp LastTs int64 `json:"latest_timestamp"` // Metadata is the information associated with Addr, which may be used // to make load balancing decision. Metadata map[string]string `json:"metadata"` }
Instance represents a server the client connects to.
type InstancesInfo ¶
type InstancesInfo struct { Instances map[string][]*Instance `json:"instances"` LastTs int64 `json:"latest_timestamp"` Scheduler []Zone `json:"scheduler"` }
InstancesInfo instance info.
func (*InstancesInfo) UseScheduler ¶
func (insInf *InstancesInfo) UseScheduler(zone string) (inss []*Instance)
UseScheduler use scheduler info on instances. if instancesInfo contains scheduler info about zone, return releated zone's instances weighted by scheduler. if not,only zone instances be returned.
type NamingConfig ¶ added in v0.1.2
type NamingConfig = Config
type NamingDiscovery ¶ added in v0.1.2
type NamingDiscovery = Discovery
type Registry ¶
type Registry interface { Register(ins *Instance) (cancel context.CancelFunc, err error) Close() error }
Registry Register an instance and renew automatically.
type Resolve ¶
type Resolve struct {
// contains filtered or unexported fields
}
Resolve discveory resolver.
func (*Resolve) Fetch ¶
func (r *Resolve) Fetch() (ins *InstancesInfo, ok bool)
Fetch fetch resolver instance.
type Resolver ¶
type Resolver interface { Fetch() (*InstancesInfo, bool) Watch() <-chan struct{} Close() error }
Resolver resolve naming service
Click to show internal directories.
Click to hide internal directories.