Documentation ¶
Overview ¶
Etcd driver for the SD registry package.
Most of the Etcd driver is implemented by an Etcd watcher. The watcher is mostly meant to be used by the driver, but if you have a similar use case you can use the watcher directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MessageBufSz int = 10
Default SourceConn channel buffer size, in number of messages. The thread sending these messages should preferably not block too long, since that can make it tough to catch up. Thus this should be big enough for normal usage. Can Also be set per watcher.
var RequestTimeout = 2 * time.Second
Timeout for non-waiting GET requests.
Functions ¶
This section is empty.
Types ¶
type Watcher ¶
type Watcher struct { Kapi *etcdlight.KAPI Prefix string RequestTimeout time.Duration MessageBufSz int // contains filtered or unexported fields }
func NewWatcher ¶
Returns a new Etcd Watcher for the given etcd URL and path prefix. Note that we do not sync the etcd nodes by default, since a proxy connection is assumed. You could sync them manually though.
The TLS pointer is optional, used for HTTPS connections if given.
Errors returned are from url.Parse
func (*Watcher) Close ¶
Tell the watcher to terminate. It's an error to call this if there's still any open channels. They need to be closed first, or panics might occur.
func (*Watcher) Connect ¶
func (w *Watcher) Connect(ctx context.Context, service string, conf bconf.Bconf) (sdr.SourceConn, error)
Start listening for updates on the service path in etcd, combined with the watcher prefix. It's assumed that the first step in this directory are the host keys, and the rest of the path are value keys. This will wait until a valid response is received from etcd, you can abort it by cancelling the context.