Skip to content

Commit ada01de

Browse files
committed
feat: add config endpoint_type
Signed-off-by: composer <[email protected]>
1 parent d0516b3 commit ada01de

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

plugins/out_doris/doris.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ static int http_put(struct flb_out_doris *ctx,
8181
const char *host, int port,
8282
const void *body, size_t body_len,
8383
const char *tag, int tag_len,
84-
const char *label, int label_len)
84+
const char *label, int label_len,
85+
const char *endpoint_type)
8586
{
87+
flb_plg_debug(ctx->ins, "send to %s", endpoint_type);
88+
8689
int ret;
8790
int out_ret = FLB_OK;
8891
size_t b_sent;
@@ -144,7 +147,9 @@ static int http_put(struct flb_out_doris *ctx,
144147
/* Append headers */
145148
flb_http_add_header(c, "format", 6, "json", 4);
146149
flb_http_add_header(c, "read_json_by_line", 17, "true", 4);
147-
flb_http_add_header(c, "Expect", 6, "100-continue", 12);
150+
if (strcasecmp(endpoint_type, "fe") == 0) {
151+
flb_http_add_header(c, "Expect", 6, "100-continue", 12);
152+
}
148153
flb_http_add_header(c, "User-Agent", 10, "Fluent-Bit", 10);
149154

150155
if (ctx->add_label) {
@@ -188,7 +193,7 @@ static int http_put(struct flb_out_doris *ctx,
188193
memcpy(redirect_port, mid + 1, end - (mid + 1));
189194

190195
out_ret = http_put(ctx, redirect_host, atoi(redirect_port),
191-
body, body_len, tag, tag_len, label, label_len);
196+
body, body_len, tag, tag_len, label, label_len, "be");
192197
}
193198
else if (c->resp.status == 200 && c->resp.payload_size > 0) {
194199
ret = flb_pack_json(c->resp.payload, c->resp.payload_size,
@@ -338,7 +343,7 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
338343
}
339344

340345
ret = http_put(ctx, ctx->host, ctx->port, out_body, out_size,
341-
event_chunk->tag, flb_sds_len(event_chunk->tag), label, len);
346+
event_chunk->tag, flb_sds_len(event_chunk->tag), label, len, ctx->endpoint_type);
342347
flb_sds_destroy(out_body);
343348

344349
if (ret == FLB_OK && ctx->log_progress_interval > 0) {
@@ -360,6 +365,12 @@ static int cb_doris_exit(void *data, struct flb_config *config)
360365

361366
/* Configuration properties map */
362367
static struct flb_config_map config_map[] = {
368+
// endpoint_type
369+
{
370+
FLB_CONFIG_MAP_STR, "endpoint_type", NULL,
371+
0, FLB_TRUE, offsetof(struct flb_out_doris, endpoint_type),
372+
"Set endpoint type: 'fe' (frontend) or 'be' (backend)"
373+
},
363374
// user
364375
{
365376
FLB_CONFIG_MAP_STR, "user", NULL,

plugins/out_doris/doris.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct flb_out_doris {
3232
char *host;
3333
int port;
3434
char uri[256];
35+
char *endpoint_type;
3536

3637
char *user;
3738
char *password;

plugins/out_doris/doris_conf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ struct flb_out_doris *flb_doris_conf_create(struct flb_output_instance *ins,
9898
flb_output_net_default("127.0.0.1", 8030, ins);
9999

100100
/* Validate */
101+
if (!ctx->endpoint_type || (strcasecmp(ctx->endpoint_type, "fe") != 0 && strcasecmp(ctx->endpoint_type, "be") != 0)) {
102+
flb_plg_error(ins, "endpoint_type is invalid");
103+
}
101104
if (!ctx->user) {
102105
flb_plg_error(ins, "user is not set");
103106
}

tests/runtime/out_doris.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ void flb_test_json()
172172

173173
ret = flb_output_set(ctx->flb, ctx->o_ffd,
174174
"match", "*",
175+
"endpoint_type", "fe",
175176
"user", "admin",
176177
"database", "d_fb",
177178
"table", "t_fb",
@@ -229,6 +230,7 @@ void flb_test_time_key()
229230

230231
ret = flb_output_set(ctx->flb, ctx->o_ffd,
231232
"match", "*",
233+
"endpoint_type", "fe",
232234
"user", "admin",
233235
"database", "d_fb",
234236
"table", "t_fb",

0 commit comments

Comments
 (0)