etcd

package
v0.3.5-0...-ad62298 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package etcd includes etcd clients ops related

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(addrs ...string) (client.KeysAPI, error)

Connect to etcd client addr format like: http://host:port

func OpenDebug

func OpenDebug(open bool)

OpenDebug set debug mode on

Types

type ProvideOptions

type ProvideOptions struct {
	NamePrefix        string             // ServerName Prefix if "" means no prefix
	SetOpts           *client.SetOptions // etcd client SetOptions
	TTLDuration       time.Duration      // ttl time.Duration
	HeartbeatDuration time.Duration      // HeartbeatDuration duration
}

ProvideOptions ...

type Server

type Server struct {
	Name  string `json:"name"`
	Addr  string `json:"addr"`
	Alive bool   `json:"alive"`
}

Server ...

type ServerProvider

type ServerProvider interface {
	Name() string
	Addr() string
	KeysAPI() client.KeysAPI
	// Provide support set key-value to etcd
	Provide(*ProvideOptions) error
	// Quit while should be called while Server quit
	Quit(*ProvideOptions) error
}

ServerProvider ....

func NewProvider

func NewProvider(kapi client.KeysAPI, name, addr string) ServerProvider

NewProvider ...

type Watcher

type Watcher struct {
	sync.RWMutex // RW mutext
	// contains filtered or unexported fields
}

Watcher ... ref to http://daizuozhuo.github.io/etcd-service-discovery/

func NewWatcher

func NewWatcher(
	kapi client.KeysAPI, serverPrefix string, d time.Duration,
) *Watcher

NewWatcher ...

func (*Watcher) AddMember

func (w *Watcher) AddMember(key, value string)

AddMember ...

func (*Watcher) DeleteMember

func (w *Watcher) DeleteMember(key string)

DeleteMember ...

func (*Watcher) ExpireMember

func (w *Watcher) ExpireMember(key string)

ExpireMember ...

func (*Watcher) RangeMember

func (w *Watcher) RangeMember() []Server

RangeMember ...

func (*Watcher) Watch

func (w *Watcher) Watch()

Watch ...

Jump to

Keyboard shortcuts

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