-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (29 loc) · 941 Bytes
/
main.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
package main
import (
ed "eileenyu.io/ebpf-prototype/eventdispatcher"
tetragon "eileenyu.io/ebpf-prototype/eventdispatcher/tetragon"
mm "eileenyu.io/ebpf-prototype/matcher"
"eileenyu.io/ebpf-prototype/notifier"
pc "eileenyu.io/ebpf-prototype/policy"
)
func eventHandler(ch chan ed.Event, eventReceiver ed.EventDispatcher, policyReceiver pc.PolicyCache, matcher mm.Matcher, nt notifier.Notifier) {
policies := policyReceiver.ListPolicies()
go eventReceiver.ListenEvent(ch)
for {
event := <-ch
for _, policy := range *policies {
if !matcher.Match(event, policy) {
continue
}
nt.Notify(event, policy)
}
}
}
func main() {
tetragonEventDispatcher := tetragon.TetragonEventDispatcher{}
policyReceiver := pc.PolicySimulator{}
matcher := mm.MockMatcher{}
stdNotifier := notifier.StdNotifier{}
ch := make(chan ed.Event)
eventHandler(ch, &tetragonEventDispatcher, &policyReceiver, &matcher, &stdNotifier)
}