crowdsec/pkg/leakybucket/processor.go

37 lines
1.2 KiB
Go
Raw Permalink Normal View History

2020-05-15 09:39:16 +00:00
package leakybucket
import "github.com/crowdsecurity/crowdsec/pkg/types"
type Processor interface {
OnBucketInit(Bucket *BucketFactory) error
OnBucketPour(Bucket *BucketFactory) func(types.Event, *Leaky) *types.Event
OnBucketOverflow(Bucket *BucketFactory) func(*Leaky, types.RuntimeAlert, *types.Queue) (types.RuntimeAlert, *types.Queue)
2023-01-06 08:26:16 +00:00
AfterBucketPour(Bucket *BucketFactory) func(types.Event, *Leaky) *types.Event
2020-05-15 09:39:16 +00:00
}
type DumbProcessor struct {
}
func (d *DumbProcessor) OnBucketInit(bucketFactory *BucketFactory) error {
2020-05-15 09:39:16 +00:00
return nil
}
func (d *DumbProcessor) OnBucketPour(bucketFactory *BucketFactory) func(types.Event, *Leaky) *types.Event {
return func(msg types.Event, leaky *Leaky) *types.Event {
2020-05-15 09:39:16 +00:00
return &msg
}
}
func (d *DumbProcessor) OnBucketOverflow(b *BucketFactory) func(*Leaky, types.RuntimeAlert, *types.Queue) (types.RuntimeAlert, *types.Queue) {
return func(leaky *Leaky, alert types.RuntimeAlert, queue *types.Queue) (types.RuntimeAlert, *types.Queue) {
return alert, queue
2020-05-15 09:39:16 +00:00
}
2023-01-06 08:26:16 +00:00
}
2020-05-15 09:39:16 +00:00
2023-01-06 08:26:16 +00:00
func (d *DumbProcessor) AfterBucketPour(bucketFactory *BucketFactory) func(types.Event, *Leaky) *types.Event {
return func(msg types.Event, leaky *Leaky) *types.Event {
return &msg
}
2020-05-15 09:39:16 +00:00
}