-
Notifications
You must be signed in to change notification settings - Fork 208
/
main.go
56 lines (43 loc) · 1.11 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// nolint
package main
import (
"context"
"github.com/cilium/cilium/api/v1/flow"
v1 "github.com/cilium/cilium/pkg/hubble/api/v1"
"github.com/microsoft/retina/pkg/controllers/cache"
"github.com/microsoft/retina/pkg/enricher"
"github.com/microsoft/retina/pkg/log"
"github.com/microsoft/retina/pkg/pubsub"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/timestamppb"
)
func main() {
opts := log.GetDefaultLogOpts()
opts.Level = "debug"
log.SetupZapLogger(opts)
l := log.Logger().Named("test-enricher")
ctx := context.Background()
c := cache.New(pubsub.New())
e := enricher.New(ctx, c)
e.Run()
for i := 0; i < 10; i++ {
addEvent(e)
}
oreader := e.ExportReader()
for i := 0; i < 10; i++ {
l.Info("Receiving event")
ev := oreader.NextFollow(ctx)
l.Info("Received event", zap.Any("event", ev))
}
}
func addEvent(e *enricher.Enricher) {
l := log.Logger().Named("addev")
ev := &v1.Event{
Timestamp: timestamppb.Now(),
Event: &flow.Flow{},
}
l.Info("Adding event", zap.Any("event", ev))
e.Write(ev)
}