-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Implement streaming data source. #179
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 streaming data source. #179
Conversation
…dks-private into rlamb/data-store-arch
…arkly/cpp-sdks-private into rlamb/basic-store-implementation
| } | ||
| return DataSourceEventHandler::Patch{ | ||
| TStreamingDataKind::Key(path), | ||
| data_model::ItemDescriptor<TData>(data->value())}; |
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 wish this lint worked, because it would be useful, but it is basically always wrong. Checked on line 41.
2ca520e to
77de4fd
Compare
| return; | ||
| } | ||
|
|
||
| // TODO: Initial reconnect delay. sc-204393 |
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.
Likely this should still be addressed as an independent change, but maybe this ticket should be pulled into the epic.
I think that the SSE client currently has a hardcoded value and it just needs to expose a value for building instead, and then we can use that value.
| if (auto self = weak_self.lock()) { | ||
| self->data_source_handler_.HandleMessage(event.type(), | ||
| event.data()); | ||
| // TODO: Use the result of handle message to restart the |
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 am not sure how to handle this in the current pattern. I think we went with re-creating instead of restarting. So it will require extracting out the build of the client, then closing and re-creating the client.
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.
Another thought is have the callback return a bool/status that tells the eventsource to reconnect. Then we don't have to rebuild it and can keep the async stuff hidden there.
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.
That sounds more pleasant.
libs/internal/include/launchdarkly/data_sources/data_source_status_manager_base.hpp
Outdated
Show resolved
Hide resolved
libs/internal/include/launchdarkly/data_sources/data_source_status_manager_base.hpp
Outdated
Show resolved
Hide resolved
| PARSE_FIELD(path, obj, "path"); | ||
|
|
||
| if (StreamingDataKinds::Flag::IsKind(path)) { | ||
| return Patch<StreamingDataKinds::Flag, data_model::Flag>(path, obj); |
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.
Very elegant.
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 spent an inordinate amount of time on template shenanigans. Ultimately it is pretty pleasant though,
| LD_LOG(logger_, LogLevel::kWarn) | ||
| << "Polling for feature flag updates failed: " | ||
| << (error_message.has_value() ? *error_message : "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.
Kinda wish we could use the beast error codes here. Maybe we can, they might just be the numeric values of the status codes or have a getter for it.
| if (auto self = weak_self.lock()) { | ||
| self->data_source_handler_.HandleMessage(event.type(), | ||
| event.data()); | ||
| // TODO: Use the result of handle message to restart the |
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.
Another thought is have the callback return a bool/status that tells the eventsource to reconnect. Then we don't have to rebuild it and can keep the async stuff hidden there.
…atus_manager_base.hpp Co-authored-by: Casey Waldren <cwaldren@launchdarkly.com>
Co-authored-by: Casey Waldren <cwaldren@launchdarkly.com>
Co-authored-by: Casey Waldren <cwaldren@launchdarkly.com>
Co-authored-by: Casey Waldren <cwaldren@launchdarkly.com>
|
|
||
| #include <launchdarkly/encoding/base_64.hpp> | ||
| #include <launchdarkly/serialization/json_flag.hpp> | ||
| // #include <launchdarkly/serialization/json_primitives.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.
remove
No description provided.