etcd

package
v0.0.0-...-1dd3e1b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 上锁超时时间
	TIMEOUT = 10
	TTL     = 5
)

Variables

This section is empty.

Functions

func NewResolver

func NewResolver(client *Client, scheme string) re.Builder

func RegisterMethod

func RegisterMethod(client *Client, version, service, method string, auth bool) error

func UnRegisterMethod

func UnRegisterMethod(client *Client, version, service, method string) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}
var (
	EtcdClient *Client
)

func NewClient

func NewClient(cfg conf.EtcdConfig) (*Client, error)

func (*Client) Cli

func (cl *Client) Cli() *v3.Client

func (*Client) Close

func (cl *Client) Close() error

关闭客户端

func (*Client) GetPattern

func (cl *Client) GetPattern(key string) (result map[string]string)

func (*Client) GetSingle

func (cl *Client) GetSingle(key string) string

func (*Client) Kv

func (cl *Client) Kv() v3.KV

func (*Client) RegisterApi

func (cl *Client) RegisterApi(name string, data interface{}, config conf.YamlConfig) error

传入yaml配置

func (*Client) RegisterService

func (cl *Client) RegisterService(name, addr string, ttl int64) error

func (*Client) Set

func (cl *Client) Set(key, value string) bool

func (*Client) UnRegister

func (cl *Client) UnRegister(name, addr string) error

func (*Client) UnRegisterApi

func (cl *Client) UnRegisterApi(name string, data interface{}, config conf.YamlConfig) error

注销方法

type DistributeLock

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

func NewLock

func NewLock(client *Client, prefix string, timeout ...int) (*DistributeLock, error)

func (*DistributeLock) Close

func (l *DistributeLock) Close() error

func (*DistributeLock) Lock

func (l *DistributeLock) Lock() error

func (*DistributeLock) UnLock

func (l *DistributeLock) UnLock() error

type Method

type Method struct {
	NoAuth bool   `json:"no_auth"` // 是否需要登录
	Path   string `json:"path"`
}

func (*Method) Marshal

func (m *Method) Marshal() string

Jump to

Keyboard shortcuts

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