-
Notifications
You must be signed in to change notification settings - Fork 348
Add timepoint to periodic task settings. #913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,15 @@ class PeriodicTask final { | |
|
|
||
| /// Configuration parameters for PeriodicTask. | ||
| struct Settings final { | ||
| struct TimePoint { | ||
| std::uint8_t hour; | ||
| std::uint8_t minute; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. лучше инициализировать нулями, чем оставлять мусорные значения |
||
|
|
||
| bool operator==(const TimePoint& other) const { | ||
| return std::tie(hour, minute) == std::tie(other.hour, other.minute); | ||
| } | ||
| }; | ||
|
|
||
| static constexpr uint8_t kDistributionPercent = 25; | ||
|
|
||
| constexpr /*implicit*/ Settings( | ||
|
|
@@ -91,6 +100,12 @@ class PeriodicTask final { | |
| UASSERT(distribution_percent <= 100); | ||
| } | ||
|
|
||
| constexpr Settings( | ||
| TimePoint time_point, | ||
| logging::Level span_level = logging::Level::kInfo | ||
| ) | ||
| : strong_mode_anchor(time_point), span_level(span_level) {} | ||
|
|
||
| template <class Rep, class Period> | ||
| constexpr /*implicit*/ Settings(std::chrono::duration<Rep, Period> period) | ||
| : Settings(period, kDistributionPercent, {}, logging::Level::kInfo) {} | ||
|
|
@@ -110,6 +125,10 @@ class PeriodicTask final { | |
| /// `(period +/- distribution) - time of previous execution` | ||
| std::chrono::milliseconds distribution{}; | ||
|
|
||
| /// @brief Time point for the task execution. Task is repeated every | ||
| /// hour:minute UTC of the current/next day | ||
| std::optional<TimePoint> strong_mode_anchor; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. как-то костыльненько выглядит |
||
|
|
||
| /// @brief Used instead of `period` in case of exception, if set. | ||
| std::optional<std::chrono::milliseconds> exception_period; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если есть что-то про время, должно быть и про таймзону