Skip to content

Commit

Permalink
config_format: yaml: Support passing arbitrary objects to processors
Browse files Browse the repository at this point in the history
This was initially based on
#8656 and
#8661 but ended up making
few different choices:

- Instead of adding FLB_CONFIG_MAP_KVLIST and FLB_CONFIG_MAP_ARRAY as
  config map types, it adds a single FLB_CONFIG_MAP_VARIANT which
  accepts an array or map. The passed array/map can have nested values
  and accept any JSON/YAML types, which are converted to cfl types. The
  processor will simply receive a `cfl_variant` pointer but doesn't own
  it, the config section is responsible for releasing its memory.
- The existing `flb_config_map_set` function is reused by passing the
  `cfl_variant` pointer (from the yaml parsing phase) as the value of a
  `flb_kv`. Then pointer is eventually passed to the processor context.

Signed-off-by: Thiago Padilha <[email protected]>
  • Loading branch information
tchrono committed Jun 5, 2024
1 parent 8aee285 commit 7edb1af
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 69 deletions.
4 changes: 4 additions & 0 deletions include/fluent-bit/flb_config_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <fluent-bit/flb_slist.h>
#include <fluent-bit/flb_sds.h>
#include <monkey/mk_core.h>
#include <cfl/cfl.h>

/* Configuration types */
#define FLB_CONFIG_MAP_STR 0 /* string */
Expand All @@ -47,6 +48,8 @@
#define FLB_CONFIG_MAP_SLIST_3 43 /* split up to 3 nodes + remaining data */
#define FLB_CONFIG_MAP_SLIST_4 44 /* split up to 4 nodes + remaining data */

#define FLB_CONFIG_MAP_VARIANT 50 /* variant that wraps a kvlist or array */

#define FLB_CONFIG_MAP_MULT 1

struct flb_config_map_val {
Expand All @@ -57,6 +60,7 @@ struct flb_config_map_val {
size_t s_num; /* FLB_CONFIG_MAP_SIZE */
flb_sds_t str; /* FLB_CONFIG_MAP_STR */
struct mk_list *list; /* FLB_CONFIG_MAP_CLIST and FLB_CONFIG_MAP_SLIST */
struct cfl_variant *variant; /* FLB_CONFIG_MAP_VARIANT */
} val;
struct mk_list *mult;
struct mk_list _head; /* Link to list if this entry is a 'multiple' entry */
Expand Down
2 changes: 1 addition & 1 deletion include/fluent-bit/flb_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ int flb_processor_instance_check_properties(

int flb_processor_instance_set_property(
struct flb_processor_instance *ins,
const char *k, const char *v);
const char *k, struct cfl_variant *v);

const char *flb_processor_instance_get_property(
const char *key,
Expand Down
Loading

0 comments on commit 7edb1af

Please sign in to comment.