Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_systemd: Process enumerated data as cfl_kvlist(s) at first #9291

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions include/fluent-bit/flb_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,71 @@

struct flb_input_instance;

/*
* Tests callbacks
* ===============
*/
struct flb_test_in_formatter {
/*
* Runtime Library Mode
* ====================
* When the runtime library enable the test formatter mode, it needs to
* keep a reference of the context and other information:
*
* - rt_ctx : context created by flb_create()
*
* - rt_ffd : this plugin assigned 'integer' created by flb_output()
*
* - rt_in_calback: intermediary function to receive the results of
* the formatter plugin test function.
*
* - rt_data: opaque data type for rt_step_callback()
*/

/* runtime library context */
void *rt_ctx;

/* runtime library: assigned plugin integer */
int rt_ffd;

/* optional format context */
void *format_ctx;

/*
* "runtime step callback": this function pointer is used by Fluent Bit
* library mode to reference a test function that must retrieve the
* results of 'callback'. Consider this an intermediary function to
* transfer the results to the runtime test.
*
* This function is private and should not be set manually in the plugin
* code, it's set on src/flb_lib.c .
*/
void (*rt_in_callback) (void *, int, int, void *, size_t, void *);

/*
* opaque data type passed by the runtime library to be used on
* rt_step_test().
*/
void *rt_data;

/*
* Callback
* =========
* "Formatter callback": it references the plugin function that performs
* data formatting (msgpack -> local data). This entry is mostly to
* expose the plugin local function.
*/
int (*callback) (/* Fluent Bit context */
struct flb_config *,
/* plugin that ingested the records */
struct flb_input_instance *,
void *, /* plugin instance context */
const void *, /* incoming unformatted data */
size_t, /* incoming unformatted size */
void **, /* output buffer */
size_t *); /* output buffer size */
};

struct flb_input_plugin {
/*
* The type defines if this is a core-based plugin or it's handled by
Expand Down Expand Up @@ -138,6 +203,9 @@ struct flb_input_plugin {
/* Destroy */
void (*cb_destroy) (struct flb_input_plugin *);

/* Tests */
struct flb_test_in_formatter test_formatter;

void *instance;

struct mk_list _head;
Expand Down Expand Up @@ -177,6 +245,7 @@ struct flb_input_instance {
int runs_in_coroutine; /* instance runs in coroutine ? */
char name[32]; /* numbered name (cpu -> cpu.0) */
char *alias; /* alias name for the instance */
int test_mode; /* running tests? (default:off) */
void *context; /* plugin configuration context */
flb_pipefd_t ch_events[2]; /* channel for events */
struct flb_input_plugin *p; /* original plugin */
Expand Down Expand Up @@ -294,6 +363,8 @@ struct flb_input_instance {
struct flb_metrics *metrics; /* metrics */
#endif

/* Tests */
struct flb_test_in_formatter test_formatter;

/* is the plugin running in a separate thread ? */
int is_threaded;
Expand Down
4 changes: 4 additions & 0 deletions include/fluent-bit/flb_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ FLB_EXPORT int flb_output(flb_ctx_t *ctx, const char *output, struct flb_lib_out
FLB_EXPORT int flb_output_set_processor(flb_ctx_t *ctx, int ffd, struct flb_processor *proc);
FLB_EXPORT int flb_filter(flb_ctx_t *ctx, const char *filter, void *data);
FLB_EXPORT int flb_input_set(flb_ctx_t *ctx, int ffd, ...);
FLB_EXPORT int flb_input_set_test(flb_ctx_t *ctx, int ffd, char *test_name,
void (*in_callback) (void *, int, int,
void *, size_t, void *),
void *in_callback_data);
FLB_EXPORT int flb_input_property_check(flb_ctx_t *ctx, int ffd, char *key, char *val);
FLB_EXPORT int flb_output_property_check(flb_ctx_t *ctx, int ffd, char *key, char *val);
FLB_EXPORT int flb_filter_property_check(flb_ctx_t *ctx, int ffd, char *key, char *val);
Expand Down
Loading
Loading