Add 'AddValuesWithTime' function to accumulator

This commit is contained in:
Evan Phoenix
2015-05-26 22:14:42 -07:00
parent dcd7861c1a
commit 2667183bfb
4 changed files with 100 additions and 9 deletions

View File

@@ -1,11 +1,16 @@
package testutil
import "fmt"
import (
"fmt"
"time"
)
type Point struct {
Name string
Value interface{}
Tags map[string]string
Name string
Value interface{}
Tags map[string]string
Values map[string]interface{}
Time time.Time
}
type Accumulator struct {
@@ -13,7 +18,31 @@ type Accumulator struct {
}
func (a *Accumulator) Add(name string, value interface{}, tags map[string]string) {
a.Points = append(a.Points, &Point{name, value, tags})
a.Points = append(
a.Points,
&Point{
Name: name,
Value: value,
Tags: tags,
},
)
}
func (a *Accumulator) AddValuesWithTime(
name string,
values map[string]interface{},
tags map[string]string,
timestamp time.Time,
) {
a.Points = append(
a.Points,
&Point{
Name: name,
Values: values,
Tags: tags,
Time: timestamp,
},
)
}
func (a *Accumulator) Get(name string) (*Point, bool) {