@@ -142,15 +142,13 @@ func runCrowdsec(
142142 parsers * parser.Parsers ,
143143 hub * cwhub.Hub ,
144144 datasources []acquisitionTypes.DataSource ,
145- pourCollector * leakybucket.PourCollector ,
146- stageCollector * parser.StageParseCollector ,
147- bucketOverflows []pipeline.Event ,
145+ sd * StateDumper ,
148146) error {
149147 inEvents = make (chan pipeline.Event )
150148 logLines = make (chan pipeline.Event )
151149
152- startParserRoutines (ctx , g , cConfig , parsers , stageCollector )
153- startBucketRoutines (ctx , g , cConfig , pourCollector )
150+ startParserRoutines (ctx , g , cConfig , parsers , sd . StageParse )
151+ startBucketRoutines (ctx , g , cConfig , sd . Pour )
154152
155153 apiClient , err := apiclient .GetLAPIClient ()
156154 if err != nil {
@@ -159,7 +157,7 @@ func runCrowdsec(
159157
160158 startHeartBeat (ctx , cConfig , apiClient )
161159
162- startOutputRoutines (ctx , cConfig , parsers , apiClient , stageCollector , bucketOverflows )
160+ startOutputRoutines (ctx , cConfig , parsers , apiClient , sd . StageParse , sd . BucketOverflows )
163161
164162 if err := startLPMetrics (ctx , cConfig , apiClient , hub , datasources ); err != nil {
165163 return err
@@ -182,9 +180,7 @@ func serveCrowdsec(
182180 hub * cwhub.Hub ,
183181 datasources []acquisitionTypes.DataSource ,
184182 agentReady chan bool ,
185- pourCollector * leakybucket.PourCollector ,
186- stageCollector * parser.StageParseCollector ,
187- bucketOverflows []pipeline.Event ,
183+ sd * StateDumper ,
188184) {
189185 cctx , cancel := context .WithCancel (ctx )
190186
@@ -200,7 +196,7 @@ func serveCrowdsec(
200196
201197 agentReady <- true
202198
203- if err := runCrowdsec (cctx , & g , cConfig , parsers , hub , datasources , pourCollector , stageCollector , bucketOverflows ); err != nil {
199+ if err := runCrowdsec (cctx , & g , cConfig , parsers , hub , datasources , sd ); err != nil {
204200 log .Fatalf ("unable to start crowdsec routines: %s" , err )
205201 }
206202 }()
@@ -217,11 +213,12 @@ func serveCrowdsec(
217213 }
218214
219215 log .Debugf ("everything is dead, return crowdsecTomb" )
216+ log .Debugf ("sd.DumpDir == %s" , sd .DumpDir )
220217
221- if flags .DumpDir != "" {
222- log .Debugf ("Dumping parser+bucket states to %s" , flags .DumpDir )
218+ if sd .DumpDir != "" {
219+ log .Debugf ("Dumping parser+bucket states to %s" , sd .DumpDir )
223220
224- if err := dumpAllStates ( flags . DumpDir , pourCollector , stageCollector , bucketOverflows ); err != nil {
221+ if err := sd . Dump ( ); err != nil {
225222 log .Fatal (err )
226223 }
227224
0 commit comments