|
75 | 75 |
|
76 | 76 | struct flb_input_instance; |
77 | 77 |
|
| 78 | +/* |
| 79 | + * Tests callbacks |
| 80 | + * =============== |
| 81 | + */ |
| 82 | +struct flb_test_in_formatter { |
| 83 | + /* |
| 84 | + * Runtime Library Mode |
| 85 | + * ==================== |
| 86 | + * When the runtime library enable the test formatter mode, it needs to |
| 87 | + * keep a reference of the context and other information: |
| 88 | + * |
| 89 | + * - rt_ctx : context created by flb_create() |
| 90 | + * |
| 91 | + * - rt_ffd : this plugin assigned 'integer' created by flb_output() |
| 92 | + * |
| 93 | + * - rt_in_calback: intermediary function to receive the results of |
| 94 | + * the formatter plugin test function. |
| 95 | + * |
| 96 | + * - rt_data: opaque data type for rt_step_callback() |
| 97 | + */ |
| 98 | + |
| 99 | + /* runtime library context */ |
| 100 | + void *rt_ctx; |
| 101 | + |
| 102 | + /* runtime library: assigned plugin integer */ |
| 103 | + int rt_ffd; |
| 104 | + |
| 105 | + /* optional format context */ |
| 106 | + void *format_ctx; |
| 107 | + |
| 108 | + /* |
| 109 | + * "runtime step callback": this function pointer is used by Fluent Bit |
| 110 | + * library mode to reference a test function that must retrieve the |
| 111 | + * results of 'callback'. Consider this an intermediary function to |
| 112 | + * transfer the results to the runtime test. |
| 113 | + * |
| 114 | + * This function is private and should not be set manually in the plugin |
| 115 | + * code, it's set on src/flb_lib.c . |
| 116 | + */ |
| 117 | + void (*rt_in_callback) (void *, int, int, void *, size_t, void *); |
| 118 | + |
| 119 | + /* |
| 120 | + * opaque data type passed by the runtime library to be used on |
| 121 | + * rt_step_test(). |
| 122 | + */ |
| 123 | + void *rt_data; |
| 124 | + |
| 125 | + /* |
| 126 | + * Callback |
| 127 | + * ========= |
| 128 | + * "Formatter callback": it references the plugin function that performs |
| 129 | + * data formatting (msgpack -> local data). This entry is mostly to |
| 130 | + * expose the plugin local function. |
| 131 | + */ |
| 132 | + int (*callback) (/* Fluent Bit context */ |
| 133 | + struct flb_config *, |
| 134 | + /* plugin that ingested the records */ |
| 135 | + struct flb_input_instance *, |
| 136 | + void *, /* plugin instance context */ |
| 137 | + const void *, /* incoming unformatted data */ |
| 138 | + size_t, /* incoming unformatted size */ |
| 139 | + void **, /* output buffer */ |
| 140 | + size_t *); /* output buffer size */ |
| 141 | +}; |
| 142 | + |
78 | 143 | struct flb_input_plugin { |
79 | 144 | /* |
80 | 145 | * The type defines if this is a core-based plugin or it's handled by |
@@ -138,6 +203,9 @@ struct flb_input_plugin { |
138 | 203 | /* Destroy */ |
139 | 204 | void (*cb_destroy) (struct flb_input_plugin *); |
140 | 205 |
|
| 206 | + /* Tests */ |
| 207 | + struct flb_test_in_formatter test_formatter; |
| 208 | + |
141 | 209 | void *instance; |
142 | 210 |
|
143 | 211 | struct mk_list _head; |
@@ -177,6 +245,7 @@ struct flb_input_instance { |
177 | 245 | int runs_in_coroutine; /* instance runs in coroutine ? */ |
178 | 246 | char name[32]; /* numbered name (cpu -> cpu.0) */ |
179 | 247 | char *alias; /* alias name for the instance */ |
| 248 | + int test_mode; /* running tests? (default:off) */ |
180 | 249 | void *context; /* plugin configuration context */ |
181 | 250 | flb_pipefd_t ch_events[2]; /* channel for events */ |
182 | 251 | struct flb_input_plugin *p; /* original plugin */ |
@@ -294,6 +363,8 @@ struct flb_input_instance { |
294 | 363 | struct flb_metrics *metrics; /* metrics */ |
295 | 364 | #endif |
296 | 365 |
|
| 366 | + /* Tests */ |
| 367 | + struct flb_test_in_formatter test_formatter; |
297 | 368 |
|
298 | 369 | /* is the plugin running in a separate thread ? */ |
299 | 370 | int is_threaded; |
|
0 commit comments