Documentation ¶
Index ¶
- type Simple
- func NewClientFromClient(client *etcd.Client) *Simple
- func NewClientFromNamespace(client *etcd.Client, kv etcd.KV, w etcd.Watcher) *Simple
- func NewClientFromNamespaceStr(client *etcd.Client, ns string) *Simple
- func NewClientFromSeeds(seeds []string) *Simple
- func NewClientFromSeedsNamespace(seeds []string, ns string) *Simple
- func NewClientFromSimple(client interfaces.Client, ns string) *Simple
- func (obj *Simple) Close() error
- func (obj *Simple) ComplexWatcher(ctx context.Context, path string, opts ...etcd.OpOption) (*interfaces.WatcherInfo, error)
- func (obj *Simple) Del(ctx context.Context, path string, opts ...etcd.OpOption) (int64, error)
- func (obj *Simple) Get(ctx context.Context, path string, opts ...etcd.OpOption) (map[string]string, error)
- func (obj *Simple) GetClient() *etcd.Client
- func (obj *Simple) Init() error
- func (obj *Simple) Set(ctx context.Context, key, value string, opts ...etcd.OpOption) error
- func (obj *Simple) Txn(ctx context.Context, ifCmps []etcd.Cmp, thenOps, elseOps []etcd.Op) (*etcd.TxnResponse, error)
- func (obj *Simple) Watcher(ctx context.Context, path string, opts ...etcd.OpOption) (chan error, error)
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 ¶
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 ¶
NewClientFromNamespace builds a new simple client by taking an existing set of interface API's that we might use.
func NewClientFromNamespaceStr ¶
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 ¶
NewClientFromSeeds builds a new simple client by connecting to a list of seeds.
func NewClientFromSeedsNamespace ¶
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) 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) 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 ¶
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) Set ¶
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.