etcdclient.go 909 B

1234567891011121314151617181920212223
  1. //go:generate mockgen -package internal -destination etcdclient_mock.go -source etcdclient.go EtcdClient
  2. package internal
  3. import (
  4. "context"
  5. "go.etcd.io/etcd/clientv3"
  6. "google.golang.org/grpc"
  7. )
  8. // EtcdClient interface represents an etcd client.
  9. type EtcdClient interface {
  10. ActiveConnection() *grpc.ClientConn
  11. Close() error
  12. Ctx() context.Context
  13. Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
  14. Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error)
  15. KeepAlive(ctx context.Context, id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error)
  16. Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
  17. Revoke(ctx context.Context, id clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error)
  18. Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
  19. }