diff --git a/libs/server-sdk/include/launchdarkly/server_side/client.hpp b/libs/server-sdk/include/launchdarkly/server_side/client.hpp index 50a9fda72..bc13bf85c 100644 --- a/libs/server-sdk/include/launchdarkly/server_side/client.hpp +++ b/libs/server-sdk/include/launchdarkly/server_side/client.hpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -236,6 +237,13 @@ class IClient { FlagKey const& key, Value default_value) = 0; + /** + * Returns an interface which provides methods for subscribing to data + * source status. + * @return A data source status provider. + */ + virtual data_sources::IDataSourceStatusProvider& DataSourceStatus() = 0; + virtual ~IClient() = default; IClient(IClient const& item) = delete; IClient(IClient&& item) = delete; @@ -320,6 +328,8 @@ class Client : public IClient { FlagKey const& key, Value default_value) override; + data_sources::IDataSourceStatusProvider& DataSourceStatus() override; + /** * Returns the version of the SDK. * @return String representing version of the SDK. diff --git a/libs/server-sdk/src/client.cpp b/libs/server-sdk/src/client.cpp index 4a88b054a..ce992de85 100644 --- a/libs/server-sdk/src/client.cpp +++ b/libs/server-sdk/src/client.cpp @@ -124,6 +124,10 @@ EvaluationDetail Client::JsonVariationDetail(Context const& ctx, return client->JsonVariationDetail(ctx, key, std::move(default_value)); } +data_sources::IDataSourceStatusProvider& Client::DataSourceStatus() { + return client->DataSourceStatus(); +} + char const* Client::Version() { return kVersion; } diff --git a/libs/server-sdk/src/client_impl.cpp b/libs/server-sdk/src/client_impl.cpp index 796bed031..fb049a4aa 100644 --- a/libs/server-sdk/src/client_impl.cpp +++ b/libs/server-sdk/src/client_impl.cpp @@ -110,6 +110,7 @@ ClientImpl::ClientImpl(Config config, std::string const& version) ioc_(kAsioConcurrencyHint), work_(boost::asio::make_work_guard(ioc_)), memory_store_(), + status_manager_(), data_source_(MakeDataSource(http_properties_, config_, ioc_.get_executor(), @@ -441,10 +442,10 @@ Value ClientImpl::JsonVariation(Context const& ctx, return *VariationInternal(ctx, key, default_value, events_default_); } -// data_sources::IDataSourceStatusProvider& ClientImpl::DataSourceStatus() { -// return status_manager_; -// } -// +data_sources::IDataSourceStatusProvider& ClientImpl::DataSourceStatus() { + return status_manager_; +} + // flag_manager::IFlagNotifier& ClientImpl::FlagNotifier() { // return flag_manager_.Notifier(); // } diff --git a/libs/server-sdk/src/client_impl.hpp b/libs/server-sdk/src/client_impl.hpp index 6326ae105..1a357f3b0 100644 --- a/libs/server-sdk/src/client_impl.hpp +++ b/libs/server-sdk/src/client_impl.hpp @@ -106,6 +106,8 @@ class ClientImpl : public IClient { FlagKey const& key, Value default_value) override; + data_sources::IDataSourceStatusProvider& DataSourceStatus() override; + ~ClientImpl(); std::future StartAsync() override; @@ -172,6 +174,8 @@ class ClientImpl : public IClient { data_store::MemoryStore memory_store_; + data_sources::DataSourceStatusManager status_manager_; + std::shared_ptr<::launchdarkly::data_sources::IDataSource> data_source_; std::unique_ptr event_processor_; @@ -179,8 +183,6 @@ class ClientImpl : public IClient { mutable std::mutex init_mutex_; std::condition_variable init_waiter_; - data_sources::DataSourceStatusManager status_manager_; - evaluation::Evaluator evaluator_; EventScope const events_default_;