Skip to content

Commit

Permalink
feat: stop using flag store for connection events
Browse files Browse the repository at this point in the history
Signed-off-by: Bernd Warmuth <[email protected]>
  • Loading branch information
Bernd Warmuth committed Jan 13, 2025
1 parent 5648059 commit fc1dc9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dev.openfeature.contrib.providers.flagd.resolver.process.model.FeatureFlag;
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.FlagStore;
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.Storage;
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.StorageState;
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.StorageStateChange;
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.connector.Connector;
import dev.openfeature.contrib.providers.flagd.resolver.process.storage.connector.file.FileConnector;
Expand Down Expand Up @@ -79,20 +80,15 @@ public void init() throws Exception {
while (true) {
final StorageStateChange storageStateChange =
flagStore.getStateQueue().take();
switch (storageStateChange.getStorageState()) {
case OK:
onConnectionEvent.accept(new ConnectionEvent(
ConnectionState.CONNECTED,
storageStateChange.getChangedFlagsKeys(),
storageStateChange.getSyncMetadata()));
break;
case ERROR:
onConnectionEvent.accept(new ConnectionEvent(false));
break;
default:
log.info(String.format(
"Storage emitted unhandled status: %s", storageStateChange.getStorageState()));
if (storageStateChange.getStorageState() != StorageState.OK) {
log.info(
String.format("Storage returned NOK status: %s", storageStateChange.getStorageState()));
continue;
}
onConnectionEvent.accept(new ConnectionEvent(
ConnectionState.CONNECTED,
storageStateChange.getChangedFlagsKeys(),
storageStateChange.getSyncMetadata()));
}
} catch (InterruptedException e) {
log.warn("Storage state watcher interrupted", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ public void eventHandling() throws Throwable {
assertEquals(StorageState.OK, storageState.getStorageState());
assertEquals(val, storageState.getSyncMetadata().getValue(key).asString());
});

assertTimeoutPreemptively(Duration.ofMillis(200), () -> {
assertEquals(StorageState.ERROR, receiver.take().getStorageState());
});
}

@Test
Expand Down

0 comments on commit fc1dc9a

Please sign in to comment.