etcd

package
v0.0.0-...-f3120f0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package etcd provides a subscriber implementation for etcd.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoKey   = errors.New("no key provided")
	ErrNoValue = errors.New("no value provided")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetEntries will query the given prefix in etcd and returns a set of entries.
	GetEntries(prefix string) ([]string, error)

	// WatchPrefix starts watching every change for given prefix in etcd. When an
	// change is detected it will populate the responseChan when an *etcd.Response.
	WatchPrefix(prefix string, responseChan chan *etcd.Response)

	// Register a service with etcd.
	Register(s Service) error
	// Deregister a service with etcd.
	Deregister(s Service) error
}

Client is a wrapper around the etcd client.

func NewClient

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

NewClient returns an *etcd.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
	DialKeepAline           time.Duration
	HeaderTimeoutPerRequest time.Duration
}

ClientOptions defines options for the etcd client.

type Registrar

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

Registrar registers service instance liveness information to etcd.

func NewRegistrar

func NewRegistrar(client Client, service Service, logger log.Logger) *Registrar

NewRegistrar returns a etcd Registrar acting on the provided catalog registration.

func (*Registrar) Deregister

func (r *Registrar) Deregister()

Deregister implements sd.Registrar interface.

func (*Registrar) Register

func (r *Registrar) Register()

Register implements sd.Registrar interface.

type Service

type Service struct {
	Key           string // discovery key, example: /myorganization/myplatform/
	Value         string // service name value, example: addsvc
	DeleteOptions *etcd.DeleteOptions
}

Service holds the key, value and instance identifying data you want to publish to etcd.

type Subscriber

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

Subscriber yield endpoints stored in a certain etcd keyspace. Any kind of change in that keyspace is watched and will update the Subscriber endpoints.

func NewSubscriber

func NewSubscriber(c Client, prefix string, factory sd.Factory, logger log.Logger) (*Subscriber, error)

NewSubscriber returns an etcd subscriber. It will start watching the given prefix for changes, and update the endpoints.

func (*Subscriber) Endpoints

func (s *Subscriber) Endpoints() ([]endpoint.Endpoint, error)

Endpoints implements the Subscriber interface.

func (*Subscriber) Stop

func (s *Subscriber) Stop()

Stop terminates the Subscriber.

Jump to

Keyboard shortcuts

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