etcd

package
v1.1.25 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package etcd is registered as a service using etcd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(etcdEndpoints []string, id string, instanceName string, instanceEndpoints []string, opts ...etcdcli.Option) (registry.Registry, *registry.ServiceInstance, error)

NewRegistry 创建一个新的 etcd 注册表实例。 注意:如果设置了 etcdcli.WithConfig(*clientv3.Config) 参数,则 etcdEndpoints 参数将被忽略!

Types

type Option

type Option func(o *options)

Option 是 etcd 注册表的选项类型。

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置注册表的上下文。

func WithMaxRetry

func WithMaxRetry(num int) Option

WithMaxRetry 设置最大重试次数。

func WithNamespace

func WithNamespace(ns string) Option

WithNamespace 设置注册表的命名空间。

func WithRegisterTTL

func WithRegisterTTL(ttl time.Duration) Option

WithRegisterTTL 设置注册的 TTL。

type Registry

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

Registry 是 etcd 注册表。

func New

func New(client *clientv3.Client, opts ...Option) (r *Registry)

New 创建一个新的 etcd 注册表实例。

func (*Registry) Deregister

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

Deregister 注销服务实例。

func (*Registry) GetService

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

GetService 根据服务名称获取服务实例列表。

func (*Registry) IsServiceRegistered added in v1.0.51

func (r *Registry) IsServiceRegistered(ctx context.Context, key string) (bool, error)

IsServiceRegistered 检查给定的服务实例是否已注册。

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, service *registry.ServiceInstance) (*clientv3.Client, error)

Register 注册服务实例。

func (*Registry) Watch

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

Watch 根据服务名称创建一个观察者。

Jump to

Keyboard shortcuts

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