type opType … const tRange … const tPut … const tDeleteRange … const tTxn … var noPrefixEnd … type Op … // IsTxn returns true if the "Op" type is transaction. func (op Op) IsTxn() bool { … } // Txn returns the comparison(if) operations, "then" operations, and "else" operations. func (op Op) Txn() ([]Cmp, []Op, []Op) { … } // KeyBytes returns the byte slice holding the Op's key. func (op Op) KeyBytes() []byte { … } // WithKeyBytes sets the byte slice for the Op's key. func (op *Op) WithKeyBytes(key []byte) { … } // RangeBytes returns the byte slice holding with the Op's range end, if any. func (op Op) RangeBytes() []byte { … } // Rev returns the requested revision, if any. func (op Op) Rev() int64 { … } // IsPut returns true iff the operation is a Put. func (op Op) IsPut() bool { … } // IsGet returns true iff the operation is a Get. func (op Op) IsGet() bool { … } // IsDelete returns true iff the operation is a Delete. func (op Op) IsDelete() bool { … } // IsSerializable returns true if the serializable field is true. func (op Op) IsSerializable() bool { … } // IsKeysOnly returns whether keysOnly is set. func (op Op) IsKeysOnly() bool { … } // IsCountOnly returns whether countOnly is set. func (op Op) IsCountOnly() bool { … } // MinModRev returns the operation's minimum modify revision. func (op Op) MinModRev() int64 { … } // MaxModRev returns the operation's maximum modify revision. func (op Op) MaxModRev() int64 { … } // MinCreateRev returns the operation's minimum create revision. func (op Op) MinCreateRev() int64 { … } // MaxCreateRev returns the operation's maximum create revision. func (op Op) MaxCreateRev() int64 { … } // WithRangeBytes sets the byte slice for the Op's range end. func (op *Op) WithRangeBytes(end []byte) { … } // ValueBytes returns the byte slice holding the Op's value, if any. func (op Op) ValueBytes() []byte { … } // WithValueBytes sets the byte slice for the Op's value. func (op *Op) WithValueBytes(v []byte) { … } func (op Op) toRangeRequest() *pb.RangeRequest { … } func (op Op) toTxnRequest() *pb.TxnRequest { … } func (op Op) toRequestOp() *pb.RequestOp { … } func (op Op) isWrite() bool { … } func NewOp() *Op { … } // OpGet returns "get" operation based on given key and operation options. func OpGet(key string, opts ...OpOption) Op { … } // OpDelete returns "delete" operation based on given key and operation options. func OpDelete(key string, opts ...OpOption) Op { … } // OpPut returns "put" operation based on given key-value and operation options. func OpPut(key, val string, opts ...OpOption) Op { … } // OpTxn returns "txn" operation based on given transaction conditions. func OpTxn(cmps []Cmp, thenOps []Op, elseOps []Op) Op { … } func opWatch(key string, opts ...OpOption) Op { … } func (op *Op) applyOpts(opts []OpOption) { … } type OpOption … // WithLease attaches a lease ID to a key in 'Put' request. func WithLease(leaseID LeaseID) 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 WithLimit(n int64) OpOption { … } // WithRev specifies the store revision for 'Get' request. // Or the start revision of 'Watch' request. func WithRev(rev int64) 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'. func WithSort(target SortTarget, order SortOrder) OpOption { … } // GetPrefixRangeEnd gets the range end of the prefix. // 'Get(foo, WithPrefix())' is equal to 'Get(foo, WithRange(GetPrefixRangeEnd(foo))'. func GetPrefixRangeEnd(prefix string) string { … } func getPrefix(key []byte) []byte { … } // 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() 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 WithRange(endKey string) OpOption { … } // WithFromKey specifies the range of 'Get', 'Delete', 'Watch' requests // to be equal or greater than the key in the argument. func WithFromKey() OpOption { … } // WithSerializable makes 'Get' request serializable. By default, // it's linearizable. Serializable requests are better for lower latency // requirement. func WithSerializable() OpOption { … } // WithKeysOnly makes the 'Get' request return only the keys and the corresponding // values will be omitted. func WithKeysOnly() OpOption { … } // WithCountOnly makes the 'Get' request return only the count of keys. func WithCountOnly() OpOption { … } // WithMinModRev filters out keys for Get with modification revisions less than the given revision. func WithMinModRev(rev int64) OpOption { … } // WithMaxModRev filters out keys for Get with modification revisions greater than the given revision. func WithMaxModRev(rev int64) OpOption { … } // WithMinCreateRev filters out keys for Get with creation revisions less than the given revision. func WithMinCreateRev(rev int64) OpOption { … } // WithMaxCreateRev filters out keys for Get with creation revisions greater than the given revision. func WithMaxCreateRev(rev int64) OpOption { … } // WithFirstCreate gets the key with the oldest creation revision in the request range. func WithFirstCreate() []OpOption { … } // WithLastCreate gets the key with the latest creation revision in the request range. func WithLastCreate() []OpOption { … } // WithFirstKey gets the lexically first key in the request range. func WithFirstKey() []OpOption { … } // WithLastKey gets the lexically last key in the request range. func WithLastKey() []OpOption { … } // WithFirstRev gets the key with the oldest modification revision in the request range. func WithFirstRev() []OpOption { … } // WithLastRev gets the key with the latest modification revision in the request range. func WithLastRev() []OpOption { … } // withTop gets the first key over the get's prefix given a sort order func withTop(target SortTarget, order SortOrder) []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 WithProgressNotify() OpOption { … } // WithCreatedNotify makes watch server sends the created event. func WithCreatedNotify() OpOption { … } // WithFilterPut discards PUT events from the watcher. func WithFilterPut() OpOption { … } // WithFilterDelete discards DELETE events from the watcher. func WithFilterDelete() OpOption { … } // WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted, // nothing will be returned. func WithPrevKV() OpOption { … } // WithFragment to receive raw watch response with fragmentation. // Fragmentation is disabled by default. If fragmentation is enabled, // etcd watch server will split watch response before sending to clients // when the total size of watch events exceed server-side request limit. // The default server-side request limit is 1.5 MiB, which can be configured // as "--max-request-bytes" flag value + gRPC-overhead 512 bytes. // See "etcdserver/api/v3rpc/watch.go" for more details. func WithFragment() OpOption { … } // WithIgnoreValue updates the key using its current value. // This option can not be combined with non-empty values. // Returns an error if the key does not exist. func WithIgnoreValue() OpOption { … } // WithIgnoreLease updates the key using its current lease. // This option can not be combined with WithLease. // Returns an error if the key does not exist. func WithIgnoreLease() OpOption { … } type LeaseOp … type LeaseOption … func (op *LeaseOp) applyOpts(opts []LeaseOption) { … } // WithAttachedKeys makes TimeToLive list the keys attached to the given lease ID. func WithAttachedKeys() LeaseOption { … } func toLeaseTimeToLiveRequest(id LeaseID, opts ...LeaseOption) *pb.LeaseTimeToLiveRequest { … } // IsOptsWithPrefix returns true if WithPrefix option is called in the given opts. func IsOptsWithPrefix(opts []OpOption) bool { … } // IsOptsWithFromKey returns true if WithFromKey option is called in the given opts. func IsOptsWithFromKey(opts []OpOption) bool { … }