@@ -19,6 +19,7 @@ import (
1919 "github.com/crowdsecurity/crowdsec/pkg/csconfig"
2020 "github.com/crowdsecurity/crowdsec/pkg/cwhub"
2121 "github.com/crowdsecurity/crowdsec/pkg/exprhelpers"
22+ "github.com/crowdsecurity/crowdsec/pkg/leakybucket"
2223 "github.com/crowdsecurity/crowdsec/pkg/metrics"
2324 "github.com/crowdsecurity/crowdsec/pkg/parser"
2425 "github.com/crowdsecurity/crowdsec/pkg/pipeline"
@@ -81,12 +82,12 @@ func startParserRoutines(ctx context.Context, g *errgroup.Group, cConfig *csconf
8182 }
8283}
8384
84- func startBucketRoutines (ctx context.Context , g * errgroup.Group , cConfig * csconfig.Config ) {
85+ func startBucketRoutines (ctx context.Context , g * errgroup.Group , cConfig * csconfig.Config , pourCollector * leakybucket. PourCollector ) {
8586 for idx := range cConfig .Crowdsec .BucketsRoutinesCount {
8687 log .WithField ("idx" , idx ).Info ("Starting bucket routine" )
8788 g .Go (func () error {
8889 defer trace .CatchPanic ("crowdsec/runPour/" + strconv .Itoa (idx ))
89- runPour (ctx , inEvents , holders , buckets , cConfig )
90+ runPour (ctx , inEvents , holders , buckets , cConfig , pourCollector )
9091 return nil
9192 })
9293 }
@@ -135,12 +136,12 @@ func startLPMetrics(ctx context.Context, cConfig *csconfig.Config, apiClient *ap
135136}
136137
137138// runCrowdsec starts the log processor service
138- func runCrowdsec (ctx context.Context , g * errgroup.Group , cConfig * csconfig.Config , parsers * parser.Parsers , hub * cwhub.Hub , datasources []acquisitionTypes.DataSource ) error {
139+ func runCrowdsec (ctx context.Context , g * errgroup.Group , cConfig * csconfig.Config , parsers * parser.Parsers , hub * cwhub.Hub , datasources []acquisitionTypes.DataSource , pourCollector * leakybucket. PourCollector ) error {
139140 inEvents = make (chan pipeline.Event )
140141 logLines = make (chan pipeline.Event )
141142
142143 startParserRoutines (ctx , g , cConfig , parsers )
143- startBucketRoutines (ctx , g , cConfig )
144+ startBucketRoutines (ctx , g , cConfig , pourCollector )
144145
145146 apiClient , err := apiclient .GetLAPIClient ()
146147 if err != nil {
@@ -165,7 +166,7 @@ func runCrowdsec(ctx context.Context, g *errgroup.Group, cConfig *csconfig.Confi
165166}
166167
167168// serveCrowdsec wraps the log processor service
168- func serveCrowdsec (ctx context.Context , parsers * parser.Parsers , cConfig * csconfig.Config , hub * cwhub.Hub , datasources []acquisitionTypes.DataSource , agentReady chan bool ) {
169+ func serveCrowdsec (ctx context.Context , parsers * parser.Parsers , cConfig * csconfig.Config , hub * cwhub.Hub , datasources []acquisitionTypes.DataSource , agentReady chan bool , pourCollector * leakybucket. PourCollector ) {
169170 cctx , cancel := context .WithCancel (ctx )
170171
171172 var g errgroup.Group
@@ -180,7 +181,7 @@ func serveCrowdsec(ctx context.Context, parsers *parser.Parsers, cConfig *csconf
180181
181182 agentReady <- true
182183
183- if err := runCrowdsec (cctx , & g , cConfig , parsers , hub , datasources ); err != nil {
184+ if err := runCrowdsec (cctx , & g , cConfig , parsers , hub , datasources , pourCollector ); err != nil {
184185 log .Fatalf ("unable to start crowdsec routines: %s" , err )
185186 }
186187 }()
@@ -201,7 +202,7 @@ func serveCrowdsec(ctx context.Context, parsers *parser.Parsers, cConfig *csconf
201202 if flags .DumpDir != "" {
202203 log .Debugf ("Dumping parser+bucket states to %s" , flags .DumpDir )
203204
204- if err := dumpAllStates (flags .DumpDir ); err != nil {
205+ if err := dumpAllStates (flags .DumpDir , pourCollector ); err != nil {
205206 log .Fatal (err )
206207 }
207208
0 commit comments