etcd

package
v6.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2019 License: Apache-2.0 Imports: 4 Imported by: 108

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

View Source
const (
	EventTypePut    = clientv3.EventTypePut
	EventTypeDelete = clientv3.EventTypeDelete
)

Event types

View Source
const (
	SortNone    SortOrder = clientv3.SortNone
	SortAscend            = clientv3.SortAscend
	SortDescend           = clientv3.SortDescend
)

SortOrder types

View Source
const (
	SortByKey            SortTarget = clientv3.SortByKey
	SortByVersion                   = clientv3.SortByVersion
	SortByCreateRevision            = clientv3.SortByCreateRevision
	SortByModRevision               = clientv3.SortByModRevision
	SortByValue                     = clientv3.SortByValue
)

SortTarget types

Variables

View Source
var NewClient = clientv3.New

NewClient creates a new etcdv3 client from a given configuration.

func New(cfg clientv3.Config) (*clientv3.Client, error)

NewLocker creates a sync.Locker backed by an etcd mutex.

func NewLocker(s *concurrency.Session, pfx string) sync.Locker

NewMutex creates a sync Locker interface with etcd. func NewMutex(s *concurrency.Session, pfx string) *Mutex

NewSession gets the leased session for a client.

func NewSession(client *v3.Client, opts ...concurrency.SessionOption) (*Session, error)
View Source
var WithAttachedKeys = clientv3.WithAttachedKeys

WithAttachedKeys makes TimeToLive list the keys attached to the given lease ID.

func WithAttachedKeys() LeaseOption
View Source
var WithCompactPhysical = clientv3.WithCompactPhysical

WithCompactPhysical makes Compact wait until all compacted entries are removed from the etcd server's storage.

func WithCompactPhysical() CompactOption
View Source
var WithCountOnly = clientv3.WithCountOnly

WithCountOnly makes the 'Get' request return only the count of keys.

func WithCountOnly() clientv3.OpOption
View Source
var WithCreatedNotify = clientv3.WithCreatedNotify

WithCreatedNotify makes watch server sends the created event.

func WithCreatedNotify() clientv3.OpOption
View Source
var WithFilterDelete = clientv3.WithFilterDelete

WithFilterDelete discards DELETE events from the watcher.

func WithFilterDelete() clientv3.OpOption
View Source
var WithFilterPut = clientv3.WithFilterPut

WithFilterPut discards PUT events from the watcher.

func WithFilterPut() clientv3.OpOption
View Source
var WithFirstCreate = clientv3.WithFirstCreate

WithFirstCreate gets the key with the oldest creation revision in the request range.

func WithFirstCreate() []clientv3.OpOption
View Source
var WithFirstKey = clientv3.WithFirstKey

WithFirstKey gets the lexically first key in the request range.

func WithFirstKey() []clientv3.OpOption
View Source
var WithFirstRev = clientv3.WithFirstRev

WithFirstRev gets the key with the oldest modification revision in the request range.

func WithFirstRev() []clientv3.OpOption
View Source
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
View Source
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
View Source
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
View Source
var WithKeysOnly = clientv3.WithKeysOnly

WithKeysOnly makes the 'Get' request return only the keys and the corresponding values will be omitted.

func WithKeysOnly() clientv3.OpOption
View Source
var WithLastCreate = clientv3.WithLastCreate

WithLastCreate gets the key with the latest creation revision in the request range.

func WithLastCreate() []clientv3.OpOption
View Source
var WithLastKey = clientv3.WithLastKey

WithLastKey gets the lexically last key in the request range.

func WithLastKey() []clientv3.OpOption
View Source
var WithLastRev = clientv3.WithLastRev

WithLastRev gets the key with the latest modification revision in the request range.

func WithLastRev
View Source
var WithLease = clientv3.WithLease

WithLease attaches a lease ID to a key in 'Put' request.

func WithLease(leaseID clientv3.LeaseID) clientv3.OpOption
View Source
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
View Source
var WithMaxCreateRev = clientv3.WithMaxCreateRev

WithMaxCreateRev filters out keys for Get with creation revisions greater than the given revision.

func WithMaxCreateRev(rev int64) clientv3.OpOption
View Source
var WithMaxModRev = clientv3.WithMaxModRev

WithMaxModRev filters out keys for Get with modification revisions greater than the given revision.

func WithMaxModRev(rev int64) clientv3.OpOption
View Source
var WithMinCreateRev = clientv3.WithMinCreateRev

WithMinCreateRev filters out keys for Get with creation revisions less than the given revision.

func WithMinCreateRev(rev int64) clientv3.OpOption
View Source
var WithMinModRev = clientv3.WithMinModRev

WithMinModRev filters out keys for Get with modification revisions less than the given revision.

func WithMinModRev(rev int64) clientv3.OpOption
View Source
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
View Source
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
View Source
var WithProgressNotify = clientv3.WithProgressNotify

every 10 minutes when there is no incoming events. Progress updates have zero events in WatchResponse.

func WithProgressNotify() clientv3.OpOption
View Source
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
View Source
var WithRequireLeader = clientv3.WithRequireLeader

WithRequireLeader requires client requests to only succeed when the cluster has a leader.

func WithRequireLeader(ctx context.Context) context.Context
View Source
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
View Source
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
View Source
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
View Source
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
View Source
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
View Source
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

func EasyNew

func EasyNew(etcdConfig EasyConfig) (*clientv3.Client, error)

EasyNew creates ETCD client. Note: If etcdConfig.DialTimeout<0, it means unlimit; If etcdConfig.DialTimeout=0, use the default value(15s).

Types

type Client

type Client = clientv3.Client

Client ETCD v3 client

type CompactResponse

type CompactResponse = clientv3.CompactResponse

type Config

type Config = clientv3.Config

Config etcd config

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

func (*EasyConfig) Check

func (c *EasyConfig) Check() error

Check check and correct config.

func (*EasyConfig) Reload

func (c *EasyConfig) Reload(bind cfgo.BindFunc) error

Reload Bi-directionally synchronizes config between YAML file and memory.

type GetResponse

type GetResponse = clientv3.GetResponse

type LeaseGrantResponse

type LeaseGrantResponse = clientv3.LeaseGrantResponse

LeaseGrantResponse wraps the protobuf message LeaseGrantResponse.

type LeaseID

type LeaseID = clientv3.LeaseID

LeaseID etcd lease ID

type LeaseKeepAliveResponse

type LeaseKeepAliveResponse = clientv3.LeaseKeepAliveResponse

LeaseKeepAliveResponse wraps the protobuf message LeaseKeepAliveResponse.

type LeaseStatus

type LeaseStatus = clientv3.LeaseStatus

LeaseStatus represents a lease status.

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 OpOption

type OpOption = clientv3.OpOption

OpOption configures Operations like Get, Put, Delete.

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 SessionOption

type SessionOption concurrency.SessionOption

SessionOption configures Session.

type SortOption

type SortOption = clientv3.SortOption

SortOption etcd SortOption type

type SortOrder

type SortOrder = clientv3.SortOrder

SortOrder etcd SortOrder type

type SortTarget

type SortTarget = clientv3.SortTarget

SortTarget etcd SortTarget type

type TxnResponse

type TxnResponse = clientv3.TxnResponse

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL