Documentation ¶
Index ¶
- Constants
- func AddEtcdMember(client *clientv3.Client, urls []string) (*clientv3.MemberAddResponse, error)
- func CheckClusterID(localClusterID types.ID, um types.URLsMap, tlsConfig *tls.Config) error
- func CreateClients(tlsConfig *tls.Config, acUrls url.URL) (*clientv3.Client, *http.Client, error)
- func CreateClientsWithMultiEndpoint(tlsConfig *tls.Config, acUrls []url.URL) (*clientv3.Client, *http.Client, error)
- func CreateEtcdClient(tlsConfig *tls.Config, acURL url.URL) (*clientv3.Client, error)
- func EtcdKVGet(c *clientv3.Client, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
- func EtcdKVPutWithTTL(ctx context.Context, c *clientv3.Client, key string, value string, ...) (*clientv3.PutResponse, error)
- func GetClusterID(c *clientv3.Client, key string) (clusterID uint64, err error)
- func GetProtoMsgWithModRev(c *clientv3.Client, key string, msg proto.Message, opts ...clientv3.OpOption) (bool, int64, error)
- func GetValue(c *clientv3.Client, key string, opts ...clientv3.OpOption) ([]byte, error)
- func InitClusterID(c *clientv3.Client, key string) (clusterID uint64, err error)
- func InitOrGetClusterID(c *clientv3.Client, key string) (uint64, error)
- func ListEtcdMembers(client *clientv3.Client) (*clientv3.MemberListResponse, error)
- func NewTestSingleConfig(t *testing.T) *embed.Config
- func RemoveEtcdMember(client *clientv3.Client, id uint64) (*clientv3.MemberRemoveResponse, error)
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 // DefaultSlowRequestTime 1s for the threshold for normal request, for those // longer then 1s, they are considered as slow requests. DefaultSlowRequestTime = time.Second )
Variables ¶
This section is empty.
Functions ¶
func AddEtcdMember ¶
AddEtcdMember adds an etcd member.
func CheckClusterID ¶
CheckClusterID checks etcd cluster ID, returns an error if mismatch. This function will never block even quorum is not satisfied.
func CreateClients ¶
CreateClients creates etcd v3 client and http client.
func CreateClientsWithMultiEndpoint ¶
func CreateClientsWithMultiEndpoint(tlsConfig *tls.Config, acUrls []url.URL) (*clientv3.Client, *http.Client, error)
CreateClientsWithMultiEndpoint creates etcd v3 client and http client.
func CreateEtcdClient ¶
CreateEtcdClient creates etcd v3 client. Note: it will be used by legacy pd-server, and only connect to leader only.
func EtcdKVGet ¶
func EtcdKVGet(c *clientv3.Client, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
EtcdKVGet returns the etcd GetResponse by given key or key prefix
func EtcdKVPutWithTTL ¶
func EtcdKVPutWithTTL(ctx context.Context, c *clientv3.Client, key string, value string, ttlSeconds int64) (*clientv3.PutResponse, error)
EtcdKVPutWithTTL put (key, value) into etcd with a ttl of ttlSeconds
func GetClusterID ¶
GetClusterID gets the cluster ID for the given key.
func GetProtoMsgWithModRev ¶
func GetProtoMsgWithModRev(c *clientv3.Client, key string, msg proto.Message, opts ...clientv3.OpOption) (bool, int64, error)
GetProtoMsgWithModRev returns boolean to indicate whether the key exists or not.
func InitClusterID ¶
InitClusterID creates a cluster ID for the given key if it hasn't existed. This function assumes the cluster ID has already existed and always use a cheaper read to retrieve it; if it doesn't exist, invoke the more expensive operation InitOrGetClusterID().
func InitOrGetClusterID ¶
InitOrGetClusterID creates a cluster ID for the given key with a CAS operation, if the cluster ID doesn't exist.
func ListEtcdMembers ¶
func ListEtcdMembers(client *clientv3.Client) (*clientv3.MemberListResponse, error)
ListEtcdMembers returns a list of internal etcd members.
func NewTestSingleConfig ¶
NewTestSingleConfig is used to create a etcd config for the unit test purpose.
func RemoveEtcdMember ¶
RemoveEtcdMember removes a member by the given id.
Types ¶
This section is empty.