client

package
v0.0.0-...-c555478 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Simple

type Simple struct {
	Debug bool
	Logf  func(format string, v ...interface{})
	// contains filtered or unexported fields
}

Simple provides a simple etcd client for deploy and status operations. You can set Debug and Logf after you've built this with one of the NewClient* methods.

func NewClientFromClient

func NewClientFromClient(client *etcd.Client) *Simple

NewClientFromClient builds a new simple client by taking an existing client struct. It does not disconnect this when Close is called, as that is up to the parent, which is the owner of that client input struct.

func NewClientFromNamespace

func NewClientFromNamespace(client *etcd.Client, kv etcd.KV, w etcd.Watcher) *Simple

NewClientFromNamespace builds a new simple client by taking an existing set of interface API's that we might use.

func NewClientFromNamespaceStr

func NewClientFromNamespaceStr(client *etcd.Client, ns string) *Simple

NewClientFromNamespaceStr builds a new simple client by taking an existing client and a string namespace. Warning, this doesn't properly nest the namespaces.

func NewClientFromSeeds

func NewClientFromSeeds(seeds []string) *Simple

NewClientFromSeeds builds a new simple client by connecting to a list of seeds.

func NewClientFromSeedsNamespace

func NewClientFromSeedsNamespace(seeds []string, ns string) *Simple

NewClientFromSeedsNamespace builds a new simple client by connecting to a list of seeds and ensuring all key access is prefixed with a namespace.

func NewClientFromSimple

func NewClientFromSimple(client interfaces.Client, ns string) *Simple

NewClientFromSimple builds a simple client from an existing client interface which must be a simple client. This awkward method is required so that namespace nesting works properly, because the *etcd.Client doesn't directly pass through the namespace. I'd love to nuke this function, but it's good enough for now.

func (*Simple) Close

func (obj *Simple) Close() error

Close cleans up the struct after we're finished.

func (*Simple) ComplexWatcher

func (obj *Simple) ComplexWatcher(ctx context.Context, path string, opts ...etcd.OpOption) (*interfaces.WatcherInfo, error)

ComplexWatcher is a more capable watcher that also returns data information. This starts a watch request. It writes on a channel that you can follow to know when an event or an error occurs. It always sends one startup event. It will not return until the watch has been started. If it cannot start, then it will return an error. Remember to add the WithPrefix() option if you want to watch recursively. TODO: do we need to support retry and changed client connections? XXX: do we need to track last successful revision and retry from there? If so use: lastRev := response.Header.Revision // TODO: +1 ? and: etcd.WithRev(rev)

func (*Simple) Del

func (obj *Simple) Del(ctx context.Context, path string, opts ...etcd.OpOption) (int64, error)

Del runs a delete operation.

func (*Simple) Get

func (obj *Simple) Get(ctx context.Context, path string, opts ...etcd.OpOption) (map[string]string, error)

Get runs a get operation.

func (*Simple) GetClient

func (obj *Simple) GetClient() *etcd.Client

GetClient returns a handle to an open etcd Client. This is needed for certain upstream API's that don't support passing in KV and Watcher instead.

func (*Simple) Init

func (obj *Simple) Init() error

Init starts up the struct.

func (*Simple) Set

func (obj *Simple) Set(ctx context.Context, key, value string, opts ...etcd.OpOption) error

Set runs a set operation. If you'd like more information about whether a value changed or not, use Txn instead.

func (*Simple) Txn

func (obj *Simple) Txn(ctx context.Context, ifCmps []etcd.Cmp, thenOps, elseOps []etcd.Op) (*etcd.TxnResponse, error)

Txn runs a transaction.

func (*Simple) Watcher

func (obj *Simple) Watcher(ctx context.Context, path string, opts ...etcd.OpOption) (chan error, error)

Watcher is a watcher that returns a chan of error's instead of a chan with all sorts of watcher data. This is useful when we only want an event signal, but we don't care about the specifics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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