func (r *Registry) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) {
	if r.client == nil {
		return nil, errors.New("registry etcd client is nil")
	}
	key = r.prefix + key + r.postfix
	return r.client.Put(ctx, key, val, r.op(opts)...)
}
Put inwrap for clientv3.Put of etcd
package service
import (
	"context"
	"errors"
	"fmt"
	"strings"
	"time"
	"github.com/axfor/bast/conf"
	"github.com/axfor/bast/logs"
	"go.etcd.io/etcd/clientv3"
)
type Registry struct {
	client       *clientv3.Client
	leaseID      clientv3.LeaseID
	prefix       string
	postfix      string
	stop         chan struct{}
	keepAliveing bool
}
func NewRegistry(c *conf.RegistryConf) (*Registry, error) {
	if c.DialTimeout <= 0 {
		c.DialTimeout = 10
	}
	if c.TTL <= 0 {
		c.TTL = 5
	}
	cli, err := clientv3.New(clientv3.Config{
		Endpoints:   strings.Split(c.Endpoints, ","),
		DialTimeout: time.Duration(c.DialTimeout) * time.Second,
	})
	if err != nil {
		return nil, err
	}
	resp, err := cli.Grant(cli.Ctx(), c.TTL)
	if err != nil {
		return nil, err
	}
	r := &Registry{
		client:  cli,
		leaseID: resp.ID,
		prefix:  c.Prefix,
		postfix: fmt.Sprintf(".%d", resp.ID),
	}
	return r, nil
}