-
Notifications
You must be signed in to change notification settings - Fork 159
/
usage.go
54 lines (45 loc) · 1.81 KB
/
usage.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
package event
import "fmt"
const (
UsageEventsNs = "fabric.usage"
UsageEventsVersion = 2
)
type UsageEvent struct {
Namespace string `json:"namespace"`
Version uint32 `json:"version"`
EventType string `json:"event_type"`
SourceId string `json:"source_id"`
CircuitId string `json:"circuit_id"`
Usage uint64 `json:"usage"`
IntervalStartUTC int64 `json:"interval_start_utc"`
IntervalLength uint64 `json:"interval_length"`
Tags map[string]string `json:"tags"`
}
func (event *UsageEvent) String() string {
return fmt.Sprintf("%v source=%v session=%v usage=%v intervalStart=%v intervalLength=%v",
event.EventType, event.SourceId, event.CircuitId, event.Usage, event.IntervalStartUTC, event.IntervalLength)
}
type UsageEventHandler interface {
AcceptUsageEvent(event *UsageEvent)
}
type UsageEventV3 struct {
Namespace string `json:"namespace"`
Version uint32 `json:"version"`
SourceId string `json:"source_id"`
CircuitId string `json:"circuit_id"`
Usage map[string]uint64 `json:"usage"`
IntervalStartUTC int64 `json:"interval_start_utc"`
IntervalLength uint64 `json:"interval_length"`
Tags map[string]string `json:"tags"`
}
func (event *UsageEventV3) String() string {
return fmt.Sprintf("source=%v session=%v usage=%v intervalStart=%v intervalLength=%v",
event.SourceId, event.CircuitId, event.Usage, event.IntervalStartUTC, event.IntervalLength)
}
type UsageEventV3Handler interface {
AcceptUsageEventV3(event *UsageEventV3)
}
type UsageEventV3HandlerWrapper interface {
UsageEventV3Handler
IsWrapping(value UsageEventV3Handler) bool
}