etcd

package
v0.0.0-...-457ba4f Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

* User: cr-mao Date: 2023/11/30 14:03 Email: crmao@qq.com Desc: 给管理后台用的。框架这边不用

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(ins *registry.ServiceInstance) (string, error)

Types

type Option

type Option func(o *options)

func WithAddrs

func WithAddrs(addrs ...string) Option

WithAddrs 设置客户端连接地址

func WithClient

func WithClient(client *clientv3.Client) Option

WithClient 设置外部客户端

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置上下文

func WithDialTimeout

func WithDialTimeout(dialTimeout time.Duration) Option

WithDialTimeout 设置客户端拨号超时时间

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace 设置命名空间

func WithRetryInterval

func WithRetryInterval(retryInterval time.Duration) Option

WithRetryInterval 设置心跳重试间隔时间

func WithRetryTimes

func WithRetryTimes(retryTimes int) Option

WithRetryTimes 设置心跳重试次数

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 设置上下文超时时间

type Registry

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

func NewRegistry

func NewRegistry(opts ...Option) *Registry

func (*Registry) Deregister

func (r *Registry) Deregister(ctx context.Context, ins *registry.ServiceInstance) error

Deregister 解注册服务实例

func (*Registry) GetByKey

func (c *Registry) GetByKey(ctx context.Context, key string) (*registry.ServiceInstance, error)

key := fmt.Sprintf("/%s/%s/%s", namespace, gate|node , 服务唯一id)

func (*Registry) GetServerInstances

func (c *Registry) GetServerInstances(ctx context.Context, namespace, serviceName string) (res []*registry.ServiceInstance, err error)

namespace 命名空间, serviceName : gate|node

func (*Registry) Pub

func (c *Registry) Pub(ctx context.Context, key string, value string) error

设置、覆盖值,如设置权重

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, ins *registry.ServiceInstance) error

Register 注册服务实例

func (*Registry) Services

func (r *Registry) Services(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error)

Services 获取服务实例列表

func (*Registry) Stop

func (r *Registry) Stop() error

Stop 停止注册服务

func (*Registry) Watch

func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error)

Watch 监听相同服务名的服务实例变化

Jump to

Keyboard shortcuts

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