-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
65 lines (57 loc) · 1.44 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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Hubble
package v1
import (
"google.golang.org/protobuf/types/known/timestamppb"
pb "github.com/cilium/cilium/api/v1/flow"
)
// Event represents a single event observed and stored by Hubble
type Event struct {
// Timestamp when event was observed in Hubble
Timestamp *timestamppb.Timestamp
// Event contains the actual event
Event interface{}
}
// GetFlow returns the decoded flow, or nil if the event is nil or not a flow
func (ev *Event) GetFlow() *pb.Flow {
if ev == nil || ev.Event == nil {
return nil
}
if f, ok := ev.Event.(*pb.Flow); ok {
return f
}
return nil
}
// GetAgentEvent returns the decoded agent event, or nil if the event is nil
// or not an agent event
func (ev *Event) GetAgentEvent() *pb.AgentEvent {
if ev == nil || ev.Event == nil {
return nil
}
if f, ok := ev.Event.(*pb.AgentEvent); ok {
return f
}
return nil
}
// GetDebugEvent returns the decoded debug event, or nil if the event is nil
// or not an debug event
func (ev *Event) GetDebugEvent() *pb.DebugEvent {
if ev == nil || ev.Event == nil {
return nil
}
if d, ok := ev.Event.(*pb.DebugEvent); ok {
return d
}
return nil
}
// GetLostEvent returns the decoded lost event, or nil if the event is nil
// or not a lost event
func (ev *Event) GetLostEvent() *pb.LostEvent {
if ev == nil || ev.Event == nil {
return nil
}
if f, ok := ev.Event.(*pb.LostEvent); ok {
return f
}
return nil
}