Skip to content

Commit 70a7ecf

Browse files
cosmo0920edsiper
authored andcommitted
cfl_ra_key: Implement generic CFL based RA key functionality
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 7ad0000 commit 70a7ecf

File tree

3 files changed

+908
-0
lines changed

3 files changed

+908
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* Fluent Bit
4+
* ==========
5+
* Copyright (C) 2015-2024 The Fluent Bit Authors
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#ifndef FLB_CFL_RA_KEY_H
21+
#define FLB_CFL_RA_KEY_H
22+
23+
#include <fluent-bit/flb_info.h>
24+
#include <fluent-bit/flb_sds.h>
25+
#include <fluent-bit/flb_regex.h>
26+
#include <fluent-bit/record_accessor/flb_ra_parser.h>
27+
#include <monkey/mk_core.h>
28+
#include <cfl/cfl.h>
29+
30+
#include <stdbool.h>
31+
32+
enum cfl_ra_types {
33+
FLB_CFL_RA_BOOL = 0,
34+
FLB_CFL_RA_INT,
35+
FLB_CFL_RA_FLOAT,
36+
FLB_CFL_RA_STRING,
37+
FLB_CFL_RA_NULL
38+
};
39+
40+
/* condition value types */
41+
typedef union {
42+
bool boolean;
43+
int64_t i64;
44+
double f64;
45+
flb_sds_t string;
46+
} cfl_ra_val;
47+
48+
/* Represent any value object */
49+
struct flb_cfl_ra_value {
50+
int type;
51+
struct cfl_variant v;
52+
cfl_ra_val val;
53+
};
54+
55+
struct flb_cfl_ra_value *flb_cfl_ra_key_to_value(flb_sds_t ckey,
56+
struct cfl_variant vobj,
57+
struct mk_list *subkeys);
58+
void flb_cfl_ra_key_value_destroy(struct flb_cfl_ra_value *v);
59+
60+
int flb_cfl_ra_key_value_get(flb_sds_t ckey, struct cfl_variant vobj,
61+
struct mk_list *subkeys,
62+
cfl_sds_t *start_key,
63+
cfl_sds_t *out_key, struct cfl_variant **out_val);
64+
65+
int flb_cfl_ra_key_strcmp(flb_sds_t ckey, struct cfl_variant vobj,
66+
struct mk_list *subkeys, char *str, int len);
67+
int flb_cfl_ra_key_regex_match(flb_sds_t ckey, struct cfl_variant vobj,
68+
struct mk_list *subkeys, struct flb_regex *regex,
69+
struct flb_regex_search *result);
70+
int flb_cfl_ra_key_value_append(struct flb_ra_parser *rp, struct cfl_variant *vobj,
71+
struct cfl_variant *in_val);
72+
int flb_cfl_ra_key_value_update(struct flb_ra_parser *rp, struct cfl_variant *vobj,
73+
cfl_sds_t in_key, struct cfl_variant *in_val);
74+
#endif

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ set(src
8585
flb_msgpack_append_message.c
8686
flb_notification.c
8787
flb_lock.c
88+
flb_cfl_ra_key.c
8889
)
8990

9091
# Config format

0 commit comments

Comments
 (0)