Package clientv3
Overview ▹
▹ Example
Index ▹
Constants
const ( PermRead = authpb.READ PermWrite = authpb.WRITE PermReadWrite = authpb.READWRITE )
const ( EventTypeDelete = mvccpb.DELETE EventTypePut = mvccpb.PUT )
Variables
var ( ErrNoAvailableEndpoints = errors.New("etcdclient: no available endpoints") ErrOldCluster = errors.New("etcdclient: old cluster version") )
ErrNoAddrAvilable is returned by Get() when the balancer does not have any active connection to endpoints at the time. This error is returned only when opts.BlockingWait is true.
var ErrNoAddrAvilable = grpc.Errorf(codes.Unavailable, "there is no address available")
func GetPrefixRangeEnd ¶
func GetPrefixRangeEnd(prefix string) string
GetPrefixRangeEnd gets the range end of the prefix. 'Get(foo, WithPrefix())' is equal to 'Get(foo, WithRange(GetPrefixRangeEnd(foo))'.
func RetryAuthClient ¶
func RetryAuthClient(c *Client) pb.AuthClient
RetryAuthClient implements a AuthClient that uses the client's FailFast retry policy.
func RetryClusterClient ¶
func RetryClusterClient(c *Client) pb.ClusterClient
RetryClusterClient implements a ClusterClient that uses the client's FailFast retry policy.
func RetryKVClient ¶
func RetryKVClient(c *Client) pb.KVClient
RetryKVClient implements a KVClient that uses the client's FailFast retry policy.
func RetryLeaseClient ¶
func RetryLeaseClient(c *Client) pb.LeaseClient
RetryLeaseClient implements a LeaseClient that uses the client's FailFast retry policy.
func SetLogger ¶
func SetLogger(l Logger)
SetLogger sets client-side Logger. By default, logs are disabled.
func WithFirstCreate ¶
func WithFirstCreate() []OpOption
WithFirstCreate gets the key with the oldest creation revision in the request range.
func WithFirstKey ¶
func WithFirstKey() []OpOption
WithFirstKey gets the lexically first key in the request range.
func WithFirstRev ¶
func WithFirstRev() []OpOption
WithFirstRev gets the key with the oldest modification revision in the request range.
func WithLastCreate ¶
func WithLastCreate() []OpOption
WithLastCreate gets the key with the latest creation revision in the request range.
func WithLastKey ¶
func WithLastKey() []OpOption
WithLastKey gets the lexically last key in the request range.
func WithLastRev ¶
func WithLastRev() []OpOption
WithLastRev gets the key with the latest modification revision in the request range.
func WithRequireLeader ¶
func WithRequireLeader(ctx context.Context) context.Context
WithRequireLeader requires client requests to only succeed when the cluster has a leader.
type AlarmMember ¶
type AlarmMember pb.AlarmMember
type AlarmResponse ¶
type AlarmResponse pb.AlarmResponse
type Auth ¶
type Auth interface { // AuthEnable enables auth of an etcd cluster. AuthEnable(ctx context.Context) (*AuthEnableResponse, error) // AuthDisable disables auth of an etcd cluster. AuthDisable(ctx context.Context) (*AuthDisableResponse, error) // UserAdd adds a new user to an etcd cluster. UserAdd(ctx context.Context, name string, password string) (*AuthUserAddResponse, error) // UserDelete deletes a user from an etcd cluster. UserDelete(ctx context.Context, name string) (*AuthUserDeleteResponse, error) // UserChangePassword changes a password of a user. UserChangePassword(ctx context.Context, name string, password string) (*AuthUserChangePasswordResponse, error) // UserGrantRole grants a role to a user. UserGrantRole(ctx context.Context, user string, role string) (*AuthUserGrantRoleResponse, error) // UserGet gets a detailed information of a user. UserGet(ctx context.Context, name string) (*AuthUserGetResponse, error) // UserList gets a list of all users. UserList(ctx context.Context) (*AuthUserListResponse, error) // UserRevokeRole revokes a role of a user. UserRevokeRole(ctx context.Context, name string, role string) (*AuthUserRevokeRoleResponse, error) // RoleAdd adds a new role to an etcd cluster. RoleAdd(ctx context.Context, name string) (*AuthRoleAddResponse, error) // RoleGrantPermission grants a permission to a role. RoleGrantPermission(ctx context.Context, name string, key, rangeEnd string, permType PermissionType) (*AuthRoleGrantPermissionResponse, error) // RoleGet gets a detailed information of a role. RoleGet(ctx context.Context, role string) (*AuthRoleGetResponse, error) // RoleList gets a list of all roles. RoleList(ctx context.Context) (*AuthRoleListResponse, error) // RoleRevokePermission revokes a permission from a role. RoleRevokePermission(ctx context.Context, role string, key, rangeEnd string) (*AuthRoleRevokePermissionResponse, error) // RoleDelete deletes a role. RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error) }
▹ Example
func NewAuth ¶
func NewAuth(c *Client) Auth
type AuthDisableResponse ¶
type AuthDisableResponse pb.AuthDisableResponse
type AuthEnableResponse ¶
type AuthEnableResponse pb.AuthEnableResponse
type AuthRoleAddResponse ¶
type AuthRoleAddResponse pb.AuthRoleAddResponse
type AuthRoleDeleteResponse ¶
type AuthRoleDeleteResponse pb.AuthRoleDeleteResponse
type AuthRoleGetResponse ¶
type AuthRoleGetResponse pb.AuthRoleGetResponse
type AuthRoleGrantPermissionResponse ¶
type AuthRoleGrantPermissionResponse pb.AuthRoleGrantPermissionResponse
type AuthRoleListResponse ¶
type AuthRoleListResponse pb.AuthRoleListResponse
type AuthRoleRevokePermissionResponse ¶
type AuthRoleRevokePermissionResponse pb.AuthRoleRevokePermissionResponse
type AuthUserAddResponse ¶
type AuthUserAddResponse pb.AuthUserAddResponse
type AuthUserChangePasswordResponse ¶
type AuthUserChangePasswordResponse pb.AuthUserChangePasswordResponse
type AuthUserDeleteResponse ¶
type AuthUserDeleteResponse pb.AuthUserDeleteResponse
type AuthUserGetResponse ¶
type AuthUserGetResponse pb.AuthUserGetResponse
type AuthUserGrantRoleResponse ¶
type AuthUserGrantRoleResponse pb.AuthUserGrantRoleResponse
type AuthUserListResponse ¶
type AuthUserListResponse pb.AuthUserListResponse
type AuthUserRevokeRoleResponse ¶
type AuthUserRevokeRoleResponse pb.AuthUserRevokeRoleResponse
type AuthenticateResponse ¶
type AuthenticateResponse pb.AuthenticateResponse
type Client ¶
Client provides and manages an etcd v3 client session.
type Client struct { Cluster KV Lease Watcher Auth Maintenance // Username is a username for authentication Username string // Password is a password for authentication Password string // contains filtered or unexported fields }
▹ Example (Metrics)
func New ¶
func New(cfg Config) (*Client, error)
New creates a new etcdv3 client from a given configuration.
func NewCtxClient ¶
func NewCtxClient(ctx context.Context) *Client
NewCtxClient creates a client with a context but no underlying grpc connection. This is useful for embedded cases that override the service interface implementations and do not need connection management.
func NewFromURL ¶
func NewFromURL(url string) (*Client, error)
NewFromURL creates a new etcdv3 client from a URL.
func (*Client) ActiveConnection ¶
func (c *Client) ActiveConnection() *grpc.ClientConn
ActiveConnection returns the current in-use connection
func (*Client) Close ¶
func (c *Client) Close() error
Close shuts down the client's etcd connections.
func (*Client) Ctx ¶
func (c *Client) Ctx() context.Context
Ctx is a context for "out of band" messages (e.g., for sending "clean up" message when another context is canceled). It is canceled on client Close().
func (*Client) Dial ¶
func (c *Client) Dial(endpoint string) (*grpc.ClientConn, error)
Dial connects to a single endpoint using the client's config.
func (*Client) Endpoints ¶
func (c *Client) Endpoints() (eps []string)
Endpoints lists the registered endpoints for the client.
func (*Client) SetEndpoints ¶
func (c *Client) SetEndpoints(eps ...string)
SetEndpoints updates client's endpoints.
func (*Client) Sync ¶
func (c *Client) Sync(ctx context.Context) error
Sync synchronizes client's endpoints with the known endpoints from the etcd membership.
type Cluster ¶
type Cluster interface { // MemberList lists the current cluster membership. MemberList(ctx context.Context) (*MemberListResponse, error) // MemberAdd adds a new member into the cluster. MemberAdd(ctx context.Context, peerAddrs []string) (*MemberAddResponse, error) // MemberRemove removes an existing member from the cluster. MemberRemove(ctx context.Context, id uint64) (*MemberRemoveResponse, error) // MemberUpdate updates the peer addresses of the member. MemberUpdate(ctx context.Context, id uint64, peerAddrs []string) (*MemberUpdateResponse, error) }
▹ Example (MemberAdd)
▹ Example (MemberList)
▹ Example (MemberRemove)
▹ Example (MemberUpdate)
func NewCluster ¶
func NewCluster(c *Client) Cluster
func NewClusterFromClusterClient ¶
func NewClusterFromClusterClient(remote pb.ClusterClient) Cluster
type Cmp ¶
type Cmp pb.Compare
func Compare ¶
func Compare(cmp Cmp, result string, v interface{}) Cmp
func CreateRevision ¶
func CreateRevision(key string) Cmp
func ModRevision ¶
func ModRevision(key string) Cmp
func Value ¶
func Value(key string) Cmp
func Version ¶
func Version(key string) Cmp
func (*Cmp) KeyBytes ¶
func (cmp *Cmp) KeyBytes() []byte
KeyBytes returns the byte slice holding with the comparison key.
func (*Cmp) ValueBytes ¶
func (cmp *Cmp) ValueBytes() []byte
ValueBytes returns the byte slice holding the comparison value, if any.
func (*Cmp) WithKeyBytes ¶
func (cmp *Cmp) WithKeyBytes(key []byte)
WithKeyBytes sets the byte slice for the comparison key.
func (*Cmp) WithValueBytes ¶
func (cmp *Cmp) WithValueBytes(v []byte)
WithValueBytes sets the byte slice for the comparison's value.
type CompactOp ¶
CompactOp represents a compact operation.
type CompactOp struct {
// contains filtered or unexported fields
}
func OpCompact ¶
func OpCompact(rev int64, opts ...CompactOption) CompactOp
OpCompact wraps slice CompactOption to create a CompactOp.
type CompactOption ¶
CompactOption configures compact operation.
type CompactOption func(*CompactOp)
func WithCompactPhysical ¶
func WithCompactPhysical() CompactOption
WithCompactPhysical makes compact RPC call wait until the compaction is physically applied to the local database such that compacted entries are totally removed from the backend database.
type CompactResponse ¶
type CompactResponse pb.CompactionResponse
type CompareResult ¶
type CompareResult int
type CompareTarget ¶
type CompareTarget int
const ( CompareVersion CompareTarget = iota CompareCreated CompareModified CompareValue )
type Config ¶
type Config struct { // Endpoints is a list of URLs. Endpoints []string `json:"endpoints"` // AutoSyncInterval is the interval to update endpoints with its latest members. // 0 disables auto-sync. By default auto-sync is disabled. AutoSyncInterval time.Duration `json:"auto-sync-interval"` // DialTimeout is the timeout for failing to establish a connection. DialTimeout time.Duration `json:"dial-timeout"` // TLS holds the client secure credentials, if any. TLS *tls.Config // Username is a username for authentication. Username string `json:"username"` // Password is a password for authentication. Password string `json:"password"` // RejectOldCluster when set will refuse to create a client against an outdated cluster. RejectOldCluster bool `json:"reject-old-cluster"` // DialOptions is a list of dial options for the grpc client (e.g., for interceptors). DialOptions []grpc.DialOption // Context is the default client context; it can be used to cancel grpc dial out and // other operations that do not have an explicit context. Context context.Context }
▹ Example (WithTLS)
type DefragmentResponse ¶
type DefragmentResponse pb.DefragmentResponse
type DeleteResponse ¶
type DeleteResponse pb.DeleteRangeResponse
type ErrKeepAliveHalted ¶
ErrKeepAliveHalted is returned if client keep alive loop halts with an unexpected error.
This usually means that automatic lease renewal via KeepAlive is broken, but KeepAliveOnce will still work as expected.
type ErrKeepAliveHalted struct { Reason error }
func (ErrKeepAliveHalted) Error ¶
func (e ErrKeepAliveHalted) Error() string
type Event ¶
type Event mvccpb.Event
func (*Event) IsCreate ¶
func (e *Event) IsCreate() bool
IsCreate returns true if the event tells that the key is newly created.
func (*Event) IsModify ¶
func (e *Event) IsModify() bool
IsModify returns true if the event tells that a new value is put on existing key.
type GetResponse ¶
type GetResponse pb.RangeResponse
type KV ¶
type KV interface { // Put puts a key-value pair into etcd. // Note that key,value can be plain bytes array and string is // an immutable representation of that bytes array. // To get a string of bytes, do string([]byte{0x10, 0x20}). Put(ctx context.Context, key, val string, opts ...OpOption) (*PutResponse, error) // Get retrieves keys. // By default, Get will return the value for "key", if any. // When passed WithRange(end), Get will return the keys in the range [key, end). // When passed WithFromKey(), Get returns keys greater than or equal to key. // When passed WithRev(rev) with rev > 0, Get retrieves keys at the given revision; // if the required revision is compacted, the request will fail with ErrCompacted . // When passed WithLimit(limit), the number of returned keys is bounded by limit. // When passed WithSort(), the keys will be sorted. Get(ctx context.Context, key string, opts ...OpOption) (*GetResponse, error) // Delete deletes a key, or optionally using WithRange(end), [key, end). Delete(ctx context.Context, key string, opts ...OpOption) (*DeleteResponse, error) // Compact compacts etcd KV history before the given rev. Compact(ctx context.Context, rev int64, opts ...CompactOption) (*CompactResponse, error) // Do applies a single Op on KV without a transaction. // Do is useful when creating arbitrary operations to be issued at a // later time; the user can range over the operations, calling Do to // execute them. Get/Put/Delete, on the other hand, are best suited // for when the operation should be issued at the time of declaration. Do(ctx context.Context, op Op) (OpResponse, error) // Txn creates a transaction. Txn(ctx context.Context) Txn }
▹ Example (Compact)
▹ Example (Delete)
▹ Example (Do)
▹ Example (Get)
▹ Example (GetSortedPrefix)
▹ Example (GetWithRev)
▹ Example (Put)
▹ Example (PutErrorHandling)
▹ Example (Txn)
func NewKV ¶
func NewKV(c *Client) KV
func NewKVFromKVClient ¶
func NewKVFromKVClient(remote pb.KVClient) KV
type Lease ¶
type Lease interface { // Grant creates a new lease. Grant(ctx context.Context, ttl int64) (*LeaseGrantResponse, error) // Revoke revokes the given lease. Revoke(ctx context.Context, id LeaseID) (*LeaseRevokeResponse, error) // TimeToLive retrieves the lease information of the given lease ID. TimeToLive(ctx context.Context, id LeaseID, opts ...LeaseOption) (*LeaseTimeToLiveResponse, error) // KeepAlive keeps the given lease alive forever. KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAliveResponse, error) // KeepAliveOnce renews the lease once. In most of the cases, Keepalive // should be used instead of KeepAliveOnce. KeepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAliveResponse, error) // Close releases all resources Lease keeps for efficient communication // with the etcd server. Close() error }
▹ Example (Grant)
▹ Example (KeepAlive)
▹ Example (KeepAliveOnce)
▹ Example (Revoke)
func NewLease ¶
func NewLease(c *Client) Lease
func NewLeaseFromLeaseClient ¶
func NewLeaseFromLeaseClient(remote pb.LeaseClient, keepAliveTimeout time.Duration) Lease
type LeaseGrantResponse ¶
LeaseGrantResponse is used to convert the protobuf grant response.
type LeaseGrantResponse struct { *pb.ResponseHeader ID LeaseID TTL int64 Error string }
type LeaseID ¶
type LeaseID int64
const (
// NoLease is a lease ID for the absence of a lease.
NoLease LeaseID = 0
)
type LeaseKeepAliveResponse ¶
LeaseKeepAliveResponse is used to convert the protobuf keepalive response.
type LeaseKeepAliveResponse struct { *pb.ResponseHeader ID LeaseID TTL int64 }
type LeaseOp ¶
LeaseOp represents an Operation that lease can execute.
type LeaseOp struct {
// contains filtered or unexported fields
}
type LeaseOption ¶
LeaseOption configures lease operations.
type LeaseOption func(*LeaseOp)
func WithAttachedKeys ¶
func WithAttachedKeys() LeaseOption
WithAttachedKeys requests lease timetolive API to return attached keys of given lease ID.
type LeaseRevokeResponse ¶
type LeaseRevokeResponse pb.LeaseRevokeResponse
type LeaseTimeToLiveResponse ¶
LeaseTimeToLiveResponse is used to convert the protobuf lease timetolive response.
type LeaseTimeToLiveResponse struct { *pb.ResponseHeader ID LeaseID `json:"id"` // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds. TTL int64 `json:"ttl"` // GrantedTTL is the initial granted time in seconds upon lease creation/renewal. GrantedTTL int64 `json:"granted-ttl"` // Keys is the list of keys attached to this lease. Keys [][]byte `json:"keys"` }
type Logger ¶
Logger is the logger used by client library. It implements grpclog.Logger interface.
type Logger grpclog.Logger
func GetLogger ¶
func GetLogger() Logger
GetLogger returns the current logger.
type Maintenance ¶
type Maintenance interface { // AlarmList gets all active alarms. AlarmList(ctx context.Context) (*AlarmResponse, error) // AlarmDisarm disarms a given alarm. AlarmDisarm(ctx context.Context, m *AlarmMember) (*AlarmResponse, error) // Defragment defragments storage backend of the etcd member with given endpoint. // Defragment is only needed when deleting a large number of keys and want to reclaim // the resources. // Defragment is an expensive operation. User should avoid defragmenting multiple members // at the same time. // To defragment multiple members in the cluster, user need to call defragment multiple // times with different endpoints. Defragment(ctx context.Context, endpoint string) (*DefragmentResponse, error) // Status gets the status of the endpoint. Status(ctx context.Context, endpoint string) (*StatusResponse, error) // Snapshot provides a reader for a snapshot of a backend. Snapshot(ctx context.Context) (io.ReadCloser, error) }
▹ Example (Defragment)
▹ Example (Status)
func NewMaintenance ¶
func NewMaintenance(c *Client) Maintenance
func NewMaintenanceFromMaintenanceClient ¶
func NewMaintenanceFromMaintenanceClient(remote pb.MaintenanceClient) Maintenance
type Member ¶
type Member pb.Member
type MemberAddResponse ¶
type MemberAddResponse pb.MemberAddResponse
type MemberListResponse ¶
type MemberListResponse pb.MemberListResponse
type MemberRemoveResponse ¶
type MemberRemoveResponse pb.MemberRemoveResponse
type MemberUpdateResponse ¶
type MemberUpdateResponse pb.MemberUpdateResponse
type Op ¶
Op represents an Operation that kv can execute.
type Op struct {
// contains filtered or unexported fields
}
func OpDelete ¶
func OpDelete(key string, opts ...OpOption) Op
func OpGet ¶
func OpGet(key string, opts ...OpOption) Op
func OpPut ¶
func OpPut(key, val string, opts ...OpOption) Op
func (Op) KeyBytes ¶
func (op Op) KeyBytes() []byte
KeyBytes returns the byte slice holding the Op's key.
func (Op) RangeBytes ¶
func (op Op) RangeBytes() []byte
RangeBytes returns the byte slice holding with the Op's range end, if any.
func (Op) ValueBytes ¶
func (op Op) ValueBytes() []byte
ValueBytes returns the byte slice holding the Op's value, if any.
func (*Op) WithKeyBytes ¶
func (op *Op) WithKeyBytes(key []byte)
WithKeyBytes sets the byte slice for the Op's key.
func (*Op) WithRangeBytes ¶
func (op *Op) WithRangeBytes(end []byte)
WithRangeBytes sets the byte slice for the Op's range end.
func (*Op) WithValueBytes ¶
func (op *Op) WithValueBytes(v []byte)
WithValueBytes sets the byte slice for the Op's value.
type OpOption ¶
OpOption configures Operations like Get, Put, Delete.
type OpOption func(*Op)
func WithCountOnly ¶
func WithCountOnly() OpOption
WithCountOnly makes the 'Get' request return only the count of keys.
func WithCreatedNotify ¶
func WithCreatedNotify() OpOption
WithCreatedNotify makes watch server sends the created event.
func WithFilterDelete ¶
func WithFilterDelete() OpOption
WithFilterDelete discards DELETE events from the watcher.
func WithFilterPut ¶
func WithFilterPut() OpOption
WithFilterPut discards PUT events from the watcher.
func WithFromKey ¶
func WithFromKey() OpOption
WithFromKey specifies the range of 'Get', 'Delete', 'Watch' requests to be equal or greater than the key in the argument.
func WithIgnoreLease ¶
func WithIgnoreLease() OpOption
WithIgnoreLease updates the key using its current lease. Empty lease should be passed when ignore_lease is set. Returns an error if the key does not exist.
func WithIgnoreValue ¶
func WithIgnoreValue() OpOption
WithIgnoreValue updates the key using its current value. Empty value should be passed when ignore_value is set. Returns an error if the key does not exist.
func WithKeysOnly ¶
func WithKeysOnly() OpOption
WithKeysOnly makes the 'Get' request return only the keys and the corresponding values will be omitted.
func WithLease ¶
func WithLease(leaseID LeaseID) OpOption
WithLease attaches a lease ID to a key in 'Put' request.
func WithLimit ¶
func WithLimit(n int64) OpOption
WithLimit limits the number of results to return from 'Get' request. If WithLimit is given a 0 limit, it is treated as no limit.
func WithMaxCreateRev ¶
func WithMaxCreateRev(rev int64) OpOption
WithMaxCreateRev filters out keys for Get with creation revisions greater than the given revision.
func WithMaxModRev ¶
func WithMaxModRev(rev int64) OpOption
WithMaxModRev filters out keys for Get with modification revisions greater than the given revision.
func WithMinCreateRev ¶
func WithMinCreateRev(rev int64) OpOption
WithMinCreateRev filters out keys for Get with creation revisions less than the given revision.
func WithMinModRev ¶
func WithMinModRev(rev int64) OpOption
WithMinModRev filters out keys for Get with modification revisions less than the given revision.
func WithPrefix ¶
func WithPrefix() OpOption
WithPrefix enables 'Get', 'Delete', or 'Watch' requests to operate on the keys with matching prefix. For example, 'Get(foo, WithPrefix())' can return 'foo1', 'foo2', and so on.
func WithPrevKV ¶
func WithPrevKV() OpOption
WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted, nothing will be returned.
func WithProgressNotify ¶
func WithProgressNotify() OpOption
WithProgressNotify makes watch server send periodic progress updates every 10 minutes when there is no incoming events. Progress updates have zero events in WatchResponse.
func WithRange ¶
func WithRange(endKey string) OpOption
WithRange specifies the range of 'Get', 'Delete', 'Watch' requests. For example, 'Get' requests with 'WithRange(end)' returns the keys in the range [key, end). endKey must be lexicographically greater than start key.
func WithRev ¶
func WithRev(rev int64) OpOption
WithRev specifies the store revision for 'Get' request. Or the start revision of 'Watch' request.
func WithSerializable ¶
func WithSerializable() OpOption
WithSerializable makes 'Get' request serializable. By default, it's linearizable. Serializable requests are better for lower latency requirement.
func WithSort ¶
func WithSort(target SortTarget, order SortOrder) OpOption
WithSort specifies the ordering in 'Get' request. It requires 'WithRange' and/or 'WithPrefix' to be specified too. 'target' specifies the target to sort by: key, version, revisions, value. 'order' can be either 'SortNone', 'SortAscend', 'SortDescend'.
type OpResponse ¶
type OpResponse struct {
// contains filtered or unexported fields
}
func (OpResponse) Del ¶
func (op OpResponse) Del() *DeleteResponse
func (OpResponse) Get ¶
func (op OpResponse) Get() *GetResponse
func (OpResponse) Put ¶
func (op OpResponse) Put() *PutResponse
type Permission ¶
type Permission authpb.Permission
type PermissionType ¶
type PermissionType authpb.Permission_Type
func StrToPermissionType ¶
func StrToPermissionType(s string) (PermissionType, error)
type PutResponse ¶
type PutResponse pb.PutResponse
type SortOption ¶
type SortOption struct { Target SortTarget Order SortOrder }
type SortOrder ¶
type SortOrder int
const ( SortNone SortOrder = iota SortAscend SortDescend )
type SortTarget ¶
type SortTarget int
const ( SortByKey SortTarget = iota SortByVersion SortByCreateRevision SortByModRevision SortByValue )
type StatusResponse ¶
type StatusResponse pb.StatusResponse
type Txn ¶
Txn is the interface that wraps mini-transactions.
Tx.If( Compare(Value(k1), ">", v1), Compare(Version(k1), "=", 2) ).Then( OpPut(k2,v2), OpPut(k3,v3) ).Else( OpPut(k4,v4), OpPut(k5,v5) ).Commit()
type Txn interface { // If takes a list of comparison. If all comparisons passed in succeed, // the operations passed into Then() will be executed. Or the operations // passed into Else() will be executed. If(cs ...Cmp) Txn // Then takes a list of operations. The Ops list will be executed, if the // comparisons passed in If() succeed. Then(ops ...Op) Txn // Else takes a list of operations. The Ops list will be executed, if the // comparisons passed in If() fail. Else(ops ...Op) Txn // Commit tries to commit the transaction. Commit() (*TxnResponse, error) }
type TxnResponse ¶
type TxnResponse pb.TxnResponse
type WatchChan ¶
type WatchChan <-chan WatchResponse
type WatchResponse ¶
type WatchResponse struct { Header pb.ResponseHeader Events []*Event // CompactRevision is the minimum revision the watcher may receive. CompactRevision int64 // Canceled is used to indicate watch failure. // If the watch failed and the stream was about to close, before the channel is closed, // the channel sends a final response that has Canceled set to true with a non-nil Err(). Canceled bool // Created is used to indicate the creation of the watcher. Created bool // contains filtered or unexported fields }
func (*WatchResponse) Err ¶
func (wr *WatchResponse) Err() error
Err is the error value if this WatchResponse holds an error.
func (*WatchResponse) IsProgressNotify ¶
func (wr *WatchResponse) IsProgressNotify() bool
IsProgressNotify returns true if the WatchResponse is progress notification.
type Watcher ¶
type Watcher interface { // Watch watches on a key or prefix. The watched events will be returned // through the returned channel. // If the watch is slow or the required rev is compacted, the watch request // might be canceled from the server-side and the chan will be closed. // 'opts' can be: 'WithRev' and/or 'WithPrefix'. Watch(ctx context.Context, key string, opts ...OpOption) WatchChan // Close closes the watcher and cancels all watch requests. Close() error }
▹ Example (Watch)
▹ Example (WatchWithPrefix)
▹ Example (WatchWithProgressNotify)
▹ Example (WatchWithRange)
func NewWatchFromWatchClient ¶
func NewWatchFromWatchClient(wc pb.WatchClient) Watcher
func NewWatcher ¶
func NewWatcher(c *Client) Watcher
Subdirectories
Name | Synopsis |
---|---|
.. | |
clientv3util | Package clientv3util contains utility functions derived from clientv3. |
concurrency | Package concurrency implements concurrency operations on top of etcd such as distributed locks, barriers, and elections. |
integration | Package integration implements tests built upon embedded etcd, and focuses on correctness of etcd client. |
mirror | Package mirror implements etcd mirroring operations. |
namespace | Package namespace is a clientv3 wrapper that translates all keys to begin with a given prefix. |
naming | Package naming provides an etcd-backed gRPC resolver for discovering gRPC services. |
yaml | Package yaml handles yaml-formatted clientv3 configuration data. |