snapshot

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2017 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IFace

type IFace interface {
	// Test if a feature is enabled using the built in random generator. This is done by generating
	// a random number in the range 0-99 and seeing if this number is < the value stored in the
	// runtime key, or the default_value if the runtime key is invalid.
	// NOTE: In the current implementation, this routine may return different results each time it
	//       is called because a new random number is used each time. Callers should understand this
	//       behavior and not assume that subsequent calls using the same snapshot will be
	//       consistent.
	// @param key supplies the feature key to lookup.
	// @param defaultValue supplies the default value that will be used if either the feature key
	//        does not exist or it is not an integer.
	// @return true if the feature is enabled.
	FeatureEnabled(key string, defaultValue uint64) bool

	// Fetch raw runtime data based on key.
	// @param key supplies the key to fetch.
	// @return const std::string& the value or empty string if the key does not exist.
	Get(key string) string

	// Fetch an integer runtime key.
	// @param key supplies the key to fetch.
	// @param defaultValue supplies the value to return if the key does not exist or it does not
	//        contain an integer.
	// @return uint64 the runtime value or the default value.
	GetInteger(key string, defaultValue uint64) uint64

	// Fetch all keys inside the snapshot.
	// @return []string all of the keys.
	Keys() []string

	Entries() map[string]*entry.Entry

	SetEntry(string, *entry.Entry)
}

Snapshot provides the currently loaded set of runtime values.

type Mock added in v0.1.1

type Mock struct {
	*Snapshot
}

Mock provides a Snapshot implementation for testing

func NewMock added in v0.1.1

func NewMock() (s *Mock)

NewMock initializes a new Mock

func (*Mock) FeatureEnabled added in v0.1.1

func (m *Mock) FeatureEnabled(key string, defaultValue uint64) bool

FeatureEnabled overrides the internal `Snapshot`s `FeatureEnabled`

func (*Mock) Set added in v0.1.2

func (m *Mock) Set(key string, val string) *Mock

Set set the entry for `key` to `val`

func (*Mock) SetDisabled added in v0.1.1

func (m *Mock) SetDisabled(key string) *Mock

SetDisabled overrides the entry for `key` to be disabled

func (*Mock) SetEnabled added in v0.1.1

func (m *Mock) SetEnabled(key string) *Mock

SetEnabled overrides the entry for `key` to be enabled

type Nil

type Nil struct{}

Implementation of Snapshot for the nilLoaderImpl.

func NewNil

func NewNil() (s *Nil)

func (*Nil) Entries

func (n *Nil) Entries() map[string]*entry.Entry

func (*Nil) FeatureEnabled

func (n *Nil) FeatureEnabled(key string, defaultValue uint64) bool

func (*Nil) Get

func (n *Nil) Get(key string) string

func (*Nil) GetInteger

func (n *Nil) GetInteger(key string, defaultValue uint64) uint64

func (*Nil) Keys

func (n *Nil) Keys() []string

func (*Nil) SetEntry

func (n *Nil) SetEntry(string, *entry.Entry)

type RandomGenerator

type RandomGenerator interface {
	// @return uint64 a new random number.
	Random() uint64
}

Random number generator. Implementations should be thread safe.

type Snapshot

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

Implementation of Snapshot for the filesystem loader.

func New

func New() (s *Snapshot)

func (*Snapshot) Entries

func (s *Snapshot) Entries() map[string]*entry.Entry

func (*Snapshot) FeatureEnabled

func (s *Snapshot) FeatureEnabled(key string, defaultValue uint64) bool

func (*Snapshot) Get

func (s *Snapshot) Get(key string) string

func (*Snapshot) GetInteger

func (s *Snapshot) GetInteger(key string, defaultValue uint64) uint64

func (*Snapshot) Keys

func (s *Snapshot) Keys() []string

func (*Snapshot) SetEntry

func (s *Snapshot) SetEntry(key string, e *entry.Entry)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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