Documentation ¶
Index ¶
- Variables
- func GetPrefixRangeEnd(prefix string) string
- func WithCountOnly() clientv3.OpOption
- func WithFromKey() clientv3.OpOption
- func WithKeysOnly() clientv3.OpOption
- func WithLimit(n int64) clientv3.OpOption
- func WithPrefix() clientv3.OpOption
- func WithRange(endKey string) clientv3.OpOption
- func WithRev(rev int64) clientv3.OpOption
- func WithSerializable() clientv3.OpOption
- func WithSort(target SortTarget, order SortOrder) clientv3.OpOption
- type Client
- type Cluster
- type Config
- type ConnConfig
- type KVStore
- func (kvs *KVStore) Delete(ctx context.Context, key string, options ...clientv3.OpOption) error
- func (kvs *KVStore) Get(ctx context.Context, key string, options ...clientv3.OpOption) ([]string, error)
- func (kvs *KVStore) Put(ctx context.Context, key, value string, options ...clientv3.OpOption) error
- type Node
- type Registry
- type SortOrder
- type SortTarget
Constants ¶
This section is empty.
Variables ¶
var DefaultConnConfig = &ConnConfig{ MaxConnections: 3, InitialNodeTimeout: 5 * time.Second, DebounceTime: 3 * time.Second, Retries: 2, }
var (
ErrNoClientAvailable = errors.New("no client nodes available")
)
var (
ErrNoKey = errors.New("Key could not be found")
)
Functions ¶
func GetPrefixRangeEnd ¶
GetPrefixRangeEnd gets the range end of the prefix. 'Get(foo, WithPrefix())' is equal to 'Get(foo, WithRange(GetPrefixRangeEnd(foo))'.
func WithCountOnly ¶
WithCountOnly makes the 'Get' request return only the count of keys.
func WithFromKey ¶
WithFromKey specifies the range of 'Get', 'Delete', 'Watch' requests to be equal or greater than the key in the argument.
func WithKeysOnly ¶
WithKeysOnly makes the 'Get' request return only the keys and the corresponding values will be omitted.
func 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 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 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 WithRev ¶
WithRev specifies the store revision for 'Get' request. Or the start revision of 'Watch' request.
func WithSerializable ¶
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) clientv3.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'.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ConnectionErrs ¶
type Cluster ¶
func (*Cluster) MemberList ¶
type Config ¶
type Config struct { ServiceName string `json:"service_name"` NodeName string `json:"node_name"` Port int `json:"port"` EtcdConfigFile string `json:"etcd_config_file"` InitialClusterClientUrls []string `json:"initial_cluster_client_urls"` Debug bool `json:"debug"` // contains filtered or unexported fields }
func ConfigFromFile ¶
type ConnConfig ¶
type ConnConfig struct { // Max connections to unique nodes in the cluster. If the value 0 is used, then // a mesh network will be formed (connection with every node). MaxConnections int // Timeout for establishing the initial connection with the service's nodes. // Connections afterwards are done asynchronously and don't have a timeout. InitialNodeTimeout time.Duration // Duration to batch the latest node changes. Prevents thundering herd of changes. DebounceTime time.Duration // Retries is the number of times a request is attempted to get a success. The // retires are possibliy done on different nodes. Retries int }
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
type SortTarget ¶
type SortTarget int
const ( SortByKey SortTarget = iota SortByVersion SortByCreateRevision SortByModRevision SortByValue )