Skip to content

Commit

Permalink
feat: add DataSourceStatus() and plumb through IClient interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Aug 28, 2023
1 parent 9ec37f6 commit 3794ea7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
10 changes: 10 additions & 0 deletions libs/server-sdk/include/launchdarkly/server_side/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <launchdarkly/value.hpp>

#include <launchdarkly/server_side/all_flags_state.hpp>
#include <launchdarkly/server_side/data_source_status.hpp>

#include <chrono>
#include <future>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions libs/server-sdk/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ EvaluationDetail<Value> 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;
}
Expand Down
9 changes: 5 additions & 4 deletions libs/server-sdk/src/client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ClientImpl::ClientImpl(Config config, std::string const& version)
ioc_(kAsioConcurrencyHint),
work_(boost::asio::make_work_guard(ioc_)),
memory_store_(),

Check warning on line 112 in libs/server-sdk/src/client_impl.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/libs/server-sdk/src/client_impl.cpp:112:7 [readability-redundant-member-init]

initializer for member 'memory_store_' is redundant
status_manager_(),

Check warning on line 113 in libs/server-sdk/src/client_impl.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/libs/server-sdk/src/client_impl.cpp:113:7 [readability-redundant-member-init]

initializer for member 'status_manager_' is redundant
data_source_(MakeDataSource(http_properties_,
config_,
ioc_.get_executor(),
Expand Down Expand Up @@ -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();
// }
Expand Down
6 changes: 4 additions & 2 deletions libs/server-sdk/src/client_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class ClientImpl : public IClient {
FlagKey const& key,
Value default_value) override;

data_sources::IDataSourceStatusProvider& DataSourceStatus() override;

~ClientImpl();

std::future<bool> StartAsync() override;
Expand Down Expand Up @@ -172,15 +174,15 @@ 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<events::IEventProcessor> event_processor_;

mutable std::mutex init_mutex_;
std::condition_variable init_waiter_;

data_sources::DataSourceStatusManager status_manager_;

evaluation::Evaluator evaluator_;

EventScope const events_default_;
Expand Down

0 comments on commit 3794ea7

Please sign in to comment.