Documentation
¶
Index ¶
Constants ¶
const Namespace = "github_com/devopsfaith/krakend-etcd"
Namespace is the key to use to store and access the custom config data
Variables ¶
var ( // ErrNoConfig is the error to be returned when there is no config with the etcd namespace ErrNoConfig = fmt.Errorf("unable to create the etcd client: no config") // ErrBadConfig is the error to be returned when the config is not well defined ErrBadConfig = fmt.Errorf("unable to create the etcd client with the received config") // ErrNoMachines is the error to be returned when the config has not defined one or more servers ErrNoMachines = fmt.Errorf("unable to create the etcd client without a set of servers") // ErrNilClient is the error to be nil client ErrNilClient = fmt.Errorf("nil etcd client") )
Functions ¶
func SubscriberFactory ¶
func SubscriberFactory(ctx context.Context, c Client) sd.SubscriberFactory
SubscriberFactory builds a an etcd subscriber SubscriberFactory with the received etcd client
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.
func NewClientV3 ¶
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
DialKeepAliveTimeout 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