Skip to content

Commit a6ffcae

Browse files
committed
feat: derive FDv1 fallback synchronizer from harness synchronizers
1 parent 6074215 commit a6ffcae

2 files changed

Lines changed: 37 additions & 22 deletions

File tree

contract-tests/server-contract-tests/src/entity_manager.cpp

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ using namespace launchdarkly::server_side;
1313
namespace {
1414

1515
config::builders::DataSystemBuilder::FDv2 BuildFDv2(
16-
ConfigDataSystemParams const& cfg) {
16+
ConfigDataSystemParams const& cfg,
17+
config::builders::EndpointsBuilder* endpoints) {
1718
auto fdv2 = config::builders::DataSystemBuilder::FDv2();
1819

1920
if (cfg.synchronizers) {
@@ -65,16 +66,47 @@ config::builders::DataSystemBuilder::FDv2 BuildFDv2(
6566
}
6667
}
6768

69+
using FDv2Builder = config::builders::DataSystemBuilder::FDv2;
6870
if (cfg.fdv1Fallback) {
69-
auto p = decltype(fdv2)::Polling();
7071
if (cfg.fdv1Fallback->baseUri) {
71-
p.BaseUrl(*cfg.fdv1Fallback->baseUri);
72+
endpoints->PollingBaseUrl(*cfg.fdv1Fallback->baseUri);
7273
}
74+
FDv2Builder::FDv1Polling p;
7375
if (cfg.fdv1Fallback->pollIntervalMs) {
7476
p.PollInterval(std::chrono::duration_cast<std::chrono::seconds>(
7577
std::chrono::milliseconds(*cfg.fdv1Fallback->pollIntervalMs)));
7678
}
7779
fdv2.FDv1Fallback(std::move(p));
80+
} else if (cfg.synchronizers && !cfg.synchronizers->empty()) {
81+
// Derive an FDv1 fallback from the synchronizers list: prefer the
82+
// first polling sync, otherwise reuse the first synchronizer's
83+
// baseUri. The fallback is always polling. The fallback reads its
84+
// URL from the global ServiceEndpoints, so set the polling endpoint
85+
// to the selected baseUri.
86+
ConfigDataSynchronizerParams const* selected = nullptr;
87+
for (auto const& sync : *cfg.synchronizers) {
88+
if (sync.polling) {
89+
selected = &sync;
90+
break;
91+
}
92+
}
93+
if (!selected) {
94+
selected = &cfg.synchronizers->front();
95+
}
96+
FDv2Builder::FDv1Polling p;
97+
if (selected->polling) {
98+
if (selected->polling->baseUri) {
99+
endpoints->PollingBaseUrl(*selected->polling->baseUri);
100+
}
101+
if (selected->polling->pollIntervalMs) {
102+
p.PollInterval(std::chrono::duration_cast<std::chrono::seconds>(
103+
std::chrono::milliseconds(
104+
*selected->polling->pollIntervalMs)));
105+
}
106+
} else if (selected->streaming && selected->streaming->baseUri) {
107+
endpoints->PollingBaseUrl(*selected->streaming->baseUri);
108+
}
109+
fdv2.FDv1Fallback(std::move(p));
78110
}
79111

80112
return fdv2;
@@ -163,7 +195,8 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {
163195
}
164196

165197
if (in.dataSystem) {
166-
config_builder.DataSystem().Method(BuildFDv2(*in.dataSystem));
198+
config_builder.DataSystem().Method(
199+
BuildFDv2(*in.dataSystem, &endpoints));
167200
} else {
168201
config_builder.DataSystem().Method(BuildBackgroundSync(in, &endpoints));
169202
}
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
events/summary events/flag versions
2-
streaming/requests/URL path is computed correctly/environment_filter_key="encoding necessary +! %& ( )"/base URI has no trailing slash/GET
3-
streaming/requests/URL path is computed correctly/environment_filter_key="encoding necessary +! %& ( )"/base URI has a trailing slash/GET
4-
streaming/validation/drop and reconnect if stream event has malformed JSON/server-intent event
5-
streaming/validation/drop and reconnect if stream event has well-formed JSON not matching schema/server-intent event
6-
streaming/validation/unrecognized data that can be safely ignored/unknown event name with JSON body
7-
streaming/validation/unrecognized data that can be safely ignored/unknown event name with non-JSON body
8-
streaming/validation/unrecognized data that can be safely ignored/patch event with unrecognized path kind
9-
streaming/fdv2/updates are not complete until payload transferred is sent
10-
streaming/fdv2/handles multiple updates
11-
streaming/fdv2/ignores model version
12-
streaming/fdv2/ignores heart beat
13-
streaming/fdv2/can discard partial events on errors
14-
streaming/fdv2/fallback to FDv1 handling
15-
polling/requests/URL path is computed correctly/no environment filter/base URI has a trailing slash/GET
16-
polling/requests/URL path is computed correctly/environment_filter_key="encoding_not_necessary"/base URI has a trailing slash/GET
17-
polling/requests/URL path is computed correctly/environment_filter_key="encoding necessary +! %& ( )"/base URI has no trailing slash/GET
18-
polling/requests/URL path is computed correctly/environment_filter_key="encoding necessary +! %& ( )"/base URI has a trailing slash/GET

0 commit comments

Comments
 (0)