Skip to content

Commit

Permalink
in_dummy: Add flush_on_startup config. (fluent#8222)
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
Signed-off-by: ahspw <ahspvirtuallife@gmail.com>
  • Loading branch information
franciscovalentecastro authored and ahspw committed Jan 16, 2024
1 parent 61d63a8 commit f3787c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/in_dummy/in_dummy.c
Expand Up @@ -351,6 +351,10 @@ static int in_dummy_init(struct flb_input_instance *in,

flb_input_set_context(in, ctx);

if (ctx->flush_on_startup) {
in_dummy_collect(in, config, ctx);
}

ret = flb_input_set_collector_time(in,
in_dummy_collect,
tm.tv_sec,
Expand Down Expand Up @@ -444,6 +448,11 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_dummy, fixed_timestamp),
"used a fixed timestamp, allows the message to pre-generated once."
},
{
FLB_CONFIG_MAP_BOOL, "flush_on_startup", "false",
0, FLB_TRUE, offsetof(struct flb_dummy, flush_on_startup),
"generate the first event on startup"
},
{0}
};

Expand Down
1 change: 1 addition & 0 deletions plugins/in_dummy/in_dummy.h
Expand Up @@ -48,6 +48,7 @@ struct flb_dummy {
int start_time_nsec;

bool fixed_timestamp;
bool flush_on_startup;

char *ref_metadata_msgpack;
size_t ref_metadata_msgpack_size;
Expand Down
10 changes: 10 additions & 0 deletions tests/runtime/in_simple_systems.c
Expand Up @@ -569,6 +569,11 @@ void flb_test_dummy_records_message_interval_nsec(struct callback_records *recor
TEST_CHECK(records->num_records >= 1);
}

void flb_test_dummy_records_message_flush_on_startup(struct callback_records *records)
{
TEST_CHECK(records->num_records >= 2);
}

void flb_test_in_dummy_flush()
{
do_test("dummy", NULL);
Expand Down Expand Up @@ -610,6 +615,11 @@ void flb_test_in_dummy_flush()
"interval_sec", "0",
"interval_nsec", "700000000",
NULL);
do_test_records_wait_time("dummy", 5, flb_test_dummy_records_message_flush_on_startup,
"interval_sec", "5",
"interval_nsec", "0",
"flush_on_startup", "true",
NULL);
}

void flb_test_in_dummy_thread_flush()
Expand Down

0 comments on commit f3787c4

Please sign in to comment.