github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/store/etcdv3/meta/meta.go (about) 1 package meta 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/projecteru2/core/lock" 8 9 "go.etcd.io/etcd/api/v3/mvccpb" 10 clientv3 "go.etcd.io/etcd/client/v3" 11 ) 12 13 // KV . 14 type KV interface { 15 Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error) 16 BindStatus(ctx context.Context, entityKey, statusKey, statusValue string, ttl int64) error 17 18 Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) 19 GetOne(ctx context.Context, key string, opts ...clientv3.OpOption) (*mvccpb.KeyValue, error) 20 GetMulti(ctx context.Context, keys []string, opts ...clientv3.OpOption) (kvs []*mvccpb.KeyValue, err error) 21 Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan 22 23 Create(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) 24 Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) 25 Update(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) 26 Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error) 27 28 BatchCreateAndDecr(ctx context.Context, data map[string]string, decrKey string) error 29 30 BatchCreate(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) 31 BatchUpdate(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) 32 BatchDelete(ctx context.Context, keys []string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) 33 BatchPut(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) 34 35 StartEphemeral(ctx context.Context, path string, heartbeat time.Duration) (<-chan struct{}, func(), error) 36 CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error) 37 }