etcd

package
v0.0.0-...-7f749bc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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

func NewClient(ctx context.Context, machines []string, options ClientOptions) (Client, error)

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

func NewSubscriber(ctx context.Context, c Client, prefix string) (*Subscriber, error)

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

Jump to

Keyboard shortcuts

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