Skip to content

Commit d2efff5

Browse files
Bernd Warmuthwarber
authored andcommitted
feat: stop using flag store for connection events
Signed-off-by: Bernd Warmuth <bernd.warmuth@dynatrace.com>
1 parent ae99a94 commit d2efff5

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/InProcessResolver.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import dev.openfeature.contrib.providers.flagd.resolver.process.model.FeatureFlag;
1111
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.FlagStore;
1212
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.Storage;
13+
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.StorageState;
1314
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.StorageStateChange;
1415
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.connector.Connector;
1516
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.connector.file.FileConnector;
@@ -79,20 +80,15 @@ public void init() throws Exception {
7980
while (true) {
8081
final StorageStateChange storageStateChange =
8182
flagStore.getStateQueue().take();
82-
switch (storageStateChange.getStorageState()) {
83-
case OK:
84-
onConnectionEvent.accept(new ConnectionEvent(
85-
ConnectionState.CONNECTED,
86-
storageStateChange.getChangedFlagsKeys(),
87-
storageStateChange.getSyncMetadata()));
88-
break;
89-
case ERROR:
90-
onConnectionEvent.accept(new ConnectionEvent(false));
91-
break;
92-
default:
93-
log.info(String.format(
94-
"Storage emitted unhandled status: %s", storageStateChange.getStorageState()));
83+
if (storageStateChange.getStorageState() != StorageState.OK) {
84+
log.info(
85+
String.format("Storage returned NOK status: %s", storageStateChange.getStorageState()));
86+
continue;
9587
}
88+
onConnectionEvent.accept(new ConnectionEvent(
89+
ConnectionState.CONNECTED,
90+
storageStateChange.getChangedFlagsKeys(),
91+
storageStateChange.getSyncMetadata()));
9692
}
9793
} catch (InterruptedException e) {
9894
log.warn("Storage state watcher interrupted", e);

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/InProcessResolverTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ public void eventHandling() throws Throwable {
114114
assertEquals(StorageState.OK, storageState.getStorageState());
115115
assertEquals(val, storageState.getSyncMetadata().getValue(key).asString());
116116
});
117-
118-
assertTimeoutPreemptively(Duration.ofMillis(200), () -> {
119-
assertEquals(StorageState.ERROR, receiver.take().getStorageState());
120-
});
121117
}
122118

123119
@Test

0 commit comments

Comments
 (0)