Use a memoizing supplier instead of a looping thread to cache remote config entries

This commit is contained in:
Jon Chambers authored and Chris Eager committed 2021-11-30 16:35:42 -07:00
1 parent d89b4f7e95
commit 048e17c62b
3 files changed
+10 -63

No files matched your search

@@ -29,21 +29,18 @@ public class RemoteConfigsManagerTest {
@Before
public void setup() {
RemoteConfigs remoteConfigs = new RemoteConfigs(new FaultTolerantDatabase("remote_configs-test", Jdbi.create(db.getTestDatabase()), new CircuitBreakerConfiguration()));
this.remoteConfigs = new RemoteConfigsManager(remoteConfigs, 500);
this.remoteConfigs.start();
this.remoteConfigs = new RemoteConfigsManager(new RemoteConfigs(
new FaultTolerantDatabase("remote_configs-test", Jdbi.create(db.getTestDatabase()), new CircuitBreakerConfiguration())));
}
@Test
public void testUpdate() throws InterruptedException {
public void testUpdate() {
remoteConfigs.set(new RemoteConfig("android.stickers", 50, Set.of(AuthHelper.VALID_UUID), "FALSE", "TRUE", null));
remoteConfigs.set(new RemoteConfig("value.sometimes", 50, Set.of(), "bar", "baz", null));
remoteConfigs.set(new RemoteConfig("ios.stickers", 50, Set.of(), "FALSE", "TRUE", null));
remoteConfigs.set(new RemoteConfig("ios.stickers", 75, Set.of(), "FALSE", "TRUE", null));
remoteConfigs.set(new RemoteConfig("value.sometimes", 25, Set.of(AuthHelper.VALID_UUID), "abc", "def", null));
remoteConfigs.waitForCacheRefresh();
List<RemoteConfig> results = remoteConfigs.getAll();
assertThat(results.size()).isEqualTo(3);