kratos: github.com/bilibili/kratos/pkg/naming Index | Files | Directories

package naming

import "github.com/bilibili/kratos/pkg/naming"

Index

Package Files

naming.go

Constants

const (
    MetaWeight  = "weight"
    MetaCluster = "cluster"
    MetaZone    = "zone"
    MetaColor   = "color"
)

metadata common key

type Builder Uses

type Builder interface {
    Build(id string) Resolver
    Scheme() string
}

Builder resolver builder.

type Instance Uses

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"`
    // Status instance status, eg: 1UP 2Waiting
    Status int64 `json:"status"`
}

Instance represents a server the client connects to.

type InstancesInfo Uses

type InstancesInfo struct {
    Instances map[string][]*Instance `json:"instances"`
    LastTs    int64                  `json:"latest_timestamp"`
    Scheduler []Zone                 `json:"scheduler"`
}

InstancesInfo instance info.

func (*InstancesInfo) UseScheduler Uses

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 Registry Uses

type Registry interface {
    Register(ctx context.Context, ins *Instance) (cancel context.CancelFunc, err error)
    Close() error
}

Registry Register an instance and renew automatically.

type Resolver Uses

type Resolver interface {
    Fetch(context.Context) (*InstancesInfo, bool)
    Watch() <-chan struct{}
    Close() error
}

Resolver resolve naming service

type Zone Uses

type Zone struct {
    Src string           `json:"src"`
    Dst map[string]int64 `json:"dst"`
}

Zone zone scheduler info.

Directories

PathSynopsis
discovery
etcd

Package naming imports 2 packages (graph) and is imported by 7 packages. Updated 2019-10-11. Refresh now. Tools for package owners.