Esempio n. 1
0
func First(ts *ts.TimeSeries, predicate func(float64) bool) (time.Time, float64, bool) {
	if ts == nil {
		return time.Time{}, NaN, false
	}
	it := ts.IteratorTimeValue()
	for t, v, ok := it.Next(); ok; t, v, ok = it.Next() {
		if predicate(v) {
			return t, v, true
		}
	}
	return time.Time{}, 0, false
}
Esempio n. 2
0
func (carbon *Carbon) Write(ts *ts.TimeSeries) {
	carbon.Init()

	var buffer bytes.Buffer

	it := ts.IteratorTimeValue()
	for t, v, ok := it.Next(); ok; t, v, ok = it.Next() {
		fmt.Fprintf(&buffer, "%s %f %d\n", ts.Key(), v, t.Unix())
	}

	go func() {
		carbon.feed <- buffer
	}()
}