discovery

package module
v0.0.0-...-5b39e59 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

README

service discovery via etcd v3

How to run unit test

go get github.com/golang/dep

  • install dependencies

dep ensure

  • start local etcd, which listens at 127.0.0.1:2379 by default

etcd

  • run tests

go test

Documentation

https://godoc.org/github.com/deepfabric/discovery

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EtcdRegistry

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

EtcdRegistry registers to etcd

func NewEtcdRegistry

func NewEtcdRegistry(option Option) (r *EtcdRegistry, err error)

NewEtcdRegistry creates EtcdRegistry

func (*EtcdRegistry) Close

func (r *EtcdRegistry) Close()

Close cancel RegisterLoop

func (*EtcdRegistry) Err

func (r *EtcdRegistry) Err() error

Err returns the error occurred during RegisterLoop

func (*EtcdRegistry) RegisterLoop

func (r *EtcdRegistry) RegisterLoop()

RegisterLoop keepalives the key in a loop until an error occur or EtcdRegistry be closed

type EtcdWatcher

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

EtcdWatcher models after grpc.naming.Watcher

func NewEtcdWatcher

func NewEtcdWatcher(registryDir, serviceName string, endpoints []string) (w *EtcdWatcher, err error)

NewEtcdWatcher creates EtcdWatcher

func (*EtcdWatcher) Close

func (w *EtcdWatcher) Close()

Close cancels the in-flight etcd transaction

func (*EtcdWatcher) Next

func (w *EtcdWatcher) Next() (updates []*naming.Update, err error)

Next returns current value if it's invoked the first time, otherwise blocks until next update occur

type NodeData

type NodeData map[string]string

NodeData is the struct of value part of registered KV

type Option

type Option struct {
	Endpoints   []string //etcd urls
	RegistryDir string
	ServiceName string
	NodeID      string   //key is fmt.Sprintf("%s/%s/%s", option.RegistryDir, option.ServiceName, option.NodeID)
	NData       NodeData //value
	TTL         int64    //TTL of key
}

Option is the configuration of EtcdRegistry

Jump to

Keyboard shortcuts

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