1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
package protocol
import "time"
// Tag holds the keys and values for a bunch of Tag k/v pairs
type Tag struct {
Key string
Value string
}
// Field holds the keys and values for a bunch of Metric Field k/v pairs
type Field struct {
Key string
Value interface{}
}
// Metric is the interface for marshaling, if you implement this interface you can be marshalled into the line protocol. Woot!
type Metric interface {
Time() time.Time
Name() string
TagList() []*Tag
FieldList() []*Field
}
// FieldSortOrder is a type for controlling if Fields are sorted
type FieldSortOrder int
const (
// NoSortFields tells the Decoder to not sort the fields
NoSortFields FieldSortOrder = iota
// SortFields tells the Decoder to sort the fields
SortFields
)
// FieldTypeSupport is a type for the parser to understand its type support
type FieldTypeSupport int
const (
// UintSupport means the parser understands uint64s and can store them without having to convert to int64
UintSupport FieldTypeSupport = 1 << iota
)
// MetricError is an error causing a metric to be unserializable.
type MetricError struct {
s string
}
func (e MetricError) Error() string {
return e.s
}
// FieldError is an error causing a field to be unserializable.
type FieldError struct {
s string
}
func (e FieldError) Error() string {
return e.s
}
var (
// ErrNeedMoreSpace tells us that the Decoder's io.Reader is full
ErrNeedMoreSpace = &MetricError{"need more space"}
// ErrInvalidName tells us that the chosen name is invalid
ErrInvalidName = &MetricError{"invalid name"}
// ErrNoFields tells us that there were no serializable fields in the line/metric
ErrNoFields = &MetricError{"no serializable fields"}
)
|