Documentation ¶
Overview ¶
etcd package is the [ETCD](https://github.com/coreos/etcd) client v3 mirror. Copyright 2018 HenryLee. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func EasyNew(etcdConfig EasyConfig) (*clientv3.Client, error)
- type Client
- type CompactResponse
- type Config
- type DeleteResponse
- type EasyConfig
- type GetResponse
- type LeaseGrantResponse
- type LeaseID
- type LeaseKeepAliveResponse
- type LeaseStatus
- type LeaseTimeToLiveResponse
- type Mutex
- type OpOption
- type PutResponse
- type Session
- type SessionOption
- type SortOption
- type SortOrder
- type SortTarget
- type TxnResponse
Constants ¶
const ( EventTypePut = clientv3.EventTypePut EventTypeDelete = clientv3.EventTypeDelete )
Event types
const ( SortNone SortOrder = clientv3.SortNone SortAscend = clientv3.SortAscend SortDescend = clientv3.SortDescend )
SortOrder types
const ( SortByKey SortTarget = clientv3.SortByKey SortByVersion = clientv3.SortByVersion SortByCreateRevision = clientv3.SortByCreateRevision SortByModRevision = clientv3.SortByModRevision SortByValue = clientv3.SortByValue )
SortTarget types
Variables ¶
var NewClient = clientv3.New
NewClient creates a new etcdv3 client from a given configuration.
func New(cfg clientv3.Config) (*clientv3.Client, error)
var NewLocker = concurrency.NewLocker
NewLocker creates a sync.Locker backed by an etcd mutex.
func NewLocker(s *concurrency.Session, pfx string) sync.Locker
var NewMutex = concurrency.NewMutex
NewMutex creates a sync Locker interface with etcd. func NewMutex(s *concurrency.Session, pfx string) *Mutex
var NewSession = concurrency.NewSession
NewSession gets the leased session for a client.
func NewSession(client *v3.Client, opts ...concurrency.SessionOption) (*Session, error)
var WithAttachedKeys = clientv3.WithAttachedKeys
WithAttachedKeys makes TimeToLive list the keys attached to the given lease ID.
func WithAttachedKeys() LeaseOption
var WithCompactPhysical = clientv3.WithCompactPhysical
WithCompactPhysical makes Compact wait until all compacted entries are removed from the etcd server's storage.
func WithCompactPhysical() CompactOption
var WithCountOnly = clientv3.WithCountOnly
WithCountOnly makes the 'Get' request return only the count of keys.
func WithCountOnly() clientv3.OpOption
var WithCreatedNotify = clientv3.WithCreatedNotify
WithCreatedNotify makes watch server sends the created event.
func WithCreatedNotify() clientv3.OpOption
var WithFilterDelete = clientv3.WithFilterDelete
WithFilterDelete discards DELETE events from the watcher.
func WithFilterDelete() clientv3.OpOption
var WithFilterPut = clientv3.WithFilterPut
WithFilterPut discards PUT events from the watcher.
func WithFilterPut() clientv3.OpOption
var WithFirstCreate = clientv3.WithFirstCreate
WithFirstCreate gets the key with the oldest creation revision in the request range.
func WithFirstCreate() []clientv3.OpOption
var WithFirstKey = clientv3.WithFirstKey
WithFirstKey gets the lexically first key in the request range.
func WithFirstKey() []clientv3.OpOption
var WithFirstRev = clientv3.WithFirstRev
WithFirstRev gets the key with the oldest modification revision in the request range.
func WithFirstRev() []clientv3.OpOption
var WithFromKey = clientv3.WithFromKey
WithFromKey specifies the range of 'Get', 'Delete', 'Watch' requests to be equal or greater than the key in the argument.
func WithFromKey() clientv3.OpOption
var WithIgnoreLease = clientv3.WithIgnoreLease
This option can not be combined with WithLease. Returns an error if the key does not exist.
func WithIgnoreLease() clientv3.OpOption
var WithIgnoreValue = clientv3.WithIgnoreValue
This option can not be combined with non-empty values. Returns an error if the key does not exist.
func WithIgnoreValue() clientv3.OpOption
var WithKeysOnly = clientv3.WithKeysOnly
WithKeysOnly makes the 'Get' request return only the keys and the corresponding values will be omitted.
func WithKeysOnly() clientv3.OpOption
var WithLastCreate = clientv3.WithLastCreate
WithLastCreate gets the key with the latest creation revision in the request range.
func WithLastCreate() []clientv3.OpOption
var WithLastKey = clientv3.WithLastKey
WithLastKey gets the lexically last key in the request range.
func WithLastKey() []clientv3.OpOption
var WithLastRev = clientv3.WithLastRev
WithLastRev gets the key with the latest modification revision in the request range.
func WithLastRev
var WithLease = clientv3.WithLease
WithLease attaches a lease ID to a key in 'Put' request.
func WithLease(leaseID clientv3.LeaseID) clientv3.OpOption
var WithLimit = clientv3.WithLimit
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 WithLimit(n int64) clientv3.OpOption
var WithMaxCreateRev = clientv3.WithMaxCreateRev
WithMaxCreateRev filters out keys for Get with creation revisions greater than the given revision.
func WithMaxCreateRev(rev int64) clientv3.OpOption
var WithMaxModRev = clientv3.WithMaxModRev
WithMaxModRev filters out keys for Get with modification revisions greater than the given revision.
func WithMaxModRev(rev int64) clientv3.OpOption
var WithMinCreateRev = clientv3.WithMinCreateRev
WithMinCreateRev filters out keys for Get with creation revisions less than the given revision.
func WithMinCreateRev(rev int64) clientv3.OpOption
var WithMinModRev = clientv3.WithMinModRev
WithMinModRev filters out keys for Get with modification revisions less than the given revision.
func WithMinModRev(rev int64) clientv3.OpOption
var WithPrefix = clientv3.WithPrefix
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 WithPrefix() clientv3.OpOption
var WithPrevKV = clientv3.WithPrevKV
WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted, nothing will be returned.
func WithPrevKV() clientv3.OpOption
var WithProgressNotify = clientv3.WithProgressNotify
every 10 minutes when there is no incoming events. Progress updates have zero events in WatchResponse.
func WithProgressNotify() clientv3.OpOption
var WithRange = clientv3.WithRange
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 WithRange(endKey string) clientv3.OpOption
var WithRequireLeader = clientv3.WithRequireLeader
WithRequireLeader requires client requests to only succeed when the cluster has a leader.
func WithRequireLeader(ctx context.Context) context.Context
var WithRev = clientv3.WithRev
WithRev specifies the store revision for 'Get' request. Or the start revision of 'Watch' request.
func WithRev(rev int64) clientv3.OpOption
var WithSerializable = clientv3.WithSerializable
WithSerializable makes 'Get' request serializable. By default, it's linearizable. Serializable requests are better for lower latency requirement.
func WithSerializable() clientv3.OpOption
var WithSessionContext = concurrency.WithContext
WithSessionContext assigns a context to the session instead of defaulting to using the client context. This is useful for canceling NewSession and Close operations immediately without having to close the client. If the context is canceled before Close() completes, the session's lease will be abandoned and left to expire instead of being revoked.
func WithSessionContext(ctx context.Context) concurrency.SessionOption
var WithSessionLease = concurrency.WithLease
WithSessionLease specifies the existing leaseID to be used for the session. This is useful in process restart scenario, for example, to reclaim leadership from an election prior to restart.
func WithSessionLease(leaseID v3.LeaseID) concurrency.SessionOption
var WithSessionTTL = concurrency.WithTTL
WithSessionTTL configures the session's TTL in seconds. If TTL is <= 0, the default 60 seconds TTL will be used.
func WithSessionTTL(ttl int) concurrency.SessionOption
var WithSort = clientv3.WithSort
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'.
func WithSort(target SortTarget, order SortOrder) clientv3.OpOption
Functions ¶
Types ¶
type CompactResponse ¶
type CompactResponse = clientv3.CompactResponse
type DeleteResponse ¶
type DeleteResponse = clientv3.DeleteResponse
type EasyConfig ¶
type EasyConfig struct { Endpoints []string `yaml:"endpoints" ini:"endpoints" comment:"list of URLs"` DialTimeout time.Duration `yaml:"dial_timeout" ini:"dial_timeout" comment:"timeout for failing to establish a connection"` Username string `yaml:"username" ini:"username" comment:"user name for authentication"` Password string `yaml:"password" ini:"password" comment:"password for authentication"` // contains filtered or unexported fields }
EasyConfig ETCD client config
type GetResponse ¶
type GetResponse = clientv3.GetResponse
type LeaseGrantResponse ¶
type LeaseGrantResponse = clientv3.LeaseGrantResponse
LeaseGrantResponse wraps the protobuf message LeaseGrantResponse.
type LeaseKeepAliveResponse ¶
type LeaseKeepAliveResponse = clientv3.LeaseKeepAliveResponse
LeaseKeepAliveResponse wraps the protobuf message LeaseKeepAliveResponse.
type LeaseTimeToLiveResponse ¶
type LeaseTimeToLiveResponse = clientv3.LeaseTimeToLiveResponse
LeaseTimeToLiveResponse wraps the protobuf message LeaseTimeToLiveResponse.
type Mutex ¶
type Mutex = concurrency.Mutex
Mutexutex implements the sync Locker interface with etcd
type PutResponse ¶
type PutResponse = clientv3.PutResponse
type Session ¶
type Session = concurrency.Session
Session represents a lease kept alive for the lifetime of a client. Fault-tolerant applications may use sessions to reason about liveness.
type TxnResponse ¶
type TxnResponse = clientv3.TxnResponse