@@ -23,44 +23,51 @@ package output
2323#include "flb_output.h"
2424*/
2525import "C"
26- import "fmt"
27- import "unsafe"
26+ import (
27+ "unsafe"
28+ )
2829
2930// Define constants matching Fluent Bit core
30- const FLB_ERROR = C .FLB_ERROR
31- const FLB_OK = C .FLB_OK
32- const FLB_RETRY = C .FLB_RETRY
31+ const (
32+ FLB_ERROR = C .FLB_ERROR
33+ FLB_OK = C .FLB_OK
34+ FLB_RETRY = C .FLB_RETRY
3335
34- const FLB_PROXY_OUTPUT_PLUGIN = C .FLB_PROXY_OUTPUT_PLUGIN
35- const FLB_PROXY_GOLANG = C .FLB_PROXY_GOLANG
36+ FLB_PROXY_OUTPUT_PLUGIN = C .FLB_PROXY_OUTPUT_PLUGIN
37+ FLB_PROXY_GOLANG = C .FLB_PROXY_GOLANG
38+ )
3639
3740// Local type to define a plugin definition
38- type FLBPlugin C.struct_flb_plugin_proxy
41+ type FLBPluginProxyDef C.struct_flb_plugin_proxy_def
3942type FLBOutPlugin C.struct_flbgo_output_plugin
4043
4144// When the FLBPluginInit is triggered by Fluent Bit, a plugin context
4245// is passed and the next step is to invoke this FLBPluginRegister() function
4346// to fill the required information: type, proxy type, flags name and
4447// description.
45- func FLBPluginRegister (ctx unsafe.Pointer , name string , desc string ) int {
46- p := (* FLBPlugin ) ( unsafe . Pointer ( ctx ) )
48+ func FLBPluginRegister (def unsafe.Pointer , name , desc string ) int {
49+ p := (* FLBPluginProxyDef )( def )
4750 p ._type = FLB_PROXY_OUTPUT_PLUGIN
4851 p .proxy = FLB_PROXY_GOLANG
4952 p .flags = 0
50- p .name = C .CString (name )
53+ p .name = C .CString (name )
5154 p .description = C .CString (desc )
5255 return 0
5356}
5457
5558// Release resources allocated by the plugin initialization
56- func FLBPluginUnregister (ctx unsafe.Pointer ) {
57- p := (* FLBPlugin ) (unsafe .Pointer (ctx ))
58- fmt .Printf ("[flbgo] unregistering %v\n " , p )
59+ func FLBPluginUnregister (def unsafe.Pointer ) {
60+ p := (* FLBPluginProxyDef )(def )
5961 C .free (unsafe .Pointer (p .name ))
6062 C .free (unsafe .Pointer (p .description ))
6163}
6264
63- func FLBPluginConfigKey (ctx unsafe.Pointer , key string ) string {
65+ func FLBPluginConfigKey (plugin unsafe.Pointer , key string ) string {
6466 _key := C .CString (key )
65- return C .GoString (C .output_get_property (_key , unsafe .Pointer (ctx )))
67+ return C .GoString (C .output_get_property (_key , plugin ))
68+ }
69+
70+ func FLBPluginSetContext (plugin , ctx unsafe.Pointer ) {
71+ p := (* FLBOutPlugin )(plugin )
72+ p .context .remote_context = ctx
6673}
0 commit comments