discovery

package
v0.0.0-...-6b5340c Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleKeepAliveResp

func HandleKeepAliveResp(ch <-chan *clientv3.LeaseKeepAliveResponse)

Types

type Discovery

type Discovery interface {
	// 获取服务器的一个地址
	GetServiceAddr(serviceName string) (string, error)
	// 监控服务地址变化
	WatchService(serviceName string) error
}

type EtcdDiscovery

type EtcdDiscovery struct {
	// contains filtered or unexported fields
}

func NewEtcdDiscovery

func NewEtcdDiscovery(endpoints []string) (*EtcdDiscovery, error)

func (*EtcdDiscovery) GetServiceAddr

func (d *EtcdDiscovery) GetServiceAddr(serviceName, key string) (string, error)

func (*EtcdDiscovery) WatchService

func (d *EtcdDiscovery) WatchService(serviceName string) error

type EtcdRegisty

type EtcdRegisty struct {
	// contains filtered or unexported fields
}

基于etcd服务发现中间件,实现regisrty

func NewEtcdRegisty

func NewEtcdRegisty(endpoints []string, opts ...Option) (*EtcdRegisty, error)

func (*EtcdRegisty) DeRegisty

func (r *EtcdRegisty) DeRegisty() error

func (*EtcdRegisty) Registy

func (r *EtcdRegisty) Registy(srv Service) error

type Option

type Option func(er *EtcdRegisty)

func WithLeaseTTL

func WithLeaseTTL(ttl int64) Option

type Registry

type Registry interface {
	// 注册
	Regisrty(srv Service) error
	// 注销
	DeRegistry(srv Service) error
}

type Service

type Service interface {
	Name() string
	Addr() string
}

服务类型

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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