func (conn *Conn) GetLeaseIDByKey(key string) (clientv3.LeaseID, error) {
	leaseID, ok := conn.KeyLeaseIDMap.Load(key)
	if !ok {
		return clientv3.NoLease, nil
	}
	return leaseID.(clientv3.LeaseID), nil
}
GetLeaseIDByKey returns lease response by mutex key name which was maintained when successfully get the mutex
package etcd
import (
	"context"
	"errors"
	"fmt"
	"sync"
	"time"
	clientv3 "go.etcd.io/etcd/client/v3"
)
const (
	DefaultConnectTimeOut    = 10 * time.Second
	DefaultMutexLeaseSeconds = 3600
	MaxTTL                   = 3600 * 24
	MinimumTTL               = 2
	ZeroRevision             = 0
)
type Conn struct {
	Endpoints     []string
	KeyLeaseIDMap sync.Map
	clientv3.Config
	clientv3.Client
	clientv3.Lease
}
func NewEtcdConn(endpoints []string) (*Conn, error) {
	cfg := clientv3.Config{
		Endpoints:   endpoints,
		DialTimeout: DefaultConnectTimeOut,
	}
	client, err := clientv3.New(cfg)
	if err != nil {
		return nil, err
	}
	return &Conn{
		Endpoints: endpoints,
		Config:    cfg,
		Client:    *client,
		Lease:     clientv3.NewLease(client),
	}, nil
}
func NewEtcdConnWithConnectTimeout(endpoints []string, timeout time.Duration) (*Conn, error) {
	cfg := clientv3.Config{
		Endpoints:   endpoints,
		DialTimeout: timeout,
	}
	client, err := clientv3.New(cfg)
	if err != nil {
		return nil, err
	}
	return &Conn{
		Endpoints: endpoints,
		Config:    cfg,
		Client:    *client,
		Lease:     clientv3.NewLease(client),
	}, nil
}
func (conn *Conn) Close() error {
	return conn.Client.Close()
}