Skip to content

Conversation

aklyuchev
Copy link

Added enable flag for periodic task


Note: by creating a PR or an issue you automatically agree to the CLA. See CONTRIBUTING.md. Feel free to remove this note, the agreement holds.

@aklyuchev aklyuchev force-pushed the feature/us900-periodic-task-enable-flag branch from 26b80b2 to a4d60b2 Compare April 6, 2025 07:24
const auto settings = settings_.Read();
taskEnabled = settings->enabled;
if(!taskEnabled) {
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting deadline + continue should be more straightforward and closer to existing code logic below

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

task.Stop();
}

UTEST(PeriodicTask, EnableDisable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that checks the task does not keep running periodically if ForceStepAsync is run while enabled=false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will also check that ForceStepAsync ignores enabled

task.Stop();
}

UTEST(PeriodicTask, EnableDisable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot to decipher in this test's logic - split it into some steps with empty lines and comment on each step

task.Stop();
}

UTEST(PeriodicTask, EnableDisable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that checks that if enabled=false during Start (even if enabled=true in PeriodicTask constructor), then the first iteration won't happen immediately and won't happen after period

task.Stop();
}

UTEST(PeriodicTask, EnableDisable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that checks that SynchronizeDebug respects enabled

task.Stop();
}

UTEST(PeriodicTask, EnableDisable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that after enabled=false + enabled=on the task does not always start an iteration instantly, but awaits the configured interval since the last time it was run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants