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_ENGINE_H 22 #define FLB_ENGINE_H 23 24 #include <fluent-bit/flb_info.h> 25 #include <fluent-bit/flb_bits.h> 26 #include <fluent-bit/flb_config.h> 27 #include <fluent-bit/flb_input.h> 28 #include <fluent-bit/flb_output.h> 29 #include <fluent-bit/flb_thread_storage.h> 30 31 /* Types of events handled by the Server engine */ 32 #define FLB_ENGINE_EV_CORE MK_EVENT_NOTIFICATION 33 #define FLB_ENGINE_EV_CUSTOM MK_EVENT_CUSTOM 34 #define FLB_ENGINE_EV_THREAD 1024 35 #define FLB_ENGINE_EV_SCHED 2048 36 #define FLB_ENGINE_EV_SCHED_FRAME (FLB_ENGINE_EV_SCHED + 4096) 37 #define FLB_ENGINE_EV_OUTPUT 8192 38 #define FLB_ENGINE_EV_THREAD_OUTPUT 16384 39 40 /* Engine events: all engine events set the left 32 bits to '1' */ 41 #define FLB_ENGINE_EV_STARTED FLB_BITS_U64_SET(1, 1) /* Engine started */ 42 #define FLB_ENGINE_EV_FAILED FLB_BITS_U64_SET(1, 2) /* Engine started */ 43 #define FLB_ENGINE_EV_STOP FLB_BITS_U64_SET(1, 3) /* Requested to stop */ 44 #define FLB_ENGINE_EV_SHUTDOWN FLB_BITS_U64_SET(1, 4) /* Engine shutdown */ 45 46 /* Similar to engine events, but used as return values */ 47 #define FLB_ENGINE_STARTED FLB_BITS_U64_LOW(FLB_ENGINE_EV_STARTED) 48 #define FLB_ENGINE_FAILED FLB_BITS_U64_LOW(FLB_ENGINE_EV_FAILED) 49 #define FLB_ENGINE_STOP FLB_BITS_U64_LOW(FLB_ENGINE_EV_STOP) 50 #define FLB_ENGINE_SHUTDOWN FLB_BITS_U64_LOW(FLB_ENGINE_EV_SHUTDOWN) 51 52 /* Engine signals: Task, it only refer to the type */ 53 #define FLB_ENGINE_TASK 2 54 #define FLB_ENGINE_IN_THREAD 3 55 56 int flb_engine_start(struct flb_config *config); 57 int flb_engine_failed(struct flb_config *config); 58 int flb_engine_flush(struct flb_config *config, 59 struct flb_input_plugin *in_force); 60 int flb_engine_exit(struct flb_config *config); 61 int flb_engine_exit_status(struct flb_config *config, int status); 62 int flb_engine_shutdown(struct flb_config *config); 63 int flb_engine_destroy_tasks(struct mk_list *tasks); 64 65 /* Engine event loop */ 66 void flb_engine_evl_init(); 67 struct mk_event_loop *flb_engine_evl_get(); 68 void flb_engine_evl_set(struct mk_event_loop *evl); 69 70 #endif 71