forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serializer.go
38 lines (33 loc) · 1.42 KB
/
serializer.go
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
package telegraf
// Serializer is an interface defining functions that a serializer plugin must
// satisfy.
//
// Implementations of this interface should be reentrant but are not required
// to be thread-safe.
type Serializer interface {
// Serialize takes a single telegraf metric and turns it into a byte buffer.
// separate metrics should be separated by a newline, and there should be
// a newline at the end of the buffer.
//
// New plugins should use SerializeBatch instead to allow for non-line
// delimited metrics.
Serialize(metric Metric) ([]byte, error)
// SerializeBatch takes an array of telegraf metric and serializes it into
// a byte buffer. This method is not required to be suitable for use with
// line oriented framing.
SerializeBatch(metrics []Metric) ([]byte, error)
}
// SerializerFunc is a function to create a new instance of a serializer
type SerializerFunc func() (Serializer, error)
// SerializerPlugin is an interface for plugins that are able to
// serialize telegraf metrics into arbitrary data formats.
type SerializerPlugin interface {
// SetSerializer sets the serializer function for the interface.
SetSerializer(serializer Serializer)
}
// SerializerFuncPlugin is an interface for plugins that are able to serialize
// arbitrary data formats and require multiple instances of a parser.
type SerializerFuncPlugin interface {
// GetParser returns a new parser.
SetSerializerFunc(fn SerializerFunc)
}