types

package
v4.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrefixAndGlob

func PrefixAndGlob(path string) (string, glob.Glob, bool, error)

PrefixAndGlob takes a path that is potentially globbed and returns the longest prefix of the path before a slash-delimited part with globbing characters. E.g. if the path is "/a/b/c*/d", it would return "/a/b". It also returns a glob.Glob instance that can be used to match the path. The third return value tells whether the path has globs in it or not. Some KV stores have no concept of directories (e.g. etcd3) and so they don't actually need to go back to the previous /, but watch logic should still work with them, albeit not quite as optimal.

Types

type ConfigSource

type ConfigSource interface {
	// Name should return the name used as the scheme of the URL that is
	// provided as the value of the "#from" key.
	Name() string
	// Get should return the content and version of the given path.  Path can
	// be globbed, but a backend may choose to return an error if globbing is
	// not supported.  Get should return an instance of ErrNotFound from this
	// package if the path does not exist in the source so that the agent can
	// distinguish that from other errors to allow for optional paths.
	Get(path string) (content map[string][]byte, version uint64, err error)
	// WaitForChange should accept a path and version and only return if either
	// the provided stop channel is closed, or if the path's content changes.
	// It should make every effort to not produce false positives.
	WaitForChange(path string, version uint64, stop <-chan struct{}) error
}

ConfigSource represents a data store for which we can get and watch paths.

type ConfigSourceConfig

type ConfigSourceConfig interface {
	validation.Validatable
	New() (ConfigSource, error)
}

ConfigSourceConfig is a config type for a ConfigSource. It can make new ConfigSource instances.

type ErrNotFound

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

ErrNotFound should be returned by config sources if a path does not exist, so that we can distinguish this from other errors in case the path is optional.

func NewNotFoundError

func NewNotFoundError(msg string) ErrNotFound

NewNotFoundError returns an instance of ErrNotFound with the given msg.

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type Stoppable

type Stoppable interface {
	Stop() error
}

Stoppable is something that can be stopped

Jump to

Keyboard shortcuts

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