A cleanup callback is a Fluent Bit framework hook that releases resources associated with one completed input-callback cycle. It retrieves contextual resource values, performs cleanup, and returns status to the core. section 10.6.2
Implement cleanup around the callback’s operational context:
- Release resources specific to the current callback cycle rather than retaining uncontrolled connection data. section 10.6.2
- Close the source connection when its type requires it, especially when an empty query could leave the connection waiting. section 10.6.2
- Pass cleanup errors to the callback, log them, and report failure to the Fluent Bit core. section 10.6.2
- Use the framework grace period to allow resources to close during shutdown. section 10.6.2
Listing 10.4 Implementation of the cleanup callback function: in.go
//export FLBPluginInputCleanupCallback
func FLBPluginInputCleanupCallback(data unsafe.Pointer) int {
// err := releaseResources(data) #1
// if err != nil {
// log.Printf("%s had an error during cleanup, error is %s\n",
// Plugin_Name, err)
// return input.FLB_ERROR #2
//}
return input.FLB_OK #2
}
The Go implementation shows the cleanup callback’s framework-facing signature and an OK return when no resource-release error is reported. section 10.6.2
