registry

package
v0.0.0-...-04e6e7a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type DeRegisterOption

type DeRegisterOption func(opt *DeRegisterOptions)

DeRegisterOption 注册服务参数

func DeregisterContext

func DeregisterContext(ctx context.Context) DeRegisterOption

DeregisterContext 注销服务的上下文

type DeRegisterOptions

type DeRegisterOptions struct {
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

DeRegisterOptions 注销服务参数

type GetOption

type GetOption func(opt *GetOptions)

func GetContext

func GetContext(ctx context.Context) GetOption

func GetScheme

func GetScheme(scheme string) GetOption

type GetOptions

type GetOptions struct {
	Context context.Context // 上下文
	Scheme  string          // 服务协议
}

GetOptions 获取服务参数

type Node

type Node struct {
	Id       string            `json:"id"`       // 节点id
	Address  string            `json:"address"`  // 节点地址
	Weight   int               `json:"weight"`   // 节点权重
	Region   string            `json:"region"`   // 区域
	Zone     string            `json:"zone"`     // 地区
	Metadata map[string]string `json:"metadata"` // 节点元信息
}

Node 节点信息

type RegisterOption

type RegisterOption func(opt *RegisterOptions)

RegisterOption 注册服务参数

func RegisterContext

func RegisterContext(ctx context.Context) RegisterOption

RegisterContext 设置注册服务上下文

func RegisterTTl

func RegisterTTl(t time.Duration) RegisterOption

RegisterTTl 设置租约时间

type RegisterOptions

type RegisterOptions struct {
	TTL time.Duration
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

RegisterOptions 注册服务时的额外参数

type Registry

type Registry interface {
	// Register 注册服务
	Register(srv *Service, opts ...RegisterOption) error
	// Deregister 注销服务
	Deregister(srv *Service, opts ...DeRegisterOption) error
	// GetService 获取服务
	GetService(name string, opts ...GetOption) ([]*Service, error)
	// WatchService 监听服务
	WatchService(opts ...WatchOption) (chan WatchServiceResult, error)
	// ListService 服务列表
	ListService() ([]*Service, error)
	// String 获取注册中心类型
	String() string
	// Close 关闭注册中心
	Close() error
}

Registry 注册中心接口

type Result

type Result struct {
	Action  string   // 操作
	Service *Service // 服务
}

Result 观察者返回结果

type Service

type Service struct {
	Name     string            `json:"name"`     // 服务名称
	Version  string            `json:"version"`  // 版本
	Scheme   string            `json:"scheme"`   // 服务协议
	Nodes    []*Node           `json:"nodes"`    // 所有节点信息
	Metadata map[string]string `json:"metadata"` // 元信息
}

Service 服务

type WatchOption

type WatchOption func(opt *WatchOptions)

WatchOption 参数

func WatchContext

func WatchContext(ctx context.Context) WatchOption

WatchContext 设置监听服务的上下文

func WatchScheme

func WatchScheme(scheme string) WatchOption

WatchScheme 设置监听的服务

func WatchService

func WatchService(name string) WatchOption

WatchService 设置监听的服务

type WatchOptions

type WatchOptions struct {
	Service string          // 监听的服务名
	Scheme  string          // 服务协议
	Context context.Context // 上下文
}

WatchOptions 监听服务参数

type WatchServiceResult

type WatchServiceResult struct {
	Services []Service // 服务列表
}

WatchServiceResult 监听服务返回

func (*WatchServiceResult) DeepCopy

func (w *WatchServiceResult) DeepCopy() *WatchServiceResult

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Stop()
}

Watcher 观察者接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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