diff --git a/falcosidekick.go b/falcosidekick.go index fdd0eeb..c06a745 100644 --- a/falcosidekick.go +++ b/falcosidekick.go @@ -61,12 +61,18 @@ func (t *Teler) checkFalcoEvents() { // Check for pending Falco events every 5 seconds. for range ticker.C { + // Lock the FalcoSidekick event + t.falcoSidekick.sl.Lock() + // Get the count of pending Falco events. c := len(t.falcoSidekick.events) if c > 0 { // Send pending Falco events to FalcoSidekick. t.sendFalcoEvents() } + + // Unlock the FalcoSidekick event + t.falcoSidekick.sl.Unlock() } } diff --git a/teler_test.go b/teler_test.go index d1befd8..98219a6 100644 --- a/teler_test.go +++ b/teler_test.go @@ -11,6 +11,7 @@ import ( "os" "strings" "testing" + "time" "net/http" "net/http/httptest" @@ -286,6 +287,8 @@ func TestNewWithFalcoSidekickURL(t *testing.T) { if err != nil { t.Fatal(err) } + + time.Sleep(5 * time.Second) } func TestNewWithVerbose(t *testing.T) {