-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Implement polling data source. #177
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
feat: Implement polling data source. #177
Conversation
…dks-private into rlamb/data-store-arch
…arkly/cpp-sdks-private into rlamb/basic-store-implementation
| return DataSourceEventHandler::MessageStatus::kInvalidMessage; | ||
| } | ||
| if (type == "patch") { | ||
| return DataSourceEventHandler::MessageStatus::kInvalidMessage; |
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.
These will be implemented during the streaming implementation.
| /** | ||
| * Represents a flag patch JSON from the LaunchDarkly service. | ||
| */ | ||
| struct FlagPatch { |
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.
This may end up being one struct, but I just put them in as placeholders. If they are two types, then the handler will use the overloads, which will be nice.
| boost::json::value_to_tag<tl::expected<DataSourceEventHandler::DeleteData, | ||
| JsonError>> const& unused, | ||
| boost::json::value const& json_value) { | ||
| boost::ignore_unused(unused); |
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.
Will look at cleaning this up potentially when streaming is implemented. Currently it is a copy/paste.
| @@ -0,0 +1,207 @@ | |||
| #include <boost/json.hpp> | |||
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.
I've reduced duplication in lots of other places, but not here. Not confident in the value as of yet, but refactoring it would be internal.
| std::chrono::system_clock::to_time_t(status.StateSince()); | ||
| out << "Status(" << status.State() << ", Since(" | ||
| << std::put_time(std::gmtime(&as_time_t), "%Y-%m-%d %H:%M:%S") << ")"; | ||
| if (status.LastError()) { |
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.
Dear linter, this is a check of the optional.
| status_manager_.SetState( | ||
| DataSourceStatus::DataSourceState::kInterrupted, | ||
| DataSourceStatus::ErrorInfo::ErrorKind::kNetworkError, | ||
| res.ErrorMessage() ? *res.ErrorMessage() : "unknown error"); |
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.
Linter, checked literally on the same line.
| status_manager_.SetState( | ||
| DataSourceStatus::DataSourceState::kInterrupted, | ||
| DataSourceStatus::ErrorInfo::ErrorKind::kNetworkError, | ||
| res.ErrorMessage().has_value() ? *res.ErrorMessage() |
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.
So, I am adding has_value checks to these. Even though it has a boolean operator the linter doesn't get it, and I am not super font of all the messages.
| << "Polling for feature flag updates failed: " | ||
| << (res.ErrorMessage().has_value() ? *res.ErrorMessage() | ||
| : "unknown error"); | ||
| } else if (res.Status() == 200) { |
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.
The linter was complaining about the magic numbers, but this time it magically didn't. There is some kind of consistency issue.
|
|
||
| timer_.cancel(); | ||
| timer_.expires_after(polling_interval_); | ||
| timer_.expires_after(delay); |
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.
Made a PR against main for this fix.
| namespace launchdarkly::server_side::data_sources { | ||
|
|
||
| class DataSourceStatusManager | ||
| : public internal::data_sources::DataSourceStatusManagerBase< |
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.
Make a data source status manager for X type of status which inherits from Y interface.
|
superseded by: #179 |
No description provided.