Documentation ¶
Index ¶
- Constants
- func AddMember(client *clientv3.Client, peerAddrs []string) (*clientv3.MemberAddResponse, error)
- func CreateClient(endpoints []string, tlsCfg *tls.Config) (*clientv3.Client, error)
- func DoTxnWithRepeatable(cli *clientv3.Client, opFunc EtcdOpFunc) (*clientv3.TxnResponse, int64, error)
- func IsLimitedRetryableError(err error) bool
- func IsRetryableError(err error) bool
- func ListMembers(client *clientv3.Client) (*clientv3.MemberListResponse, error)
- func RemoveMember(client *clientv3.Client, id uint64) (*clientv3.MemberRemoveResponse, error)
- type EtcdOpFunc
Constants ¶
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 CreateClient ¶
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 ¶
IsLimitedRetryableError check whether error is retryable error for etcd to build again in a limited number of times.
func IsRetryableError ¶
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 ¶
RemoveMember removes an etcd member by the given id.
Types ¶
type EtcdOpFunc ¶
func FullOpFunc ¶
func FullOpFunc(cmps []clientv3.Cmp, opsThen, opsElse []clientv3.Op) EtcdOpFunc
func ThenOpFunc ¶
func ThenOpFunc(ops ...clientv3.Op) EtcdOpFunc