snap

package
v0.0.0-...-a1d7b1b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyKey is returned when a Rule with an empty key is created
	ErrEmptyKey = fmt.Errorf("Key cannot be Empty")

	// ErrConfigNotFound is returned when a config doesn't exist in the config map
	ErrConfigNotFound = fmt.Errorf("config item not found")

	// ErrNotA<type> is returned when the found config item doesn't have the expected type
	ErrNotAString = fmt.Errorf("config item is not a string")
	ErrNotAnInt   = fmt.Errorf("config item is not an int64")
	ErrNotABool   = fmt.Errorf("config item is not a boolean")
	ErrNotAFloat  = fmt.Errorf("config item is not a float64")
)

Functions

This section is empty.

Types

type Config

type Config map[string]interface{}

Config is a type alias for map[string]interface{} to allow the helper functions Get{String,Bool,Float,Int} to be defined.

func NewConfig

func NewConfig() Config

NewConfig returns initialized Config

func (Config) GetBool

func (c Config) GetBool(key string) (bool, error)

GetBool takes a given key and checks the config for both that the key exists, and that it is of type bool. Returns an error if either of these is false.

func (Config) GetFloat

func (c Config) GetFloat(key string) (float64, error)

GetFloat takes a given key and checks the config for both that the key exists, and that it is of type float64. Returns an error if either of these is false.

func (Config) GetInt

func (c Config) GetInt(key string) (int64, error)

GetInt takes a given key and checks the config for both that the key exists, and that it is of type int64. Returns an error if either of these is false.

func (Config) GetString

func (c Config) GetString(key string) (string, error)

GetString takes a given key and checks the config for both that the key exists, and that it is of type string. Returns an error if either of these is false.

type Metric

type Metric struct {
	Namespace   Namespace
	Version     int64
	Config      Config
	Data        interface{}
	Tags        map[string]string
	Timestamp   time.Time
	Unit        string
	Description string
	// contains filtered or unexported fields
}

Metric contains all info related to a Snap Metric

type Namespace

type Namespace []NamespaceElement

func CopyNamespace

func CopyNamespace(src Namespace) Namespace

CopyNamespace copies array of namespace elements to new array

func NewNamespace

func NewNamespace(ns ...string) Namespace

Newnamespace takes an array of strings and returns a namespace. A namespace is an array of namespaceElements. The provided array of strings is used to set the corresponding Value fields in the array of namespaceElements.

func (Namespace) AddDynamicElement

func (n Namespace) AddDynamicElement(name, description string) Namespace

AddDynamicElement adds a dynamic element to the given Namespace. A dynamic namespaceElement is defined by having a nonempty Name field.

func (Namespace) AddStaticElement

func (n Namespace) AddStaticElement(value string) Namespace

AddStaticElement adds a static element to the given Namespace. A static namespaceElement is defined by having an empty Name field.

func (Namespace) AddStaticElements

func (n Namespace) AddStaticElements(values ...string) Namespace

AddStaticElements adds a static elements to the given Namespace. A static namespaceElement is defined by having an empty Name field.

func (Namespace) Element

func (n Namespace) Element(idx int) NamespaceElement

func (Namespace) IsDynamic

func (n Namespace) IsDynamic() (bool, []int)

IsDynamic returns true if there is any element of the namespace which is dynamic. If the namespace is dynamic the second return value will contain an array of namespace elements (indexes) where there are dynamic namespace elements. A dynamic component of the namespace are those elements that contain variable data.

func (Namespace) String

func (n Namespace) String() string

String returns the string representation of the namespace with "/" joining the elements of the namespace. A leading "/" is added.

func (Namespace) Strings

func (n Namespace) Strings() []string

Strings returns an array of strings that represent the elements of the namespace.

type NamespaceElement

type NamespaceElement struct {
	Value       string
	Description string
	Name        string
}

namespaceElement provides meta data related to the namespace. This is of particular importance when the namespace contains data.

func NewNamespaceElement

func NewNamespaceElement(e string) NamespaceElement

NewNamespaceElement tasks a string and returns a namespaceElement where the Value field is set to the provided string argument.

func (*NamespaceElement) IsDynamic

func (n *NamespaceElement) IsDynamic() bool

IsDynamic returns true if the namespace element contains data. A namespace element that has a nonempty Name field is considered dynamic.

Directories

Path Synopsis
utilities
ns
str

Jump to

Keyboard shortcuts

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