/
event.go
40 lines (30 loc) · 972 Bytes
/
event.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
package telemetry
type EventType string
const (
CommandStartedEvent EventType = "CommandStarted"
CommandExitedEvent EventType = "CommandExited"
)
type Event interface {
GetType() EventType
}
type CommandOption struct {
Name string `json:"name"`
AsCli bool `json:"asCli"`
AsEnv bool `json:"asEnv"`
Count int `json:"count"`
}
func NewCommandStarted(commandOptions []CommandOption) *CommandStarted {
return &CommandStarted{CommandOptions: commandOptions}
}
type CommandStarted struct {
CommandOptions []CommandOption `json:"commandOptions,omitempty"`
}
func (e *CommandStarted) GetType() EventType { return CommandStartedEvent }
func NewCommandExited(exitCode int, durationMs int64) *CommandExited {
return &CommandExited{ExitCode: exitCode, DurationMs: durationMs}
}
type CommandExited struct {
ExitCode int `json:"exitCode"`
DurationMs int64 `json:"durationMs"`
}
func (e *CommandExited) GetType() EventType { return CommandExitedEvent }