@@ -6,7 +6,6 @@ package plugin
66import "C"
77
88import (
9- "bytes"
109 "context"
1110 "errors"
1211 "fmt"
@@ -237,7 +236,7 @@ func FLBPluginInputCallback(data *unsafe.Pointer, csize *C.size_t) int {
237236 return input .FLB_RETRY
238237 }
239238
240- return instance .callback (data , csize )
239+ return instance .inputCallback (data , csize )
241240}
242241
243242// FLBPluginInputCleanupCallback releases the memory used during the input callback
@@ -280,42 +279,14 @@ func FLBPluginFlush(data unsafe.Pointer, clength C.int, ctag *C.char) int {
280279
281280 in := C .GoBytes (data , clength )
282281 tag := C .GoString (ctag )
283- if err := pluginFlush ( instance , tag , in ); err != nil {
282+ if err := instance . outputFlush ( tag , in ); err != nil {
284283 fmt .Fprintf (os .Stderr , "flush: %s\n " , err )
285284 return output .FLB_ERROR
286285 }
287286
288287 return output .FLB_OK
289288}
290289
291- func pluginFlush (instance * pluginInstance , tag string , b []byte ) error {
292- dec := msgpack .NewDecoder (bytes .NewReader (b ))
293- for {
294- select {
295- case <- instance .runCtx .Done ():
296- err := instance .runCtx .Err ()
297- if err != nil && ! errors .Is (err , context .Canceled ) {
298- fmt .Fprintf (os .Stderr , "run: %s\n " , err )
299- return fmt .Errorf ("run: %w" , err )
300- }
301-
302- return nil
303- default :
304- }
305-
306- msg , err := decodeMsg (dec , tag )
307- if errors .Is (err , io .EOF ) {
308- return nil
309- }
310-
311- if err != nil {
312- return err
313- }
314-
315- instance .msgChannel <- msg
316- }
317- }
318-
319290// decodeMsg should be called with an already initialized decoder.
320291func decodeMsg (dec * msgpack.Decoder , tag string ) (Message , error ) {
321292 var out Message
@@ -512,7 +483,7 @@ func testCallback(inst *pluginInstance) ([]byte, int) {
512483 data := unsafe .Pointer (nil )
513484 var csize C.size_t
514485
515- retCode := inst .callback (& data , & csize )
486+ retCode := inst .inputCallback (& data , & csize )
516487
517488 if data == nil {
518489 return []byte {}, retCode
0 commit comments