Skip to content

Commit f366284

Browse files
milkrageedsiper
authored andcommitted
proxy: send proxy context to go input plugin
This is necessary so that go input plugin can implement methods with context in the same way as it is done in go output plugin. Signed-off-by: milkrage <[email protected]>
1 parent 595400b commit f366284

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

include/fluent-bit/flb_plugin_proxy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ struct flb_plugin_proxy_context {
6565

6666
struct flb_plugin_input_proxy_context {
6767
int coll_fd;
68+
/* This context is set by the remote init and is passed to remote collect */
69+
void *remote_context;
6870
/* A proxy ptr is needed to store the proxy type/lang (OUTPUT/GOLANG) */
6971
struct flb_plugin_proxy *proxy;
7072
};

src/flb_plugin_proxy.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int flb_proxy_input_cb_collect(struct flb_input_instance *ins,
8282
#ifdef FLB_HAVE_PROXY_GO
8383
if (ctx->proxy->def->proxy == FLB_PROXY_GOLANG) {
8484
flb_trace("[GO] entering go_collect()");
85-
ret = proxy_go_input_collect(ctx->proxy, &data, &len);
85+
ret = proxy_go_input_collect(ctx, &data, &len);
8686

8787
if (len == 0) {
8888
flb_trace("[GO] No logs are ingested");
@@ -96,7 +96,7 @@ static int flb_proxy_input_cb_collect(struct flb_input_instance *ins,
9696

9797
flb_input_log_append(ins, NULL, 0, data, len);
9898

99-
ret = proxy_go_input_cleanup(ctx->proxy, data);
99+
ret = proxy_go_input_cleanup(ctx, data);
100100
if (ret == -1) {
101101
flb_errno();
102102
return -1;
@@ -111,19 +111,10 @@ static int flb_proxy_input_cb_init(struct flb_input_instance *ins,
111111
struct flb_config *config, void *data)
112112
{
113113
int ret = -1;
114-
struct flb_plugin_input_proxy_context *ctx;
115-
struct flb_plugin_proxy_context *pc;
116-
117-
/* Allocate space for the configuration context */
118-
ctx = flb_malloc(sizeof(struct flb_plugin_input_proxy_context));
119-
if (!ctx) {
120-
flb_errno();
121-
return -1;
122-
}
114+
struct flb_plugin_input_proxy_context *pc;
123115

124116
/* Before to initialize for proxy, set the proxy instance reference */
125-
pc = (struct flb_plugin_proxy_context *)(ins->context);
126-
ctx->proxy = pc->proxy;
117+
pc = (struct flb_plugin_input_proxy_context *)(ins->context);
127118

128119
/* Before to initialize, set the instance reference */
129120
pc->proxy->instance = ins;
@@ -148,7 +139,7 @@ static int flb_proxy_input_cb_init(struct flb_input_instance *ins,
148139
}
149140

150141
/* Set the context */
151-
flb_input_set_context(ins, ctx);
142+
flb_input_set_context(ins, pc);
152143

153144
/* Collect upon data available on timer */
154145
ret = flb_input_set_collector_time(ins,
@@ -160,12 +151,12 @@ static int flb_proxy_input_cb_init(struct flb_input_instance *ins,
160151
flb_error("Could not set collector for threaded proxy input plugin");
161152
goto init_error;
162153
}
163-
ctx->coll_fd = ret;
154+
pc->coll_fd = ret;
164155

165156
return ret;
166157

167158
init_error:
168-
flb_free(ctx);
159+
flb_free(pc);
169160

170161
return -1;
171162
}
@@ -312,10 +303,10 @@ static int flb_proxy_input_cb_pre_run(struct flb_input_instance *ins,
312303
struct flb_config *config, void *data)
313304
{
314305
int ret = -1;
315-
struct flb_plugin_proxy_context *pc;
306+
struct flb_plugin_input_proxy_context *pc;
316307
struct flb_plugin_proxy *proxy;
317308

318-
pc = (struct flb_plugin_proxy_context *)(ins->context);
309+
pc = (struct flb_plugin_input_proxy_context *)(ins->context);
319310
proxy = pc->proxy;
320311

321312
/* pre_run */

0 commit comments

Comments
 (0)