@@ -7,12 +7,13 @@ specified instance configuration to the input callback.
77
88Every output plugin go through four callbacks associated to different phases:
99
10- | Plugin Phase | Callback |
11- | ---------------------| ----------------------------|
12- | Registration | FLBPluginRegister() |
13- | Initialization | FLBPluginInit() |
14- | Input Callback | FLBPluginInputCallback() |
15- | Exit | FLBPluginExit() |
10+ | Plugin Phase | Callback |
11+ | ------------------------| ---------------------------------|
12+ | Registration | FLBPluginRegister() |
13+ | Initialization | FLBPluginInit() |
14+ | Input Callback | FLBPluginInputCallback() |
15+ | Input Cleanup Callback | FLBPluginInputCleanupCallback() |
16+ | Exit | FLBPluginExit() |
1617
1718## Plugin Registration
1819
@@ -58,10 +59,6 @@ func alloc(size int) unsafe.Pointer {
5859func makeSlice (p unsafe .Pointer , n int ) *Slice {
5960 data := &c_slice_t{p, n}
6061
61- runtime.SetFinalizer (data, func (data *c_slice_t){
62- C.free (data.p )
63- })
64-
6562 s := &Slice{data: data}
6663 h := (*reflect.SliceHeader )(unsafe.Pointer (&s.Data ))
6764 h.Data = uintptr (p)
@@ -93,6 +90,29 @@ func FLBPluginInputCallback(data **C.void, size *C.size_t) int {
9390}
9491```
9592
93+ ### Input Cleanup Callback
94+
95+ For cleaning up to be allocated resources, this callback will be triggered after _ Input Callback_ .
96+
97+ This callback is mainly used for deallocating heap memories which are allocated by ` C.malloc ` or ` C.calloc ` .
98+
99+ ``` go
100+ import " sync"
101+
102+ var barrior sync.Mutex
103+
104+ // export FLBPluginInputCleanupCallback
105+ func FLBPluginInputCleanupCallback (data unsafe .Pointer ) int {
106+ barrior.Lock () // Guarding for deallocating region is needed for safety.
107+ C.free (unsafe.Pointer (data))
108+ barrior.Unlock ()
109+
110+ return input.FLB_OK
111+ }
112+ ```
113+
114+ #### Returning Status Values
115+
96116> for more details about how to process the sending msgpack data into Fluent Bit core, please refer to the [ in_gdummy.go] ( in_gdummy.go ) file.
97117
98118When done, there are three returning values available:
@@ -103,6 +123,7 @@ When done, there are three returning values available:
103123| FLB\_ ERROR | An internal error have ocurred, the plugin will not handle the set of records/data again. |
104124| FLB\_ RETRY | A recoverable error have ocurred, the engine can try to flush the records/data later.|
105125
126+
106127## Plugin Exit
107128
108129When Fluent Bit will stop using the instance of the plugin, it will trigger the exit callback. e.g:
0 commit comments