etcdutil

package
v0.0.0-...-44a46bf Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultDialTimeout is the maximum amount of time a dial will wait for a
	// connection to setup. 30s is long enough for most of the network conditions.
	DefaultDialTimeout = 30 * time.Second

	// DefaultRequestTimeout 10s is long enough for most of etcd clusters.
	DefaultRequestTimeout = 10 * time.Second

	// DefaultRevokeLeaseTimeout is the maximum amount of time waiting for revoke etcd lease.
	DefaultRevokeLeaseTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

func AddMember

func AddMember(client *clientv3.Client, peerAddrs []string) (*clientv3.MemberAddResponse, error)

AddMember adds an etcd member.

func CreateClient

func CreateClient(endpoints []string, tlsCfg *tls.Config) (*clientv3.Client, error)

CreateClient creates an etcd client with some default config items.

func DoTxnWithRepeatable

func DoTxnWithRepeatable(cli *clientv3.Client, opFunc EtcdOpFunc) (*clientv3.TxnResponse, int64, error)

DoTxnWithRepeatable do multiple etcd operations in one txn with repeatable retry. There are two situations that this function can be used: 1. The operations are all read operations. 2. The operations are all write operations, but write operations tolerate being written to etcd ** at least once **. TODO: add unit test to test encountered an retryable error first but then recovered.

func IsLimitedRetryableError

func IsLimitedRetryableError(err error) bool

IsLimitedRetryableError check whether error is retryable error for etcd to build again in a limited number of times.

func IsRetryableError

func IsRetryableError(err error) bool

IsRetryableError returns true if the etcd error is retryable to write ** repeatable **. https://github.com/etcd-io/etcd/blob/v3.5.2/client/v3/retry.go#L53

func ListMembers

func ListMembers(client *clientv3.Client) (*clientv3.MemberListResponse, error)

ListMembers returns a list of internal etcd members.

func RemoveMember

func RemoveMember(client *clientv3.Client, id uint64) (*clientv3.MemberRemoveResponse, error)

RemoveMember removes an etcd member by the given id.

Types

type EtcdOpFunc

type EtcdOpFunc func(*tcontext.Context, *clientv3.Client) (interface{}, error)

func FullOpFunc

func FullOpFunc(cmps []clientv3.Cmp, opsThen, opsElse []clientv3.Op) EtcdOpFunc

func ThenOpFunc

func ThenOpFunc(ops ...clientv3.Op) EtcdOpFunc

Jump to

Keyboard shortcuts

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