-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Simplify Operations by uniting Sync and Async operations #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…e interface. Merged Async Read / Write Operations into their sync operations counterparts. * AsyncWriteOperation into WriteOperation is a simple merge * AsyncReadOperation into ReadOperation requires an additional type parameter This is due to async and sync cursors have different types. Added extra ReadOperations interfaces to represent: * Read operations that return the same type for sync / async * Read operations that represent cursors Removed SyncOperations and AsyncOperations builders which both use the same Operations builder class. JAVA-4900
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request unifies synchronous and asynchronous operations in the MongoDB Java driver by merging the previously separate AsyncReadOperation
and AsyncWriteOperation
interfaces into their sync counterparts. The key changes include adding an additional type parameter to ReadOperation
to handle different sync and async return types, introducing new read operation interfaces for better type organization, removing the separate builder classes for sync/async operations, and consolidating all operation interfaces to work with both sync and async execution.
Key Changes
- Merge
AsyncReadOperation
andAsyncWriteOperation
interfaces into syncReadOperation
andWriteOperation
interfaces - Add additional type parameter to
ReadOperation<T, R>
to support different return types for sync and async execution - Remove
SyncOperations
andAsyncOperations
builder classes in favor of unifiedOperations
class
Reviewed Changes
Copilot reviewed 79 out of 79 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
driver-core/src/main/com/mongodb/internal/operation/ReadOperation.java | Added async execution method and second type parameter for different sync/async return types |
driver-core/src/main/com/mongodb/internal/operation/WriteOperation.java | Added async execution method to write operations |
driver-core/src/main/com/mongodb/internal/operation/Operations.java | Unified operations builder class with timeout settings support and public API |
driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ReadOperationCursorAsyncOnly.java | New interface for async-only cursor operations with sync method throwing UnsupportedOperationException |
driver-sync/src/main/com/mongodb/client/internal/OperationExecutor.java | Updated method signatures to use new ReadOperation type parameter |
...reams/src/main/com/mongodb/reactivestreams/client/internal/ReadOperationCursorAsyncOnly.java
Show resolved
Hide resolved
driver-sync/src/main/com/mongodb/client/internal/MapReduceIterableImpl.java
Show resolved
Hide resolved
...ive-streams/src/main/com/mongodb/reactivestreams/client/internal/MapReducePublisherImpl.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this class is used directly instead of being wrapped by Sync/AsyncOperations, consider changing the return values of the operation-return methods to be the interface types rather than the concrete types, as was done in AsyncOperations and SyncOperations.
Longer term, it would be nice if all the concrete operation classes were package private, and Operations
was the only way to create them, but that's quite a bit more work (especially since the legacy driver doesn't use Operations
)
Merged Async Read / Write Operations into their sync operations counterparts.
Added extra ReadOperations interfaces to represent:
Removed SyncOperations and AsyncOperations builders which both use the same Operations builder class.
JAVA-5900