etcdv3

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoKey indicates a client method needs a key but receives none.
	ErrNoKey = errors.New("no key provided")

	// ErrNoValue indicates a client method needs a value but receives none.
	ErrNoValue = errors.New("no value provided")
)

Functions

func KeyPrefix

func KeyPrefix(key string) string

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{})

	// Register a service with etcd.
	Register(s *sd.Service) error

	// Deregister a service with etcd.
	Deregister(s *sd.Service) error

	// LeaseID returns the lease id created for this service instance
	LeaseID() int64
}

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.

type ClientOptions

type ClientOptions struct {
	Cert          string
	Key           string
	CACert        string
	DialTimeout   time.Duration
	DialKeepAlive time.Duration

	// DialOptions is a list of dial options for the gRPC client (e.g., for interceptors).
	// For example, pass grpc.WithBlock() to block until the underlying connection is up.
	// Without this, Dial returns immediately and connecting the server happens in background.
	DialOptions []grpc.DialOption

	Username string
	Password string
}

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 Registrar

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

func NewRegistrar

func NewRegistrar(client Client) *Registrar

func (*Registrar) Deregister

func (r *Registrar) Deregister(s *sd.Service)

func (*Registrar) Register

func (r *Registrar) Register(s *sd.Service)

Jump to

Keyboard shortcuts

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