feat(#92): add Future::awaitAll/onReady and range read-ahead - #109
Closed
s2x wants to merge 1 commit into
Closed
Conversation
- Future::awaitAll() resolves N futures issued up front with ~1 round trip of total latency; Future::onReady() registers a PHP-thread completion hook - fdb_future_set_callback stays deliberately unbound (callbacks fire on the FDB network thread where PHP is unsafe) - RangeResult::paginate() now issues the next chunk request before yielding the current chunk (read-ahead), without ever fetching past an explicit limit; new KvResultFuture contract keeps pagination testable - docs/advanced.md: 'Group Awaits and Completion Hooks' section - unit tests (stub lib) + integration tests against a live cluster
6 tasks
Member
Author
|
Closing as superseded by #111 — the same functionality (Future::awaitAll()/onReady(), RangeResult read-ahead, KvResultFuture, unit/integration tests, docs and CHANGELOG entries) was already squash-merged to master in commit df4e86e. No additional commits on this branch; nothing here is lost. Remaining follow-ups from #92 stay on the issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #92
Implements the first, self-contained slice of #92 (per the issue's own note that read-ahead + group await deliver most of the practical win without the callback binding):
Added
Future::awaitAll(array $futures): array— resolves a batch of futures that were all issued up front. Since every future is already in flight, awaiting them in order costs roughly one round trip of total latency, not N.Future::onReady(callable $fn): void— PHP-thread completion hook (runs immediately for a ready future, otherwise blocks then invokes).fdb_future_set_callback— its callback fires on the FDB network thread, where executing PHP is unsafe (same reasoning as the existingNativeClient::onNetworkThreadCompletion). Documented indocs/advanced.md.Changed
RangeResult::paginate()now issues the request for the next chunk before yielding any item of the current chunk (read-ahead, mirroring Java'sAsyncIterable). Read-ahead never fetches past an explicitlimit; iteration order, dedup guarantees and pagination semantics are unchanged.KvResultFutureinterface (implemented byFutureKeyValueArray) describes the pagination contract and keepspaginate()unit-testable without a cluster.Tests
tests/Unit/FutureAwaitAllTest.php— stub-lib unit tests forawaitAll()/onReady()(ready & not-ready paths, empty batch, non-Future rejection).tests/Unit/RangeResultTest.php— new tests proving the next-chunk request is issued before the first item of the current chunk is consumed, and that no page beyond thelimitis requested.tests/Integration/FutureAwaitAllIntegrationTest.php— live-cluster coverage: 50 parallel reads resolved viaawaitAll(), mixed future types resolved in order.Docs & changelog
docs/advanced.md: new "Group Awaits and Completion Hooks" section (async model and its limits).CHANGELOG.md: entries under Unreleased → Added, referencing Add non-blocking future support (fdb_future_set_callback, awaitAll, range read-ahead) #92.CI:
composer lint(PHPCS + Rector dry-run + PHPStan level 9) andcomposer test(unit + integration against a 5-node Docker FDB cluster) are clean locally.Remaining from #92 (not in this PR): Fiber-aware await and any eventual safe callback binding — these stay as follow-up work on the issue.