etcd

package
v0.0.0-...-13c8884 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWatchs

func AddWatchs(etcdAddrs, services []string, fUpdate func(svc string, svcAddrs []string))

func RegAndWatchs

func RegAndWatchs(logMsg string, cfg *SrvCfg, fUpdate func(svc string, svcAddrs []string))

func Register

func Register(cfg *SrvCfg)

Types

type EtcdClient

type EtcdClient struct {
	// config
	EtcdAddrs  []string // etcd server address
	ServerPath string   // like "/game"
	Watch      chan bool

	// attr
	KeysAPI     client.KeysAPI
	ServerInfos []*ServerInfo // server infos
	LastIndex   uint64        // last modify index
	sync.Mutex                // mutex for this.ServerAddrs op
}

func NewEtcdClient

func NewEtcdClient(etcdAddrs []string, serverPath string) *EtcdClient

func (*EtcdClient) GetServerInfos

func (this *EtcdClient) GetServerInfos() []*ServerInfo

type EtcdRegister

type EtcdRegister struct {
	EtcdAddrs      []string      // etcd server address
	ServerPath     string        // like "/game"
	ServerAddr     string        // like "xx.xx.xxx.x:1234"
	UpdateInterval time.Duration // update register interval
	ServerNodeTTL  time.Duration // server node ttl
	ServerValue    string

	KeysAPI client.KeysAPI
	// contains filtered or unexported fields
}

func NewEtcdRegister

func NewEtcdRegister(etcdAddrs []string,
	updateInterval, serverNodeTTL time.Duration) *EtcdRegister

func (*EtcdRegister) Register

func (this *EtcdRegister) Register(serverPath, serverAddr, value string)

func (*EtcdRegister) Unregister

func (this *EtcdRegister) Unregister()

type ServerInfo

type ServerInfo struct {
	Addr  string
	Value string
}

type SrvCfg

type SrvCfg struct {
	EtcdAddrs []string // etcd地址数组

	SrvAddr      string // 服务监听addr
	SrvRegPath   string // etcd上服务位置
	SrvRegUpTick int64  // etcd上服务更新ttl间隔(ms)

	WatchPaths []string // 需监听的服务器位置
}

Jump to

Keyboard shortcuts

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