etcd

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCallTimeout = 15 * time.Second

DefaultCallTimeout represents the duration that the etcd client waits at most for read and write operations to etcd.

Variables

View Source
var AlarmTypeName = map[AlarmType]string{
	AlarmOK:      "NONE",
	AlarmNoSpace: "NOSPACE",
	AlarmCorrupt: "CORRUPT",
}

AlarmTypeName provides a text translation for AlarmType codes.

Functions

This section is empty.

Types

type AlarmType

type AlarmType int32

AlarmType defines the type of alarm for etcd.

const (
	// AlarmOK denotes that the cluster member is OK.
	AlarmOK AlarmType = iota

	// AlarmNoSpace denotes that the cluster member has run out of disk space.
	AlarmNoSpace

	// AlarmCorrupt denotes that the cluster member has corrupted data.
	AlarmCorrupt
)

type Client

type Client struct {
	EtcdClient  etcd
	Endpoint    string
	LeaderID    uint64
	Errors      []string
	CallTimeout time.Duration
}

Client wraps an etcd client formatting its output to something more consumable.

func NewClient

func NewClient(ctx context.Context, config ClientConfiguration) (*Client, error)

NewClient creates a new etcd client with the given configuration.

func (*Client) Alarms

func (c *Client) Alarms(ctx context.Context) ([]MemberAlarm, error)

Alarms retrieves all alarms on a cluster.

func (*Client) Close

func (c *Client) Close() error

Close closes the etcd client.

func (*Client) Members

func (c *Client) Members(ctx context.Context) ([]*Member, error)

Members retrieves a list of etcd members.

func (*Client) MoveLeader

func (c *Client) MoveLeader(ctx context.Context, newLeaderID uint64) error

MoveLeader moves the leader to the provided member ID.

func (*Client) RemoveMember

func (c *Client) RemoveMember(ctx context.Context, id uint64) error

RemoveMember removes a given member.

func (*Client) UpdateMemberPeerURLs

func (c *Client) UpdateMemberPeerURLs(ctx context.Context, id uint64, peerURLs []string) ([]*Member, error)

UpdateMemberPeerURLs updates the list of peer URLs.

type ClientConfiguration

type ClientConfiguration struct {
	Endpoint    string
	Proxy       proxy.Proxy
	TLSConfig   *tls.Config
	DialTimeout time.Duration
	CallTimeout time.Duration
}

ClientConfiguration describes the configuration for an etcd client.

type ClientFor

type ClientFor interface {
	ForFirstAvailableNode(ctx context.Context, nodeNames []string) (*Client, error)
	ForLeader(ctx context.Context, nodeNames []string) (*Client, error)
}

ClientFor is an interface for source etcd node selection.

type ClientGenerator

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

ClientGenerator generates etcd clients that connect to specific etcd members on particular control plane nodes.

func NewClientGenerator

func NewClientGenerator(restConfig *rest.Config, tlsConfig *tls.Config, etcdDialTimeout, etcdCallTimeout time.Duration) *ClientGenerator

NewClientGenerator returns a new etcdClientGenerator instance.

func (*ClientGenerator) ForFirstAvailableNode

func (c *ClientGenerator) ForFirstAvailableNode(ctx context.Context, nodeNames []string) (*Client, error)

ForFirstAvailableNode takes a list of nodes and returns a client for the first one that connects.

func (*ClientGenerator) ForLeader

func (c *ClientGenerator) ForLeader(ctx context.Context, nodeNames []string) (*Client, error)

ForLeader takes a list of nodes and returns a client to the leader node.

type GRPCDial

type GRPCDial func(ctx context.Context, addr string) (net.Conn, error)

GRPCDial is a function that creates a connection to a given endpoint.

type Member

type Member struct {
	// ClusterID is the ID of the cluster to which this member belongs
	ClusterID uint64

	// ID is the ID of this cluster member
	ID uint64

	// Name is the human-readable name of the member. If the member is not started, the name will be an empty string.
	Name string

	// PeerURLs is the list of URLs the member exposes to the cluster for communication.
	PeerURLs []string

	// ClientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
	ClientURLs []string

	// IsLearner indicates if the member is raft learner.
	IsLearner bool

	// Alarms is the list of alarms for a member.
	Alarms []AlarmType
}

Member struct defines an etcd member; it is used to avoid spreading github.com/coreos/etcd dependencies.

type MemberAlarm

type MemberAlarm struct {
	// MemberID is the ID of the member associated with the raised alarm.
	MemberID uint64

	// Type is the type of alarm which has been raised.
	Type AlarmType
}

MemberAlarm represents an alarm type association with a cluster member.

Directories

Path Synopsis
Package fake implements testing fakes.
Package fake implements testing fakes.
Package util implements etcd utility functions.
Package util implements etcd utility functions.

Jump to

Keyboard shortcuts

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