Skip to content

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Feb 3, 2026

Note

Medium Risk
Touches core FDv2 data-source result consumption and introduces new callback/lifecycle semantics that could affect threading or resource cleanup if misused; behavior is covered with new integration tests but remains concurrency-sensitive.

Overview
Adds consumption completion reporting for FDv2 results by making FDv2SourceResult Closeable, adding an optional completion callback plus withCompletion(), and updating FDv2DataSource to use try-with-resources when handling initializer/synchronizer results so callbacks reliably fire.

Refactors TestDataV2 to use this mechanism (wrapping results with per-synchronizer completions, switching its internal queueing to IterableAsyncQueue, and removing the old polling-based awaitPropagation helper), and adds TestDataV2WithClientTest to assert initialization, flag updates/deletes, rule/target behavior, status updates, and multi-client propagation.

Written by Cursor Bugbot for commit 08f24e2. This will update automatically on new commits. Configure here.

private final Object queueLock = new Object();
private final LinkedList<FDv2SourceResult> queue = new LinkedList<>();
private final LinkedList<CompletableFuture<FDv2SourceResult>> pendingFutures = new LinkedList<>();
private final IterableAsyncQueue<FDv2SourceResult> resultQueue = new IterableAsyncQueue<>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior here ends up not really queuing, but it makes the implementation simple.

future.complete(FDv2SourceResult.shutdown());
}
return CompletableFuture.anyOf(shutdownFuture, future).thenApply(r -> (FDv2SourceResult) r);
if (!initialSent.getAndSet(true)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the need for the lock, and this just needs to be basically a latch.

private final LinkedList<CompletableFuture<FDv2SourceResult>> pendingFutures = new LinkedList<>();
private final IterableAsyncQueue<FDv2SourceResult> resultQueue = new IterableAsyncQueue<>();
private final CompletableFuture<FDv2SourceResult> shutdownFuture = new CompletableFuture<>();
private volatile boolean closed;
Copy link
Member Author

@kinyoklion kinyoklion Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed closed because I don't see a real need for it. It is a bit of an optimization, but this isn't very high frequency, so it seems nice to just be simple.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be identical to the FDv1 tests, but using the FDv2 version.

@kinyoklion
Copy link
Member Author

bugbot review

@kinyoklion kinyoklion force-pushed the rlamb/completable-results branch from 08f24e2 to a26dc8c Compare February 4, 2026 00:04
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants