1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* Fluent Bit 4 * ========== 5 * Copyright (C) 2019-2021 The Fluent Bit Authors 6 * Copyright (C) 2015-2018 Treasure Data Inc. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 #ifndef FLB_LUA_CONFIG_H 22 #define FLB_LUA_CONFIG_H 23 24 #include <fluent-bit/flb_info.h> 25 #include <fluent-bit/flb_filter.h> 26 #include <fluent-bit/flb_luajit.h> 27 #include <fluent-bit/flb_sds.h> 28 29 #define LUA_BUFFER_CHUNK 1024 * 8 /* 8K should be enough to get started */ 30 #define L2C_TYPES_NUM_MAX 16 31 32 enum l2c_type_enum { 33 L2C_TYPE_INT, 34 L2C_TYPE_ARRAY 35 }; 36 37 struct l2c_type { 38 flb_sds_t key; 39 int type; 40 struct mk_list _head; 41 }; 42 43 struct lua_filter { 44 flb_sds_t script; /* lua script path */ 45 flb_sds_t call; /* function name */ 46 flb_sds_t buffer; /* json dec buffer */ 47 int l2c_types_num; /* number of l2c_types */ 48 int protected_mode; /* exec lua function in protected mode */ 49 int time_as_table; /* timestamp as a Lua table */ 50 struct mk_list l2c_types; /* data types (lua -> C) */ 51 struct flb_luajit *lua; /* state context */ 52 struct flb_filter_instance *ins; /* filter instance */ 53 }; 54 55 struct lua_filter *lua_config_create(struct flb_filter_instance *ins, 56 struct flb_config *config); 57 void lua_config_destroy(struct lua_filter *lf); 58 59 #endif 60