Skip to content

Conversation

@kinyoklion
Copy link
Member

No description provided.

kinyoklion added 30 commits July 6, 2023 14:11
…arkly/cpp-sdks-private into rlamb/basic-store-implementation
return DataSourceEventHandler::MessageStatus::kInvalidMessage;
}
if (type == "patch") {
return DataSourceEventHandler::MessageStatus::kInvalidMessage;
Copy link
Member Author

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 {
Copy link
Member Author

@kinyoklion kinyoklion Jul 13, 2023

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);
Copy link
Member Author

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>
Copy link
Member Author

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()) {
Copy link
Member Author

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");
Copy link
Member Author

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()
Copy link
Member Author

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) {
Copy link
Member Author

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.

@kinyoklion kinyoklion marked this pull request as ready for review July 13, 2023 17:02
@kinyoklion kinyoklion requested a review from a team July 13, 2023 17:02

timer_.cancel();
timer_.expires_after(polling_interval_);
timer_.expires_after(delay);
Copy link
Member Author

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<
Copy link
Member Author

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.

@kinyoklion
Copy link
Member Author

superseded by: #179

@kinyoklion kinyoklion closed this Jul 14, 2023
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.

2 participants