Skip to content

Commit 75dd441

Browse files
committed
router: new checker for routing types
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 2ca31a2 commit 75dd441

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

include/fluent-bit/flb_router.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,29 @@
2222
#define FLB_ROUTER_H
2323

2424
#include <fluent-bit/flb_info.h>
25+
#include <fluent-bit/flb_input.h>
2526
#include <fluent-bit/flb_output.h>
2627

2728
struct flb_router_path {
2829
struct flb_output_instance *ins;
2930
struct mk_list _head;
3031
};
3132

33+
static inline int flb_router_match_type(int in_event_type,
34+
struct flb_output_instance *ins)
35+
{
36+
if (in_event_type == FLB_INPUT_LOGS &&
37+
!(ins->event_type & FLB_OUTPUT_LOGS)) {
38+
return FLB_FALSE;
39+
}
40+
else if (in_event_type == FLB_INPUT_METRICS &&
41+
!(ins->event_type & FLB_OUTPUT_METRICS)) {
42+
return FLB_FALSE;
43+
}
44+
45+
return FLB_TRUE;
46+
}
47+
3248
int flb_router_match(const char *tag, int tag_len,
3349
const char *match, void *match_regex);
3450
int flb_router_io_set(struct flb_config *config);

src/flb_router.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ int flb_router_io_set(struct flb_config *config)
171171
struct flb_input_instance, _head);
172172
o_ins = mk_list_entry_first(&config->outputs,
173173
struct flb_output_instance, _head);
174-
if (!o_ins->match
174+
175+
if (flb_router_match_type(i_ins->event_type, o_ins) &&
176+
!o_ins->match
175177
#ifdef FLB_HAVE_REGEX
176178
&& !o_ins->match_regex
177179
#endif
@@ -212,6 +214,10 @@ int flb_router_io_set(struct flb_config *config)
212214
continue;
213215
}
214216

217+
if (!flb_router_match_type(i_ins->event_type, o_ins)) {
218+
continue;
219+
}
220+
215221
if (flb_router_match(i_ins->tag, i_ins->tag_len, o_ins->match
216222
#ifdef FLB_HAVE_REGEX
217223
, o_ins->match_regex
@@ -250,6 +256,3 @@ void flb_router_exit(struct flb_config *config)
250256
}
251257
}
252258
}
253-
254-
255-

0 commit comments

Comments
 (0)