mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 15:51:21 +00:00
77bce93e85
Previously we often had two sets of events, one in the network package, and then another in the events package. We now only have one, in the events package. Events now have a public API, with minimal deps. There's an implementation package which has the dependencies. This allows the network package to generate events, without have a circular dependency on the events implementation package.
29 lines
814 B
Go
29 lines
814 B
Go
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"`
|
|
}
|
|
|
|
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)
|
|
}
|