forked from atlassian/gostatsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.go
26 lines (21 loc) · 905 Bytes
/
backend.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
package gostatsd
import (
"context"
"github.com/spf13/viper"
)
// BackendFactory is a function that returns a Backend.
type BackendFactory func(*viper.Viper) (Backend, error)
// SendCallback is called by Backend.SendMetricsAsync() to notify about the result of operation.
// A list of errors is passed to the callback. It may be empty or contain nil values. Every non-nil value is an error
// that happened while sending metrics.
type SendCallback func([]error)
// Backend represents a backend.
type Backend interface {
// Name returns the name of the backend.
Name() string
// SendMetricsAsync flushes the metrics to the backend, preparing payload synchronously but doing the send asynchronously.
// Must not read/write MetricMap asynchronously.
SendMetricsAsync(context.Context, *MetricMap, SendCallback)
// SendEvent sends event to the backend.
SendEvent(context.Context, *Event) error
}