crowdsec/pkg/leakybucket/trigger.go
Thibault bui Koechlin 2016167654 initial import
2020-05-15 11:39:16 +02:00

27 lines
529 B
Go

package leakybucket
import (
"time"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
type Trigger struct {
DumbProcessor
}
func (t *Trigger) OnBucketPour(b *BucketFactory) func(types.Event, *Leaky) *types.Event {
// Pour makes the bucket overflow all the time
// TriggerPour unconditionnaly overflows
return func(msg types.Event, l *Leaky) *types.Event {
l.Total_count = 1
l.First_ts = time.Now()
l.Ovflw_ts = time.Now()
l.logger.Infof("Bucket overflow")
l.Queue.Add(msg)
l.Out <- l.Queue
return nil
}
}