Documentation ¶
Overview ¶
Package reckon provides support for sampling and reporting on the keys and values in one or more redis instances
Index ¶
- Constants
- func AnyKey(key string, valueType ValueType) []string
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func ComputePowerOfTwoFreq(m map[int]int64) map[int]int64
- func MustAsset(name string) []byte
- func RenderHTML(s *Results, out io.Writer) error
- func RenderText(s *Results, out io.Writer) error
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func Run(opts Options, aggregator Aggregator) (map[string]*Results, int64, error)
- type Aggregator
- type AggregatorFunc
- type Options
- type Results
- type Statistics
- type ValueType
Constants ¶
const ( // MaxExampleKeys sets an upper bound on the number of example keys that will // be captured during sampling MaxExampleKeys = 10 // MaxExampleElements sets an upper bound on the number of example elements that // will be captured during sampling MaxExampleElements = 10 // MaxExampleValues sets an upper bound on the number of example values that // will be captured during sampling MaxExampleValues = 10 )
Variables ¶
This section is empty.
Functions ¶
func AnyKey ¶
AnyKey is an AggregatorFunc that puts any sampled key (regardless of key name or redis data type) into a generic "any-key" bucket.
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func ComputePowerOfTwoFreq ¶
ComputePowerOfTwoFreq converts a frequency map into a new frequency map, where each map key is the smallest power of two that is greater than or equal to the original map key.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RenderHTML ¶
RenderHTML renders an HTML report for a Results instance to the supplied io.Writer
func RenderText ¶
RenderText renders a plaintext report for a Results instance to the supplied io.Writer
func RestoreAsset ¶
Restore an asset under the given directory
func RestoreAssets ¶
Restore assets under the given directory recursively
func Run ¶
Run performs the configured sampling operation against the redis instance, returning aggregated statistics using the provided Aggregator, as well as the actual key count for the redis instance. If any errors occur, the sampling is short-circuited, and the error is returned. In such a case, the results should be considered invalid.
Types ¶
type Aggregator ¶
An Aggregator returns 0 or more arbitrary strings, to be used during a sampling operation as aggregation groups or "buckets". For example, an Aggregator that takes the first letter of the key would cause reckon to aggregate stats by each letter of the alphabet
type AggregatorFunc ¶
The AggregatorFunc type is an adapter to allow the use of ordinary functions as Aggregators. If f is a function with the appropriate signature, AggregatorFunc(f) is an Aggregator object that calls f.
type Options ¶
type Options struct { Host string Port int // MinSamples indicates the minimum number of random keys to sample from the redis // instance. Note that this does not mean **unique** keys, just an absolute // number of random keys. Therefore, this number should be small relative to // the number of keys in the redis instance. MinSamples int // SampleRate indicates the percentage of the keyspace to sample. // Accordingly, values should be between 0.0 and 1.0. If a non-zero value is // given for both `SampleRate` and `MinSamples`, the actual number of keys // sampled will be the greater of the two values, once the key count has been // calculated using the `SampleRate`. SampleRate float32 }
Options is a configuration struct that instructs the reckon pkg to sample the redis instance listening on a particular host/port with a specified number/percentage of random keys.
type Results ¶
type Results struct { Name string KeyCount int64 // Strings StringSizes map[int]int64 StringKeys map[string]bool StringValues map[string]bool // Sets SetSizes map[int]int64 SetElementSizes map[int]int64 SetKeys map[string]bool SetElements map[string]bool // Sorted Sets SortedSetSizes map[int]int64 SortedSetElementSizes map[int]int64 SortedSetKeys map[string]bool SortedSetElements map[string]bool // Hashes HashSizes map[int]int64 HashElementSizes map[int]int64 HashValueSizes map[int]int64 HashKeys map[string]bool HashElements map[string]bool HashValues map[string]bool // Lists ListSizes map[int]int64 ListElementSizes map[int]int64 ListKeys map[string]bool ListElements map[string]bool }
Results stores data about sampled redis data structures. Map keys represent lengths/sizes, while map values represent the frequency with which those lengths/sizes occurred in the sampled data. Example keys are stored in golang "sets", which are maps with bool values.
func NewResults ¶
func NewResults() *Results
NewResults constructs a new, zero-valued Results struct
type Statistics ¶
Statistics are basic descriptive statistics that summarize data in a frequency table
func ComputeStatistics ¶
func ComputeStatistics(m map[int]int64) Statistics
ComputeStatistics computes basic descriptive statistics about a frequency map
func NewStatistics ¶
func NewStatistics() *Statistics
NewStatistics creates a new zero-valued Statistics instance
type ValueType ¶
type ValueType string
A ValueType represents the various data types that redis can store. The string representation of a ValueType matches what is returned from redis' `TYPE` command.
var ( // TypeString represents a redis string value TypeString ValueType = "string" // TypeSortedSet represents a redis sorted set value TypeSortedSet ValueType = "zset" // TypeSet represents a redis set value TypeSet ValueType = "set" // TypeHash represents a redis hash value TypeHash ValueType = "hash" // TypeList represents a redis list value TypeList ValueType = "list" // TypeUnknown means that the redis value type is undefined, and indicates an error TypeUnknown ValueType = "unknown" // ErrNoKeys is the error returned when a specified redis instance contains // no keys, or the key count could not be determined ErrNoKeys = errors.New("No keys are present in the configured redis instance") )