xetcd

package
v0.0.0-...-953156a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindYaml

func BindYaml(path string, bind interface{}) error

yaml "gopkg.in/yaml.v2"

func GetDirNode

func GetDirNode(ctx context.Context, client *clientv3.Client, path string) (map[string]string, error)

func GetNode

func GetNode(ctx context.Context, client *clientv3.Client, key string) (string, error)

GetNode

func NewElection

func NewElection(cli *XClientV3, key, val string, f func() error, sopts ...concurrency.SessionOption) error

NewElection NewElection

func NewEtcdClientV3

func NewEtcdClientV3(opt *EtcdConfig) (*clientv3.Client, error)

NewEtcdClientV3 NewEtcdClientV3

func NewMutex

func NewMutex(cli *XClientV3, key string, f func() error, sopts ...concurrency.SessionOption) error

NewMutex NewMutex

func Watch

func Watch(client *clientv3.Client, root string, op ...Option) error

func WatchDirNode

func WatchDirNode(ctx context.Context, client *clientv3.Client, path string, action WatchDirNodeFunc) error

func WatchNode

func WatchNode(ctx context.Context, client *clientv3.Client, path string, action WatchNodeFunc) error

Types

type ConvertFunc

type ConvertFunc func(data interface{}) error

func ObjectTo

func ObjectTo(out interface{}) ConvertFunc

func StringTo

func StringTo(action StrConvert) ConvertFunc

type EtcdConfig

type EtcdConfig struct {
	Peers          []string `yaml:"Peers" json:"Peers"`
	TimeoutSeconds int64    `yaml:"TimeoutSeconds" json:"TimeoutSeconds"`
	Root           string   `yaml:"Root" json:"Root"`
	UserName       string   `yaml:"Username" json:"Username"`
	Password       string   `yaml:"Password" json:"Password"`
	Cert           string   `yaml:"Cert" json:"Cert"`
	Key            string   `yaml:"Key" json:"Key"`
	CA             string   `yaml:"CA" json:"CA"`
}

EtcdConfig EtcdConfig

type MapConvert

type MapConvert func(data map[string]string)

type ObjectConvert

type ObjectConvert func(data map[string]interface{})

type Option

type Option struct {
	Key     string
	Convert ConvertFunc
}

type StrConvert

type StrConvert func(data string)

type WatchDirNodeFunc

type WatchDirNodeFunc func(key, val string) error

type WatchNodeFunc

type WatchNodeFunc func(val string) error

type XClientV3

type XClientV3 struct {
	Client *clientv3.Client
	// contains filtered or unexported fields
}

func NewCli

func NewCli(cli *clientv3.Client, root string) *XClientV3

func NewEtcdCli

func NewEtcdCli(opt *EtcdConfig) (*XClientV3, error)

func (*XClientV3) Get

func (h *XClientV3) Get(key string) (string, error)

func (*XClientV3) GetRoot

func (h *XClientV3) GetRoot() string

func (*XClientV3) Set

func (h *XClientV3) Set(key, val string) error

func (*XClientV3) WatchDirNode

func (h *XClientV3) WatchDirNode(key string, action WatchDirNodeFunc) error

func (*XClientV3) WatchNode

func (h *XClientV3) WatchNode(key string, action WatchNodeFunc) error

Jump to

Keyboard shortcuts

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