Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface {
// GetEntries queries the given prefix in etcd and returns a slice
// containing the values of all keys found, recursively, underneath that
// prefix.
GetEntries(prefix string) ([]string, error)
// WatchPrefix watches the given prefix in etcd for changes. When a change
// is detected, it will signal on the passed channel. Clients are expected
// to call GetEntries to update themselves with the latest set of complete
// values. WatchPrefix will always send an initial sentinel value on the
// channel after establishing the watch, to ensure that clients always
// receive the latest set of values. WatchPrefix will block until the
// context passed to the NewClient constructor is terminated.
WatchPrefix(prefix string, ch chan struct{})
}
Client is a wrapper around the etcd client.
func NewClient ¶
NewClient returns Client with a connection to the named machines. It will return an error if a connection to the cluster cannot be made. The parameter machines needs to be a full URL with schemas. e.g. "http://localhost:2379" will work, but "localhost:2379" will not.
type ClientOptions ¶
type ClientOptions struct {
Cert string
Key string
CACert string
DialTimeout time.Duration
DialKeepAlive time.Duration
HeaderTimeoutPerRequest time.Duration
}
ClientOptions defines options for the etcd client. All values are optional. If any duration is not specified, a default of 3 seconds will be used.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber keeps instances stored in a certain etcd keyspace cached in a fixed subscriber. Any kind of change in that keyspace is watched and will update the Subscriber's list of hosts.
func NewSubscriber ¶
NewSubscriber returns an etcd subscriber. It will start watching the given prefix for changes, and update the subscribers.
func (Subscriber) Hosts ¶
func (s Subscriber) Hosts() ([]string, error)
Hosts implements the subscriber interface
Source Files
¶
- client.go
- subscriber.go