summaryrefslogtreecommitdiffstats
path: root/fluent-bit/include/fluent-bit/flb_plugin_proxy.h
blob: 081821417f91d57564bb66d662c2ffc0da8967c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*  Fluent Bit
 *  ==========
 *  Copyright (C) 2015-2022 The Fluent Bit Authors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef FLB_PLUGIN_PROXY_H
#define FLB_PLUGIN_PROXY_H

#include <monkey/mk_core.h>
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_output.h>
#include <fluent-bit/flb_input_thread.h>

/* Plugin Types */
#define FLB_PROXY_INPUT_PLUGIN     1
#define FLB_PROXY_OUTPUT_PLUGIN    2

/* Proxies available */
#define FLB_PROXY_GOLANG          11

struct flb_plugin_proxy_def {
    /* Fields populated once remote flb_cb_register() is called */
    int type;                 /* defined by FLB_PROXY_[INPUT|OUTPUT]_PLUGIN  */
    int proxy;                /* proxy type                                  */
    int flags;
    char *name;               /* plugin short name                           */
    char *description;        /* plugin description                          */
};

/* Proxy context */
struct flb_plugin_proxy {
    /* Fields populated once remote flb_cb_register() is called */
    struct flb_plugin_proxy_def *def;

    /* Internal */
    struct flb_api *api;      /* API context to export functions             */
    void *instance;           /* input/output instance                       */
    void *dso_handler;        /* dso handler - dlopen(2)                     */
    void *data;               /* opaque data type for specific proxy handler */
    struct mk_list _head;     /* link to parent config->proxies              */
};

/* This is the context for proxy plugins */
struct flb_plugin_proxy_context {
    /* This context is set by the remote init and is passed to remote flush */
    void *remote_context;
    /* A proxy ptr is needed to detect the proxy type/lang (OUTPUT/GOLANG) */
    struct flb_plugin_proxy *proxy;
};

struct flb_plugin_input_proxy_context {
    int coll_fd;
    /* A proxy ptr is needed to store the proxy type/lang (OUTPUT/GOLANG) */
    struct flb_plugin_proxy *proxy;
};

void *flb_plugin_proxy_symbol(struct flb_plugin_proxy *proxy,
                              const char *symbol);

int flb_plugin_proxy_output_init(struct flb_plugin_proxy *proxy,
                                 struct flb_output_instance *o_ins,
                                 struct flb_config *config);

int flb_plugin_proxy_register(struct flb_plugin_proxy *proxy,
                              struct flb_config *config);

struct flb_plugin_proxy *flb_plugin_proxy_create(const char *dso_path, int type,
                                                 struct flb_config *config);
int flb_plugin_proxy_load_all(struct flb_config *config);

#endif