/
timing.go
36 lines (28 loc) · 991 Bytes
/
timing.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
package contexts
import (
"github.com/blushft/jitsuclient/event"
"github.com/fatih/structs"
)
const ContextTiming event.ContextType = "timing"
type Timing struct {
Category string `json:"category,omitempty" structs:"category,omitempty" mapstructure:"category,omitempty"`
Label string `json:"label,omitempty" structs:"label,omitempty" mapstructure:"label,omitempty"`
Unit string `json:"unit,omitempty" structs:"unit,omitempty" mapstructure:"unit,omitempty"`
Variable string `json:"variable,omitempty" structs:"variable,omitempty" mapstructure:"variable,omitempty"`
Value float64 `json:"value,omitempty" structs:"value,omitempty" mapstructure:"value,omitempty"`
}
func (ctx *Timing) Type() event.ContextType {
return ContextTiming
}
func (ctx *Timing) Values() map[string]interface{} {
return structs.Map(ctx)
}
func (ctx *Timing) Interface() interface{} {
return ctx
}
func (ctx *Timing) Validate() bool {
if ctx.Value == 0 {
return false
}
return true
}