endpoints

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 9 Imported by: 96

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	// Addr is the server address on which a connection will be established.
	// Since etcd 3.1
	Addr string

	// Metadata is the information associated with Addr, which may be used
	// to make load balancing decision.
	// Since etcd 3.1
	Metadata interface{}
}

Endpoint represents a single address the connection can be established with.

Inspired by: https://pkg.go.dev/google.golang.org/grpc/resolver#Address. Please document etcd version since which version each field is supported.

type Key2EndpointMap

type Key2EndpointMap map[string]Endpoint

Key2EndpointMap maps etcd key into struct describing the endpoint.

type Manager

type Manager interface {
	// Update allows to atomically add/remove a few endpoints from etcd.
	Update(ctx context.Context, updates []*UpdateWithOpts) error

	// AddEndpoint registers a single endpoint in etcd.
	// For more advanced use-cases use the Update method.
	AddEndpoint(ctx context.Context, key string, endpoint Endpoint, opts ...clientv3.OpOption) error
	// DeleteEndpoint deletes a single endpoint stored in etcd.
	// For more advanced use-cases use the Update method.
	DeleteEndpoint(ctx context.Context, key string, opts ...clientv3.OpOption) error

	// List returns all the endpoints for the current target as a map.
	List(ctx context.Context) (Key2EndpointMap, error)
	// NewWatchChannel creates a channel that populates or endpoint updates.
	// Cancel the 'ctx' to close the watcher.
	NewWatchChannel(ctx context.Context) (WatchChannel, error)
}

Manager can be used to add/remove & inspect endpoints stored in etcd for a particular target.

func NewManager

func NewManager(client *clientv3.Client, target string) (Manager, error)

NewManager creates an endpoint manager which implements the interface of 'Manager'.

type Operation

type Operation uint8
const (
	// Add indicates an Endpoint is added.
	Add Operation = iota
	// Delete indicates an existing address is deleted.
	Delete
)

type Update

type Update struct {
	// Op - action Add or Delete.
	Op       Operation
	Key      string
	Endpoint Endpoint
}

Update describes a single edit action of an Endpoint.

type UpdateWithOpts

type UpdateWithOpts struct {
	Update
	Opts []clientv3.OpOption
}

UpdateWithOpts describes endpoint update (add or delete) together with etcd options (e.g. to attach an endpoint to a lease).

func NewAddUpdateOpts

func NewAddUpdateOpts(key string, endpoint Endpoint, opts ...clientv3.OpOption) *UpdateWithOpts

NewAddUpdateOpts constructs UpdateWithOpts for endpoint registration.

func NewDeleteUpdateOpts

func NewDeleteUpdateOpts(key string, opts ...clientv3.OpOption) *UpdateWithOpts

NewDeleteUpdateOpts constructs UpdateWithOpts for endpoint deletion.

type WatchChannel

type WatchChannel <-chan []*Update

WatchChannel is used to deliver notifications about endpoints updates.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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