diff --git a/include/fluent-bit/flb_output.h b/include/fluent-bit/flb_output.h index 661054b7db4..d69de4f9192 100644 --- a/include/fluent-bit/flb_output.h +++ b/include/fluent-bit/flb_output.h @@ -1075,6 +1075,8 @@ void *flb_output_get_cmt_instance(struct flb_output_instance *ins); #endif void flb_output_net_default(const char *host, int port, struct flb_output_instance *ins); +int flb_output_enable_multi_threading(struct flb_output_instance *ins, + struct flb_config *config); const char *flb_output_name(struct flb_output_instance *ins); void flb_output_pre_run(struct flb_config *config); void flb_output_exit(struct flb_config *config); diff --git a/include/fluent-bit/flb_plugin_proxy.h b/include/fluent-bit/flb_plugin_proxy.h index 081821417f9..ad2f379a3d5 100644 --- a/include/fluent-bit/flb_plugin_proxy.h +++ b/include/fluent-bit/flb_plugin_proxy.h @@ -71,10 +71,6 @@ struct flb_plugin_input_proxy_context { 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); diff --git a/src/flb_output.c b/src/flb_output.c index b1548f60dfa..64756c090e4 100644 --- a/src/flb_output.c +++ b/src/flb_output.c @@ -1220,27 +1220,6 @@ int flb_output_init_all(struct flb_config *config) } #endif -#ifdef FLB_HAVE_PROXY_GO - /* Proxy plugins have their own initialization */ - if (p->type == FLB_OUTPUT_PLUGIN_PROXY) { - ret = flb_plugin_proxy_output_init(p->proxy, ins, config); - if (ret == -1) { - flb_output_instance_destroy(ins); - return -1; - } - - /* Multi-threading enabled if configured */ - ret = flb_output_enable_multi_threading(ins, config); - if (ret == -1) { - flb_error("[output] could not start thread pool for '%s' plugin", - p->name); - return -1; - } - - continue; - } -#endif - #ifdef FLB_HAVE_TLS if (ins->use_tls == FLB_TRUE) { ins->tls = flb_tls_create(FLB_TLS_CLIENT_MODE, diff --git a/src/flb_plugin_proxy.c b/src/flb_plugin_proxy.c index eea90729762..eed253aa011 100644 --- a/src/flb_plugin_proxy.c +++ b/src/flb_plugin_proxy.c @@ -338,6 +338,9 @@ static int flb_proxy_output_cb_pre_run(void *out_context, struct flb_config *con return ret; } +int flb_proxy_output_cb_init(struct flb_output_instance *o_ins, + struct flb_config *config, void *data); + static int flb_proxy_register_output(struct flb_plugin_proxy *proxy, struct flb_plugin_proxy_def *def, struct flb_config *config) @@ -363,6 +366,7 @@ static int flb_proxy_register_output(struct flb_plugin_proxy *proxy, * the core plugins specs, have a different callback approach, so * we put our proxy-middle callbacks to do the translation properly. */ + out->cb_init = flb_proxy_output_cb_init; out->cb_flush = proxy_cb_flush; out->cb_pre_run = flb_proxy_output_cb_pre_run; out->cb_exit = flb_proxy_output_cb_exit; @@ -490,24 +494,35 @@ int flb_plugin_proxy_register(struct flb_plugin_proxy *proxy, return 0; } -int flb_plugin_proxy_output_init(struct flb_plugin_proxy *proxy, - struct flb_output_instance *o_ins, - struct flb_config *config) +int flb_proxy_output_cb_init(struct flb_output_instance *o_ins, + struct flb_config *config, void *data) { int ret = -1; + struct flb_plugin_proxy_context *pc; + + /* Before to initialize for proxy, set the proxy instance reference */ + pc = (struct flb_plugin_proxy_context *)(o_ins->context); /* Before to initialize, set the instance reference */ - proxy->instance = o_ins; + pc->proxy->instance = o_ins; /* Based on 'proxy', use the proper handler */ - if (proxy->def->proxy == FLB_PROXY_GOLANG) { + if (pc->proxy->def->proxy == FLB_PROXY_GOLANG) { #ifdef FLB_HAVE_PROXY_GO - ret = proxy_go_output_init(proxy); + ret = proxy_go_output_init(pc->proxy); #endif } else { flb_error("[proxy] unrecognized proxy handler %i", - proxy->def->proxy); + pc->proxy->def->proxy); + } + + /* Multi-threading enabled if configured */ + ret = flb_output_enable_multi_threading(o_ins, config); + if (ret == -1) { + flb_error("[output] could not start thread pool for '%s' plugin", + o_ins->p->name); + return -1; } return ret;