registry

package
v3.1.22 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetService

func GetService(s string) *server.ServiceInfo

GetService ..

func GetServiceKey

func GetServiceKey(prefix string, s *server.ServiceInfo) string

GetServiceKey ..

func GetServiceValue

func GetServiceValue(s *server.ServiceInfo) string

GetServiceValue ..

func RegisterBuilder

func RegisterBuilder(kind string, build Builder)

RegisterBuilder ...

func Service

func Service(srv server.Server) server.Server

Service ...

Types

type BuildFunc

type BuildFunc func(string) (Registry, error)

BuildFunc ...

type Builder

type Builder func(string) Registry

Builder ...

type Config

type Config map[string]ConfigLab

Config ...

func New

func New() Config

New ...

func (Config) InitDefaultRegister

func (config Config) InitDefaultRegister()

InitDefaultRegister ...

func (Config) Lab

func (config Config) Lab(name string, lab ConfigLab) Config

Lab ...

type ConfigLab

type ConfigLab struct {
	Kind          string `json:"kind" description:"底层注册器类型, eg: etcdv3, consul"`
	ConfigKey     string `json:"configKey" description:"底册注册器的配置键"`
	DeplaySeconds int    `json:"deplaySeconds" description:"延迟注册"`
}

ConfigLab ...

type Configuration

type Configuration struct {
	Routes []Route           `json:"routes"` // 配置客户端路由策略
	Labels map[string]string `json:"labels"` // 配置服务端标签: 分组
}

Configuration ...

type ConsumerConfig

type ConsumerConfig struct {
	ID     string `json:"id"`
	Scheme string `json:"scheme"`
	Host   string `json:"host"`
}

ConsumerConfig config of consumer 客户端调用app的配置

type Endpoints

type Endpoints struct {
	// 服务节点列表
	Nodes map[string]server.ServiceInfo

	// 路由配置
	RouteConfigs map[string]RouteConfig

	// 消费者元数据
	ConsumerConfigs map[string]ConsumerConfig

	// 服务元信息
	ProviderConfigs map[string]ProviderConfig
}

Endpoints ...

func (*Endpoints) DeepCopy

func (in *Endpoints) DeepCopy() *Endpoints

DeepCopy ...

func (*Endpoints) DeepCopyInfo

func (in *Endpoints) DeepCopyInfo(out *Endpoints)

DeepCopyInfo ...

type Event

type Event uint8

Event ...

const (
	// EventUnknown ...
	EventUnknown Event = iota
	// EventUpdate ...
	EventUpdate
	// EventDelete ...
	EventDelete
)

EventUnknown ...

type EventMessage

type EventMessage struct {
	Event
	Kind
	Name    string
	Scheme  string
	Address string
	Message interface{}
}

EventMessage ...

type Kind

type Kind uint8

Kind ...

const (
	// KindUnknown ...
	KindUnknown Kind = iota
	// KindProvider ...
	KindProvider
	// KindConfigurator ...
	KindConfigurator
	// KindConsumer ...
	KindConsumer
)

KindUnknown ...

func ToKind

func ToKind(kindStr string) Kind

ToKind ...

func (Kind) String

func (kind Kind) String() string

String ...

type Local

type Local struct{}

Local Nop registry, used for local development/debugging

func (Local) Close

func (n Local) Close() error

Close ...

func (Local) Kind

func (n Local) Kind() string

Kind Close ...

func (Local) ListServices

func (n Local) ListServices(ctx context.Context, s string, s2 string) ([]*server.ServiceInfo, error)

ListServices ...

func (Local) RegisterService

func (n Local) RegisterService(ctx context.Context, si *server.ServiceInfo) error

RegisterService ...

func (Local) UnregisterService

func (n Local) UnregisterService(ctx context.Context, si *server.ServiceInfo) error

UnregisterService ...

func (Local) WatchServices

func (n Local) WatchServices(ctx context.Context, s string, s2 string) (chan Endpoints, error)

WatchServices ...

type ProviderConfig

type ProviderConfig struct {
	ID         string            `json:"id"`
	Scheme     string            `json:"scheme"`
	Host       string            `json:"host"`
	Region     string            `json:"region"`
	Zone       string            `json:"zone"`
	Deployment string            `json:"deployment"`
	Metadata   map[string]string `json:"metadata"`
	Enable     bool              `json:"enable"`
}

ProviderConfig config of provider 通过这个配置,修改provider的属性

type Registry

type Registry interface {
	RegisterService(context.Context, *server.ServiceInfo) error
	UnregisterService(context.Context, *server.ServiceInfo) error
	ListServices(context.Context, string, string) ([]*server.ServiceInfo, error)
	WatchServices(context.Context, string, string) (chan Endpoints, error)
	Kind() string
	io.Closer
}

Registry register/unregister service registry impl should control rpc timeout

var DefaultRegisterer Registry = &Local{}

DefaultRegisterer default register

type Route

type Route struct {
	// 路由方法名
	Method string `json:"method" toml:"method"`
	// 路由权重组, 按比率在各个权重组中分配流量
	WeightGroups []WeightGroup `json:"weightGroups" toml:"weightGroups"`
	// 路由部署组, 将流量导入部署组
	Deployment string `json:"deployment" toml:"deployment"`
}

Route represents route configuration

type RouteConfig

type RouteConfig struct {
	ID         string   `json:"id" toml:"id"`
	Scheme     string   `json:"scheme" toml:"scheme"`
	Host       string   `json:"host" toml:"host"`
	Deployment string   `json:"deployment"`
	URI        string   `json:"uri"`
	Upstream   Upstream `json:"upstream"`
}

RouteConfig ...

func (RouteConfig) String

func (config RouteConfig) String() string

String ...

type ServerInstance

type ServerInstance struct {
	Scheme string
	IP     string
	Port   int
	Labels map[string]string
}

ServerInstance ...

type Upstream

type Upstream struct {
	Nodes  map[string]int `json:"nodes"`
	Groups map[string]int `json:"groups"`
}

Upstream represents upstream balancing config

type WeightGroup

type WeightGroup struct {
	Group  string `json:"group" toml:"group"`
	Weight int    `json:"weight" toml:"weight"`
}

WeightGroup ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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