etcd

package
v0.0.0-...-8d377ce Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecoderNoop

func DecoderNoop(_, value []byte) ([]byte, error)

Types

type GetOption

type GetOption struct {
	// contains filtered or unexported fields
}

type Option

type Option struct {
	// contains filtered or unexported fields
}

func Range

func Range(end string) *Option

Range creates a Value that is backed a range of etcd key/value pairs from 'key' passed to NewValue to 'end' passed to Range.

The key range semantics (ie. lexicographic ordering) are the same as in etcd ranges, so for example to retrieve all keys prefixed by `foo/` key should be `foo/` and end should be `foo0`.

For any update in the given range, the decoder will be called and its result will trigger the return of a Get() call. The decoder should return a type that lets the user distinguish which of the multiple objects in the range got updated, as the Get() call returns no additional information about the location of the retrieved object by itself.

The order of values retrieved by Get() is currently fully arbitrary and must not be relied on. It's possible that in the future the order of updates and the blocking behaviour of Get will be formalized, but this is not yet the case. Instead, the data returned should be treated as eventually consistent with the etcd state.

For some uses, it might be necessary to first retrieve all the objects contained within the range before starting to block on updates - in this case, the BacklogOnly option should be used when calling Get.

type StringAt

type StringAt struct {
	Key   string
	Value string
}

func DecoderStringAt

func DecoderStringAt(key, value []byte) (StringAt, error)

type Value

type Value[T any] struct {
	// contains filtered or unexported fields
}

Value is an 'Event Value' backed in an etcd cluster, accessed over an etcd client. This is a stateless handle and can be copied and shared across goroutines.

func NewValue

func NewValue[T any](etcd client.Namespaced, key string, decoder func(key, value []byte) (T, error), options ...*Option) *Value[T]

NewValue creates a new Value for a given key(s) in an etcd client. The given decoder will be used to convert bytes retrieved from etcd into the interface{} value retrieved by Get by this value's watcher.

func (*Value[T]) Watch

func (e *Value[T]) Watch() event.Watcher[T]

Jump to

Keyboard shortcuts

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