Documentation ¶
Index ¶
- Constants
- Variables
- func QueryPermutations(input url.Values) []map[string]string
- func TimeSequence(start time.Time, end time.Time, unit time.Duration) []time.Time
- type Client
- type Controller
- type Counter
- type DB
- func (db DB) AppendKey(data []byte, r Resolution, event string, t time.Time) []byte
- func (db *DB) Batch(tm time.Time, events ...*Event) (err []error)
- func (db *DB) Gather(tm time.Time, e *Event) error
- func (db DB) Key(r Resolution, event string, t time.Time) (k string)
- func (db *DB) Query(queries ...Query) (Results, error)
- type DataPoint
- type DataPoints
- type Desc
- func (d *Desc) Describe() *Desc
- func (d *Desc) Error() error
- func (d *Desc) HasLabel(label string) bool
- func (d *Desc) Labels() []string
- func (d *Desc) MatchingQueries(q url.Values) url.Values
- func (d *Desc) Name() string
- func (d *Desc) Resolution(name string) (r Resolution, ok bool)
- func (d *Desc) Resolutions() []Resolution
- func (d *Desc) Type() MetricType
- type Descriptor
- type Event
- type FrequencyMap
- type MetricType
- type Query
- type QueryBuilder
- func (q QueryBuilder) At(res Resolution) QueryBuilder
- func (q QueryBuilder) Between(start, end time.Time) QueryBuilder
- func (q QueryBuilder) Exact() QueryBuilder
- func (q QueryBuilder) From(event ...string) QueryBuilder
- func (q QueryBuilder) GroupBy(label ...string) QueryBuilder
- func (qb QueryBuilder) Queries(events Resolver) (queries []Query)
- func (q QueryBuilder) QueryValues(d *Desc) []map[string]string
- func (q QueryBuilder) Scan() QueryBuilder
- func (q QueryBuilder) Values() QueryBuilder
- func (q QueryBuilder) Where(label string, value ...string) QueryBuilder
- type QueryMode
- type Queryer
- type Registries
- type Registry
- type Resolution
- func (r Resolution) AddSteps(t time.Time, n int) time.Time
- func (r Resolution) IsZero() bool
- func (r Resolution) MarshalTime(t time.Time) string
- func (r Resolution) Name() string
- func (r Resolution) Round(t time.Time) time.Time
- func (r Resolution) Step() time.Duration
- func (r Resolution) TTL() time.Duration
- func (r Resolution) TimeSequence(s, e time.Time) []time.Time
- func (r Resolution) UnmarshalTime(s string) (t time.Time, err error)
- func (r Resolution) WithCodec(codec tcodec.TimeCodec) Resolution
- func (r Resolution) WithLayout(layout string) Resolution
- func (r Resolution) WithName(name string) Resolution
- func (r Resolution) WithStep(step time.Duration) Resolution
- func (r Resolution) WithTTL(ttl time.Duration) Resolution
- type Resolver
- type ResolverFunc
- type Result
- type Results
- type Snapshot
Constants ¶
View Source
const ( DefaultKeyPrefix = "meter" // Prefix all keys DefaultSeparator = '^' // Key separator DefaultScanSize = 100 // Scan size for queries )
DB defaults
View Source
const ( QueryParamEvent = "event" QueryParamResolution = "res" QueryParamStart = "start" QueryParamEnd = "end" QueryParamGroup = "group" QueryParamMode = "mode" )
View Source
const ( // DailyDateFormat is the date format used by the start/end query parameters DailyDateFormat string = "2006-01-02" HourlyDateFormat string = "2006-01-02-15" MinlyDateFormat string = "2006-01-02-15-04" )
Variables ¶
View Source
var ( ErrDuplicateEvent = errors.New("Duplicate event registration.") ErrNilRegistry = errors.New("Registry is nil") ErrNilEvent = errors.New("Event is nil") ErrNilDesc = errors.New("Desc is nil") ErrUnregisteredEvent = errors.New("Unregistered event") ErrInvalidEventLabel = errors.New("Invalid event label") ErrInvalidGroupLabel = errors.New("Invalid group label") ErrInvalidResolution = errors.New("Invalid event resolution") )
View Source
var ( // NoResolution = Resolution{"totals", 0, 0, NoResolutionCodec} ResolutionHourly = Resolution{"hourly", 0, Hourly, tcodec.LayoutCodec(HourlyDateFormat)} ResolutionDaily = Resolution{"daily", 0, Daily, tcodec.LayoutCodec(DailyDateFormat)} ResolutionMinly = Resolution{"minly", 0, Minly, tcodec.LayoutCodec(MinlyDateFormat)} ResolutionWeekly = Resolution{"weekly", 0, Weekly, tcodec.ISOWeekCodec} )
Functions ¶
func QueryPermutations ¶ added in v0.2.0
Types ¶
type Controller ¶
type Controller struct { DB *DB *Registry Logger *log.Logger TimeDecoder tcodec.TimeDecoder FlushInterval time.Duration // contains filtered or unexported fields }
func (*Controller) Close ¶ added in v0.4.0
func (c *Controller) Close()
func (*Controller) Flush ¶ added in v0.4.0
func (c *Controller) Flush(t time.Time)
func (*Controller) ServeHTTP ¶
func (c *Controller) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DB ¶
type DataPoint ¶
type DataPoint struct {
Timestamp, Value int64
}
func (DataPoint) MarshalJSON ¶
func (*DataPoint) UnmarshalJSON ¶ added in v0.2.0
type DataPoints ¶ added in v0.2.0
type DataPoints []DataPoint
func (DataPoints) Len ¶ added in v0.2.0
func (s DataPoints) Len() int
func (DataPoints) Less ¶ added in v0.2.0
func (s DataPoints) Less(i, j int) bool
func (DataPoints) MarshalJSON ¶ added in v0.2.0
func (s DataPoints) MarshalJSON() (data []byte, err error)
func (DataPoints) Sort ¶ added in v0.2.0
func (s DataPoints) Sort()
func (DataPoints) Swap ¶ added in v0.2.0
func (s DataPoints) Swap(i, j int)
type Desc ¶ added in v0.2.0
type Desc struct {
// contains filtered or unexported fields
}
func NewCounterDesc ¶ added in v0.2.0
func NewCounterDesc(name string, labels []string, res ...Resolution) *Desc
func NewDesc ¶ added in v0.2.0
func NewDesc(t MetricType, name string, labels []string, res ...Resolution) *Desc
func NewValueDesc ¶ added in v0.2.0
func NewValueDesc(name string, labels []string, res ...Resolution) *Desc
func (*Desc) HasLabel ¶ added in v0.2.0
func (d *Desc) LabelIndex(label string) int { return indexOf(d.labels, label) }
func (*Desc) MatchingQueries ¶ added in v0.2.0
func (*Desc) Resolution ¶ added in v0.2.0
func (d *Desc) Resolution(name string) (r Resolution, ok bool)
func (*Desc) Resolutions ¶ added in v0.2.0
func (d *Desc) Resolutions() []Resolution
func (*Desc) Type ¶ added in v0.2.0
func (d *Desc) Type() MetricType
type Descriptor ¶ added in v0.2.0
type Descriptor interface {
Describe() *Desc
}
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func (*Event) AddVolatile ¶ added in v0.4.0
type FrequencyMap ¶ added in v0.2.0
type MetricType ¶ added in v0.2.0
type MetricType uint8
const ( MetricTypeIncrement MetricType // Increment value on store MetricTypeUpdateOnce // Update value once on store MetricTypeUpdate // Update value on store )
func (MetricType) RedisCmd ¶ added in v0.4.0
func (t MetricType) RedisCmd() string
type Query ¶
type Query struct { Mode QueryMode Event Descriptor Start, End time.Time Group []string Resolution Resolution Values []map[string]string // contains filtered or unexported fields }
type QueryBuilder ¶ added in v0.2.0
type QueryBuilder struct { Mode QueryMode Events []string Start, End time.Time Group []string Query url.Values Resolution string }
func NewQueryBuilder ¶ added in v0.2.0
func NewQueryBuilder() QueryBuilder
func ParseQuery ¶ added in v0.2.0
func ParseQuery(q url.Values, tdec tcodec.TimeDecoder) (s QueryBuilder, err error)
func (QueryBuilder) At ¶ added in v0.2.0
func (q QueryBuilder) At(res Resolution) QueryBuilder
func (QueryBuilder) Between ¶ added in v0.2.0
func (q QueryBuilder) Between(start, end time.Time) QueryBuilder
func (QueryBuilder) Exact ¶ added in v0.2.0
func (q QueryBuilder) Exact() QueryBuilder
func (QueryBuilder) From ¶ added in v0.2.0
func (q QueryBuilder) From(event ...string) QueryBuilder
func (QueryBuilder) GroupBy ¶ added in v0.2.0
func (q QueryBuilder) GroupBy(label ...string) QueryBuilder
func (QueryBuilder) Queries ¶ added in v0.2.0
func (qb QueryBuilder) Queries(events Resolver) (queries []Query)
func (QueryBuilder) QueryValues ¶ added in v0.2.0
func (q QueryBuilder) QueryValues(d *Desc) []map[string]string
func (QueryBuilder) Scan ¶ added in v0.3.0
func (q QueryBuilder) Scan() QueryBuilder
func (QueryBuilder) Values ¶ added in v0.3.0
func (q QueryBuilder) Values() QueryBuilder
func (QueryBuilder) Where ¶ added in v0.2.0
func (q QueryBuilder) Where(label string, value ...string) QueryBuilder
type Registries ¶ added in v0.2.0
type Registries []*Registry
func (Registries) Get ¶ added in v0.2.0
func (r Registries) Get(name string) *Event
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func NewRegistryEvents ¶ added in v0.3.5
func (*Registry) MustRegister ¶
type Resolution ¶
type Resolution struct {
// contains filtered or unexported fields
}
func NewResolution ¶
func NewResolution(name string, step, ttl time.Duration) Resolution
func (Resolution) IsZero ¶ added in v0.2.0
func (r Resolution) IsZero() bool
func (Resolution) MarshalTime ¶
func (r Resolution) MarshalTime(t time.Time) string
func (Resolution) Name ¶
func (r Resolution) Name() string
func (Resolution) Step ¶
func (r Resolution) Step() time.Duration
func (Resolution) TTL ¶
func (r Resolution) TTL() time.Duration
func (Resolution) TimeSequence ¶
func (r Resolution) TimeSequence(s, e time.Time) []time.Time
func (Resolution) UnmarshalTime ¶
func (r Resolution) UnmarshalTime(s string) (t time.Time, err error)
func (Resolution) WithCodec ¶ added in v0.2.0
func (r Resolution) WithCodec(codec tcodec.TimeCodec) Resolution
func (Resolution) WithLayout ¶ added in v0.2.0
func (r Resolution) WithLayout(layout string) Resolution
func (Resolution) WithName ¶ added in v0.2.0
func (r Resolution) WithName(name string) Resolution
func (Resolution) WithStep ¶ added in v0.2.0
func (r Resolution) WithStep(step time.Duration) Resolution
func (Resolution) WithTTL ¶
func (r Resolution) WithTTL(ttl time.Duration) Resolution
type ResolverFunc ¶ added in v0.3.0
func (ResolverFunc) Get ¶ added in v0.3.0
func (rf ResolverFunc) Get(eventName string) Event
type Results ¶ added in v0.2.0
type Results []Result
func (Results) FrequencyMap ¶ added in v0.2.3
func (rs Results) FrequencyMap() FrequencyMap
Source Files ¶
Click to show internal directories.
Click to hide internal directories.