Skip to content

Commit b56f9b1

Browse files
committed
out_tcp: document config_map, fix return value and set context to upstream
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 67df784 commit b56f9b1

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

plugins/out_tcp/tcp.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,30 @@ static int cb_tcp_exit(void *data, struct flb_config *config)
110110
return 0;
111111
}
112112

113-
/* Configuration properties map */
114-
static struct flb_config_map config_map[] = {
115-
{
116-
FLB_CONFIG_MAP_STR, "format", NULL,
117-
0, FLB_FALSE, 0,
118-
NULL
119-
},
120-
{
121-
FLB_CONFIG_MAP_STR, "json_date_format", NULL,
122-
0, FLB_FALSE, 0,
123-
NULL
124-
},
125-
{
126-
FLB_CONFIG_MAP_STR, "json_date_key", "date",
127-
0, FLB_TRUE, offsetof(struct flb_out_tcp, json_date_key),
128-
NULL
129-
},
130-
/* EOF */
131-
{0}
113+
/* Configuration properties map */
114+
static struct flb_config_map config_map[] = {
115+
{
116+
FLB_CONFIG_MAP_STR, "format", "msgpack",
117+
0, FLB_FALSE, 0,
118+
"Specify the payload format, supported formats: msgpack, json, "
119+
"json_lines or json_stream."
120+
},
121+
122+
{
123+
FLB_CONFIG_MAP_STR, "json_date_format", "double",
124+
0, FLB_FALSE, 0,
125+
"Specify the format of the date, supported formats: double, iso8601 "
126+
"(e.g: 2018-05-30T09:39:52.000681Z) and epoch."
127+
},
128+
129+
{
130+
FLB_CONFIG_MAP_STR, "json_date_key", "date",
131+
0, FLB_TRUE, offsetof(struct flb_out_tcp, json_date_key),
132+
"Specify the name of the date field in output."
133+
},
134+
135+
/* EOF */
136+
{0}
132137
};
133138

134139
/* Plugin reference */

plugins/out_tcp/tcp_conf.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ struct flb_out_tcp *flb_tcp_conf_create(struct flb_output_instance *ins,
4242
return NULL;
4343
}
4444
ctx->ins = ins;
45-
46-
ret = flb_output_config_map_set(ins, (void *) ctx);
47-
if (ret == -1) {
48-
return -1;
49-
}
45+
46+
ret = flb_output_config_map_set(ins, (void *) ctx);
47+
if (ret == -1) {
48+
return NULL;
49+
}
5050

5151
/* Set default network configuration if not set */
5252
flb_output_net_default("127.0.0.1", 5170, ins);
@@ -107,6 +107,8 @@ struct flb_out_tcp *flb_tcp_conf_create(struct flb_output_instance *ins,
107107
}
108108

109109
ctx->u = upstream;
110+
flb_output_upstream_set(ctx->u, ins);
111+
110112
ctx->host = ins->host.name;
111113
ctx->port = ins->host.port;
112114

0 commit comments

Comments
 (0)