etcd

package
v0.0.0-...-b9a86dc Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prefix = "im"

prefix is the root Dir of services in etcd

Functions

func Register

func Register(name string, rpcServerAddr string, target string, interval xtime.Duration, ttl xtime.Duration) (err error)

Register is the helper function to self-register service into Etcd/Consul server should call Unregister when pocess stop name - service name host - service host port - service port target - etcd dial address, for example: "http://127.0.0.1:2379;http://127.0.0.1:12379" interval - interval of self-register to etcd ttl - ttl of the register information

func Unregister

func Unregister() (err error)

Unregister delete service from etcd

Types

type EtcdResolver

type EtcdResolver struct {
	ServiceName string // service name to resolve
}

EtcdResolver is the implementaion of grpc.naming.Resolver

func NewResolver

func NewResolver(serviceName string) *EtcdResolver

NewResolver return EtcdResolver with service name

func (*EtcdResolver) Resolve

func (er *EtcdResolver) Resolve(target string) (naming.Watcher, error)

Resolve to resolve the service from etcd, target is the dial address of etcd target example: "http://127.0.0.1:2379;http://127.0.0.1:12379;http://127.0.0.1:22379"

type EtcdWatcher

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

EtcdWatcher is the implementaion of grpc.naming.Watcher

func (*EtcdWatcher) Close

func (ew *EtcdWatcher) Close()

Close do nothing

func (*EtcdWatcher) Next

func (ew *EtcdWatcher) Next() ([]*naming.Update, error)

Next to return the updates

Jump to

Keyboard shortcuts

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