GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add dispatch strategy, implement bfs strategy by zsmoore · Pull Request #261 · graphql-java/java-dataloader Conversation
|
|
Note to self to follow up on - I believe thinking on this again this may be a greedy level by level traversal rather than true BFS. I will come back to this and add a more complicated test to replicate the example I have to verify if async are waited on a level basis or we continue dispatching to child levels when work is known and only wait if we are blocked on just async calls |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces a dispatch strategy framework for DataLoaders, allowing custom control over when and how DataLoader batches are dispatched. The primary implementation is a breadth-first search (BFS) dispatch strategy that handles synchronous and asynchronous chained DataLoaders by dispatching level-by-level with a fallback mechanism for async operations.
DispatchStrategy interface with lifecycle hooks (onRegistryCreation, loadCalled, loadCompleted)BreadthFirstChainedDispatchStrategy with automatic BFS dispatching and scheduled fallback for async scenariosDataLoaderRegistry and DataLoaderOptions for configurationCopilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.
| File | Description |
|---|---|
| src/main/java/org/dataloader/DispatchStrategy.java | New public API interface defining dispatch strategy lifecycle methods with a NO_OP default implementation |
| src/main/java/org/dataloader/strategy/BreadthFirstChainedDispatchStrategy.java | New BFS strategy implementation with fallback dispatch mechanism for async chained loaders |
| src/main/java/org/dataloader/DataLoaderRegistry.java | Integrates dispatch strategy into registry builder, applies strategy to all registered DataLoaders |
| src/main/java/org/dataloader/DataLoaderOptions.java | Adds dispatch strategy field and builder methods to options |
| src/main/java/org/dataloader/DataLoaderHelper.java | Calls dispatch strategy lifecycle hooks when loads are initiated and completed |
| src/main/java/org/dataloader/registries/ScheduledDataLoaderRegistry.java | Updates to use NO_OP dispatch strategy (maintains existing behavior) |
| src/test/java/org/dataloader/strategy/BreadthFirstChainedDispatchStrategyTest.java | Comprehensive test suite covering single-depth, chained, async, and level-by-level dispatch scenarios |
| src/test/java/org/dataloader/DataLoaderCacheMapTest.java | Updates expected dependent counts to account for dispatch strategy hooks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…taloader into zmoore/dispatch-strategy
…tchStrategy.java Co-authored-by: Copilot <[email protected]>
…taloader into zmoore/dispatch-strategy
…tchStrategy.java Co-authored-by: Copilot <[email protected]>
…taloader into zmoore/dispatch-strategy
Wrote out a fairly complicated test in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@andimarek This one should be about ready. Let me know what you think when you're available to review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am happy with this PR - modulo the question on whenComplete ordering
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
ps the test are failing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I fixed that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@zsmoore @bbakerman I changed the strategy callback a bit to ensure it is always called before the load itself is returned. @zsmoore the stress test is failing now (not sure if that was the result of my change, it could be). I will continue to review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@zsmoore some questions, clarifications: In your test your "chained dataloader" is actually a few DataLoader.load calls in parallel. What we refer normally to as chained dataloader is dl1.load(key1).compose(result1 -> var key2 <based on result1)>; return dl2.load(key2)) In We also have a In your test This is again a bit different than the use cased described above we called "chained". So that is what you are referring to as "level"? Regarding your strategy: In my understanding it works like this: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bbakerman @andimarek apologies for the delay, I was ill the past couple of weeks. Changes since last commits - |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
For the understanding of the strategy yes that is the correct understanding of how the strategy is working. As for the verbage around chained I see the point around the mixing of chaining. We actually have both cases in our use case take for example Nested chaining Top level chaining When referring to level, I think of the entire call chain as a tree structure. Take both example above Nested Chaining Top level Chaining In both cases the 'level' or depth of the chain is the same as it takes the same amount of subsequent DL dependents to get the overall result but i believe the difference comes down to organization. You could still swap the structure to be Where this composition is encapsulated in the overall DL itself instead of a top level unfolding of the calls. Let me know if i understood the question correctly. Thanks again and apologies for the delay |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Also WRT the parallelization, that is just added to bump up the complexity for the stress test, nothing really core to the test here |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bbakerman @andimarek friendly ping on this one |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
hey @zsmoore ... sorry it has been really busy the last week. Will try to come back to this soon. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No worries at all, the beginning of the year is always crazy |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hello, this pull request has been inactive for 60 days, so we're marking it as stale. If you would like to continue working on this pull request, please make an update within the next 30 days, or we'll close the pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hello, as this pull request has been inactive for 90 days, we're closing this pull request. We always welcome contributions, and if you would like to continue, please open a new pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Reopening - I wanted to chat about this before the bot closes it |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hello, this pull request has been inactive for 60 days, so we're marking it as stale. If you would like to continue working on this pull request, please make an update within the next 30 days, or we'll close the pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This bot is a scourge... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.