@@ -836,26 +836,23 @@ func (p *Plugin) compilerUpdated(storage.Transaction) {
836
836
func (p * Plugin ) loop () {
837
837
ctx , cancel := context .WithCancel (context .Background ())
838
838
839
- var errCh chan error
840
- var stop chan chan struct {}
839
+ var stopImmediateLoop chan chan struct {}
841
840
if * p .config .Reporting .Trigger == plugins .TriggerImmediate && p .config .Service != "" {
842
- errCh = make (chan error )
843
- stop = make (chan chan struct {})
844
-
841
+ stopImmediateLoop = make (chan chan struct {})
845
842
switch p .config .Reporting .BufferType {
846
843
case sizeBufferType :
847
844
go immediateUpload [[][]byte ](ctx ,
848
- errCh ,
849
- stop ,
845
+ stopImmediateLoop ,
850
846
p .config .Reporting .MaxDelaySeconds ,
851
847
p ,
848
+ p ,
852
849
)
853
850
case eventBufferType :
854
851
go immediateUpload [* bufferItem ](ctx ,
855
- errCh ,
856
- stop ,
852
+ stopImmediateLoop ,
857
853
p .config .Reporting .MaxDelaySeconds ,
858
854
p .eventBuffer ,
855
+ p ,
859
856
)
860
857
}
861
858
}
@@ -898,16 +895,14 @@ func (p *Plugin) loop() {
898
895
}
899
896
900
897
select {
901
- case err := <- errCh :
902
- p .handleUploadError (err )
903
898
case <- waitC :
904
899
case update := <- p .reconfig :
905
900
p .reconfigure (ctx , update .config )
906
901
update .done <- struct {}{}
907
902
case done := <- p .stop :
908
903
if * p .config .Reporting .Trigger == plugins .TriggerImmediate {
909
904
d := make (chan struct {})
910
- stop <- d
905
+ stopImmediateLoop <- d
911
906
<- d
912
907
}
913
908
cancel ()
@@ -1303,7 +1298,7 @@ type buffer[T any] interface {
1303
1298
}
1304
1299
1305
1300
// immediateUpload continuously waits to receive a chunk or event and then attempts an upload
1306
- func immediateUpload [T any ](ctx context.Context , errCh chan error , stop chan chan struct {}, maxDelay * int64 , b buffer [T ]) {
1301
+ func immediateUpload [T any ](ctx context.Context , stopImmediateLoop chan chan struct {}, maxDelay * int64 , b buffer [T ], p * Plugin ) {
1307
1302
timer := time .NewTimer (time .Duration (* maxDelay ))
1308
1303
1309
1304
for {
@@ -1315,18 +1310,14 @@ func immediateUpload[T any](ctx context.Context, errCh chan error, stop chan cha
1315
1310
chunks = b .Handle (e )
1316
1311
case <- timer .C :
1317
1312
chunks = b .Flush ()
1318
- case d := <- stop :
1319
- d <- struct {}{}
1313
+ case done := <- stopImmediateLoop :
1314
+ done <- struct {}{}
1320
1315
return
1321
1316
}
1322
1317
1323
1318
err := b .UploadChunks (ctx , chunks )
1324
1319
if err != nil {
1325
- // this is consumed by p.loop to set the plugin status
1326
- errCh <- err
1327
- // delay briefly to prevent overloading the service
1328
- time .Sleep (minRetryDelay )
1329
-
1320
+ p .handleUploadError (err )
1330
1321
continue
1331
1322
}
1332
1323
0 commit comments