You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/core/discov/internal/etcdclient.go

24 lines
919 B
Go

4 years ago
//go:generate mockgen -package internal -destination etcdclient_mock.go -source etcdclient.go EtcdClient
4 years ago
package internal
import (
"context"
clientv3 "go.etcd.io/etcd/client/v3"
4 years ago
"google.golang.org/grpc"
)
// EtcdClient interface represents an etcd client.
4 years ago
type EtcdClient interface {
ActiveConnection() *grpc.ClientConn
Close() error
Ctx() context.Context
Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error)
KeepAlive(ctx context.Context, id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error)
Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
Revoke(ctx context.Context, id clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error)
Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
}