forked from atlassian/gostatsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
74 lines (62 loc) · 1.87 KB
/
types.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
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
72
73
74
package gostatsd
import (
"context"
"time"
)
// Nanotime is the number of nanoseconds elapsed since January 1, 1970 UTC.
// Get the value with time.Now().UnixNano().
type Nanotime int64
func NanoNow() Nanotime {
return Nanotime(time.Now().UnixNano())
}
func NanoMax(t1, t2 Nanotime) Nanotime {
if t1 > t2 {
return t1
}
return t2
}
// IP is a v4/v6 IP address.
// We do not use net.IP because it will involve conversion to string and back several times.
type IP string
// UnknownIP is an IP of an unknown source.
const UnknownIP IP = ""
type Wait func()
type TimerSubtypes struct {
Lower bool
LowerPct bool // pct
Upper bool
UpperPct bool // pct
Count bool
CountPct bool // pct
CountPerSecond bool
Mean bool
MeanPct bool // pct
Median bool
StdDev bool
Sum bool
SumPct bool // pct
SumSquares bool
SumSquaresPct bool // pct
}
// Runnable is a long running function intended to be launched in a goroutine.
type Runnable func(ctx context.Context)
// Runner exposes a Runnable through an interface
type Runner interface {
Run(ctx context.Context)
}
// RawMetricHandler is an interface that accepts a Metric for processing. Raw refers to pre-aggregation, not
// pre-consolidation.
type RawMetricHandler interface {
DispatchMetrics(ctx context.Context, m []*Metric)
DispatchMetricMap(ctx context.Context, mm *MetricMap)
}
// PipelineHandler can be used to handle metrics and events, it provides an estimate of how many tags it may add.
type PipelineHandler interface {
RawMetricHandler
// EstimatedTags returns a guess for how many tags to pre-allocate
EstimatedTags() int
// DispatchEvent dispatches event to the next step in a pipeline.
DispatchEvent(ctx context.Context, e *Event)
// WaitForEvents waits for all event-dispatching goroutines to finish.
WaitForEvents()
}