Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions contract-tests/server-contract-tests/src/entity_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "entity_manager.hpp"

Check failure on line 1 in contract-tests/server-contract-tests/src/entity_manager.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

contract-tests/server-contract-tests/src/entity_manager.cpp:1:10 [clang-diagnostic-error]

'entity_manager.hpp' file not found
#include "contract_test_big_segment_store.hpp"
#include "contract_test_hook.hpp"

Expand Down Expand Up @@ -147,9 +147,8 @@
if (cfg.fdv1Fallback->baseUri) {
endpoints->PollingBaseUrl(*cfg.fdv1Fallback->baseUri);
} else if (cfg.synchronizers && !cfg.synchronizers->empty()) {
// No explicit baseUri: derive from the synchronizers list, matching
// the no-fdv1Fallback branch below.
// No explicit baseUri: derive from the synchronizers list.
ConfigDataSynchronizerParams const* selected = nullptr;

Check warning on line 151 in contract-tests/server-contract-tests/src/entity_manager.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

contract-tests/server-contract-tests/src/entity_manager.cpp:151:49 [cppcoreguidelines-init-variables]

variable 'selected' is not initialized
for (auto const& sync : *cfg.synchronizers) {
if (sync.polling) {
selected = &sync;
Expand All @@ -165,42 +164,12 @@
endpoints->PollingBaseUrl(*selected->streaming->baseUri);
}
}
FDv2Builder::FDv1Polling p;

Check warning on line 167 in contract-tests/server-contract-tests/src/entity_manager.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

contract-tests/server-contract-tests/src/entity_manager.cpp:167:34 [cppcoreguidelines-init-variables]

variable 'p' is not initialized
if (cfg.fdv1Fallback->pollIntervalMs) {
p.PollInterval(std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::milliseconds(*cfg.fdv1Fallback->pollIntervalMs)));
}
fdv2.FDv1Fallback(std::move(p));
} else if (cfg.synchronizers && !cfg.synchronizers->empty()) {
// Derive an FDv1 fallback from the synchronizers list: prefer the
// first polling sync, otherwise reuse the first synchronizer's
// baseUri. The fallback is always polling. The fallback reads its
// URL from the global ServiceEndpoints, so set the polling endpoint
// to the selected baseUri.
ConfigDataSynchronizerParams const* selected = nullptr;
for (auto const& sync : *cfg.synchronizers) {
if (sync.polling) {
selected = &sync;
break;
}
}
if (!selected) {
selected = &cfg.synchronizers->front();
}
FDv2Builder::FDv1Polling p;
if (selected->polling) {
if (selected->polling->baseUri) {
endpoints->PollingBaseUrl(*selected->polling->baseUri);
}
if (selected->polling->pollIntervalMs) {
p.PollInterval(std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::milliseconds(
*selected->polling->pollIntervalMs)));
}
} else if (selected->streaming && selected->streaming->baseUri) {
endpoints->PollingBaseUrl(*selected->streaming->baseUri);
}
fdv2.FDv1Fallback(std::move(p));
}

return fdv2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# C++ implements TTL-based FDv1 fallback; this scenario tests the older terminal semantics. Tracked in SDK-2527.
# The SDK still retries streaming after HTTP 500 with an FDv1 directive and no fallback.
streaming/fdv2/FDv1 fallback directive/directive without FDv1 fallback configured halts the data system

# FDv2 public payload filter API is not exposed by the C++ SDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@
.Initializer(Polling{})
.Synchronizer(Streaming{})
.Synchronizer(Polling{})
.FDv1Fallback(FDv1Streaming{});
.FDv1Fallback(FDv1Polling{});
}

FDv2Builder FDv2Builder::Custom() {
return FDv2Builder();

Check warning on line 53 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:53:12 [modernize-return-braced-init-list]

avoid repeating the return type from the declaration; use a braced initializer list instead
}

FDv2Builder& FDv2Builder::Initializer(Polling source) {

Check warning on line 56 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:56:47 [performance-unnecessary-value-param]

the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference
config_.initializers.push_back(source.Build());
return *this;
}

FDv2Builder& FDv2Builder::Synchronizer(Streaming source) {

Check warning on line 61 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:61:50 [performance-unnecessary-value-param]

the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference
config_.synchronizers.push_back(source.Build());

Check warning on line 62 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:62:27 [modernize-use-emplace]

use emplace_back instead of push_back
return *this;
}

FDv2Builder& FDv2Builder::Synchronizer(Polling source) {

Check warning on line 66 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:66:48 [performance-unnecessary-value-param]

the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference
config_.synchronizers.push_back(source.Build());

Check warning on line 67 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:67:27 [modernize-use-emplace]

use emplace_back instead of push_back
return *this;
}

FDv2Builder& FDv2Builder::FDv1Fallback(FDv1Streaming source) {

Check warning on line 71 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:71:54 [performance-unnecessary-value-param]

the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference
config_.fdv1_fallback = source.Build();
return *this;
}

FDv2Builder& FDv2Builder::FDv1Fallback(FDv1Polling source) {

Check warning on line 76 in libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

libs/server-sdk/src/config/builders/data_system/fdv2_builder.cpp:76:52 [performance-unnecessary-value-param]

the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference
config_.fdv1_fallback = source.Build();
return *this;
}
Expand Down
34 changes: 30 additions & 4 deletions libs/server-sdk/tests/config_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,42 @@ TEST_F(ConfigBuilderTest, FDv2_DefaultsAreUsed) {
fdv2_config.synchronizers[1]));

ASSERT_TRUE(fdv2_config.fdv1_fallback.has_value());
ASSERT_TRUE(std::holds_alternative<built::FDv2Config::FDv1StreamingConfig>(
ASSERT_TRUE(std::holds_alternative<built::FDv2Config::FDv1PollingConfig>(
*fdv2_config.fdv1_fallback));
EXPECT_EQ(std::get<built::FDv2Config::FDv1StreamingConfig>(
*fdv2_config.fdv1_fallback),
EXPECT_EQ(std::get<built::FDv2Config::FDv1PollingConfig>(
*fdv2_config.fdv1_fallback)
.poll_interval,
launchdarkly::config::shared::Defaults<
launchdarkly::config::shared::ServerSDK>::StreamingConfig());
launchdarkly::config::shared::ServerSDK>::PollingConfig()
.poll_interval);
EXPECT_EQ(fdv2_config.fallback_timeout, std::chrono::minutes{2});
EXPECT_EQ(fdv2_config.recovery_timeout, std::chrono::minutes{5});
}

TEST_F(ConfigBuilderTest, FDv2_CustomHasNoFDv1Fallback) {
auto const config = builders::FDv2Builder::Custom().Build();

EXPECT_FALSE(config.fdv1_fallback.has_value());
}

TEST_F(ConfigBuilderTest, FDv2_DefaultFDv1FallbackCanBeDisabled) {
auto const config =
builders::FDv2Builder::Default().DisableFDv1Fallback().Build();

EXPECT_FALSE(config.fdv1_fallback.has_value());
}

TEST_F(ConfigBuilderTest, FDv2_DefaultFDv1FallbackCanBeReplacedWithStreaming) {
auto const config =
builders::FDv2Builder::Default()
.FDv1Fallback(builders::FDv2Builder::FDv1Streaming())
.Build();

ASSERT_TRUE(config.fdv1_fallback.has_value());
EXPECT_TRUE(std::holds_alternative<built::FDv2Config::FDv1StreamingConfig>(
*config.fdv1_fallback));
}

TEST_F(ConfigBuilderTest, FDv2_FDv1FallbackPolling) {
ConfigBuilder builder("sdk-123");
builder.DataSystem().Method(
Expand Down
Loading