Skip to content

Commit db55b09

Browse files
committed
refactor: Rename the FDv2 freshness accessors to ReadFreshness and GetTimestamp
1 parent 7668b27 commit db55b09

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

libs/client-sdk/src/flag_manager/context_index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void ContextIndex::Notice(
2424
}
2525

2626
std::optional<std::chrono::time_point<std::chrono::system_clock>>
27-
ContextIndex::TimestampFor(std::string const& id) const {
27+
ContextIndex::GetTimestamp(std::string const& id) const {
2828
for (auto const& entry : index_) {
2929
if (entry.id == id) {
3030
return entry.timestamp;

libs/client-sdk/src/flag_manager/context_index.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ContextIndex {
6363
*/
6464
[[nodiscard]] std::optional<
6565
std::chrono::time_point<std::chrono::system_clock>>
66-
TimestampFor(std::string const& id) const;
66+
GetTimestamp(std::string const& id) const;
6767

6868
/**
6969
* Prune the index returning a list of the removed context keys

libs/client-sdk/src/flag_manager/flag_persistence.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ void FlagPersistence::RecordFreshness(Context const& context) {
136136
}
137137

138138
std::optional<std::chrono::time_point<std::chrono::system_clock>>
139-
FlagPersistence::FreshnessFor(Context const& context) {
139+
FlagPersistence::ReadFreshness(Context const& context) {
140140
if (!persistence_ || !context.Valid()) {
141141
return std::nullopt;
142142
}
143143

144144
std::lock_guard lock(persistence_mutex_);
145-
return ReadIndexAt(freshness_key_).TimestampFor(FreshnessId(context));
145+
return ReadIndexAt(freshness_key_).GetTimestamp(FreshnessId(context));
146146
}
147147

148148
void FlagPersistence::StoreCache(std::string const& context_id) {

libs/client-sdk/src/flag_manager/flag_persistence.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FlagPersistence : public IDataSourceUpdateSink {
7575
*/
7676
[[nodiscard]] std::optional<
7777
std::chrono::time_point<std::chrono::system_clock>>
78-
FreshnessFor(Context const& context);
78+
ReadFreshness(Context const& context);
7979

8080
private:
8181
inline static std::string global_namespace_ = "LaunchDarkly";

libs/client-sdk/tests/flag_persistence_test.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ TEST(FlagPersistenceTests, RecordsFreshnessOnAPayload) {
246246
std::chrono::milliseconds{500}};
247247
});
248248

249-
EXPECT_FALSE(flag_persistence.FreshnessFor(context).has_value());
249+
EXPECT_FALSE(flag_persistence.ReadFreshness(context).has_value());
250250

251251
flag_persistence.Apply(
252252
context,
@@ -262,7 +262,7 @@ TEST(FlagPersistenceTests, RecordsFreshnessOnAPayload) {
262262

263263
EXPECT_EQ(
264264
std::chrono::system_clock::time_point{std::chrono::milliseconds{500}},
265-
flag_persistence.FreshnessFor(context));
265+
flag_persistence.ReadFreshness(context));
266266
}
267267

268268
// A "none" intent is the service confirming the SDK's data is current, which
@@ -287,7 +287,7 @@ TEST(FlagPersistenceTests, RecordsFreshnessOnANoneChangeSet) {
287287

288288
EXPECT_EQ(
289289
std::chrono::system_clock::time_point{std::chrono::milliseconds{700}},
290-
flag_persistence.FreshnessFor(context));
290+
flag_persistence.ReadFreshness(context));
291291
}
292292

293293
// The freshness record is keyed by the whole context, because changing an
@@ -313,8 +313,8 @@ TEST(FlagPersistenceTests, FreshnessIsPerContextAttributeSet) {
313313
FlagChangeSet{ChangeSetType::kNone, {}, Selector{}},
314314
/* from_cache= */ false);
315315

316-
EXPECT_TRUE(flag_persistence.FreshnessFor(plain).has_value());
317-
EXPECT_FALSE(flag_persistence.FreshnessFor(with_attribute).has_value());
316+
EXPECT_TRUE(flag_persistence.ReadFreshness(plain).has_value());
317+
EXPECT_FALSE(flag_persistence.ReadFreshness(with_attribute).has_value());
318318
}
319319

320320
// A stored context that has aged out of the cache should not keep a freshness
@@ -342,10 +342,10 @@ TEST(FlagPersistenceTests, PrunesFreshnessBeyondMaxContexts) {
342342
now++;
343343
}
344344

345-
EXPECT_FALSE(flag_persistence.FreshnessFor(first).has_value());
345+
EXPECT_FALSE(flag_persistence.ReadFreshness(first).has_value());
346346
EXPECT_TRUE(
347347
flag_persistence
348-
.FreshnessFor(ContextBuilder().Kind("user", "third").Build())
348+
.ReadFreshness(ContextBuilder().Kind("user", "third").Build())
349349
.has_value());
350350
}
351351

@@ -378,7 +378,7 @@ TEST(FlagPersistenceTests, ApplyFromCacheDoesNotWriteTheCache) {
378378
// Nothing is written back.
379379
EXPECT_TRUE(persistence->store_.empty());
380380
// Nor was it confirmed current by the service, so it is not freshness.
381-
EXPECT_FALSE(flag_persistence.FreshnessFor(context).has_value());
381+
EXPECT_FALSE(flag_persistence.ReadFreshness(context).has_value());
382382
// The data is still applied to the store, so evaluation can use it.
383383
ASSERT_TRUE(store.Get("flagA"));
384384
}

0 commit comments

Comments
 (0)