bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/leakybucket/trigger.go (about) 1 package leakybucket 2 3 import ( 4 "time" 5 6 "bitbucket.org/Aishee/synsec/pkg/types" 7 ) 8 9 type Trigger struct { 10 DumbProcessor 11 } 12 13 func (t *Trigger) OnBucketPour(b *BucketFactory) func(types.Event, *Leaky) *types.Event { 14 // Pour makes the bucket overflow all the time 15 // TriggerPour unconditionnaly overflows 16 return func(msg types.Event, l *Leaky) *types.Event { 17 l.Total_count = 1 18 l.First_ts = time.Now() 19 l.Ovflw_ts = time.Now() 20 l.logger.Infof("Bucket overflow") 21 l.Queue.Add(msg) 22 l.Out <- l.Queue 23 24 return nil 25 } 26 }