etcd

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name    string
	Address string
	Port    int

	Endpoints            []string      `yaml:"endpoints"`
	AutoSyncInterval     time.Duration `yaml:"autoSyncInterval"`
	DialTimeout          time.Duration `yaml:"dialTimeout"`    // 秒
	DefLeaseSecond       time.Duration `yaml:"defLeaseSecond"` // 续租时间(秒)
	DialKeepAliveTime    time.Duration `yaml:"dialKeepAliveTime"`
	DialKeepAliveTimeout time.Duration `yaml:"dialKeepAliveTimeout"`
}

123

type Handler

type Handler struct {
	Client *clientv3.Client
	Conf   Config
}

func New

func New(conf Config) *Handler

func (*Handler) DiscoverServices

func (p *Handler) DiscoverServices(name string) ([]Service, error)

DiscoverServices 发现服务

func (*Handler) Get

func (p *Handler) Get(key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)

func (*Handler) Put

func (p *Handler) Put(key, value string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)

func (*Handler) RegisterService

func (p *Handler) RegisterService(name string, address string, port int) error

RegisterService 注册服务

func (*Handler) RegisterServiceDefault

func (p *Handler) RegisterServiceDefault() error

RegisterServiceDefault 注册服务默认配置

type Service

type Service struct {
	Name    string
	Address string
	Port    int
}

Service 服务结构体

func (*Service) GetUrl added in v2.0.8

func (s *Service) GetUrl() string

Jump to

Keyboard shortcuts

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