-
Notifications
You must be signed in to change notification settings - Fork 180
RUST-1588: Add RunCursorCommand #912
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4efc673
RUST-1636: Add RunCursorCommand
drshika e6626f5
docs
drshika dcee793
add run_cursor_command_with_session
drshika 9f9737f
remove RunCursorCommandWithSession Enum
drshika 9e17b35
more comment fixes
drshika 5d74bfa
more comment fixes
drshika 69c8d51
all pr fixes but moving files
drshika ee5492a
moved files
drshika 960c800
resolve remaining comments
drshika 6fac64b
Update src/db/options.rs
drshika 5eeafec
Update src/db.rs
drshika 7afc8a5
resolve remaining comments
drshika 54185f8
resolve remaining comments
drshika 0836a45
fix failing test cases
drshika 9c690a6
Update src/db.rs
drshika File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#[cfg(feature = "in-use-encryption-unstable")] | ||
use bson::doc; | ||
use bson::RawDocumentBuf; | ||
|
||
use crate::{ | ||
cmap::{conn::PinnedConnectionHandle, Command, RawCommandResponse, StreamDescription}, | ||
concern::WriteConcern, | ||
cursor::CursorSpecification, | ||
error::{Error, Result}, | ||
operation::{Operation, RunCommand}, | ||
options::RunCursorCommandOptions, | ||
selection_criteria::SelectionCriteria, | ||
}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub(crate) struct RunCursorCommand<'conn> { | ||
run_command: RunCommand<'conn>, | ||
options: Option<RunCursorCommandOptions>, | ||
} | ||
|
||
impl<'conn> RunCursorCommand<'conn> { | ||
pub(crate) fn new( | ||
run_command: RunCommand<'conn>, | ||
options: Option<RunCursorCommandOptions>, | ||
) -> Result<Self> { | ||
Ok(Self { | ||
run_command, | ||
options, | ||
}) | ||
} | ||
} | ||
|
||
impl<'conn> Operation for RunCursorCommand<'conn> { | ||
type O = CursorSpecification; | ||
type Command = RawDocumentBuf; | ||
|
||
const NAME: &'static str = "run_cursor_command"; | ||
|
||
fn build(&mut self, description: &StreamDescription) -> Result<Command<Self::Command>> { | ||
self.run_command.build(description) | ||
} | ||
|
||
fn serialize_command(&mut self, cmd: Command<Self::Command>) -> Result<Vec<u8>> { | ||
self.run_command.serialize_command(cmd) | ||
} | ||
|
||
fn extract_at_cluster_time( | ||
&self, | ||
response: &bson::RawDocument, | ||
) -> Result<Option<bson::Timestamp>> { | ||
self.run_command.extract_at_cluster_time(response) | ||
} | ||
|
||
fn handle_error(&self, error: Error) -> Result<Self::O> { | ||
Err(error) | ||
} | ||
|
||
fn selection_criteria(&self) -> Option<&SelectionCriteria> { | ||
self.run_command.selection_criteria() | ||
} | ||
|
||
fn is_acknowledged(&self) -> bool { | ||
self.run_command.is_acknowledged() | ||
} | ||
|
||
fn write_concern(&self) -> Option<&WriteConcern> { | ||
self.run_command.write_concern() | ||
} | ||
|
||
fn supports_read_concern(&self, description: &StreamDescription) -> bool { | ||
self.run_command.supports_read_concern(description) | ||
} | ||
|
||
fn supports_sessions(&self) -> bool { | ||
self.run_command.supports_sessions() | ||
} | ||
|
||
fn retryability(&self) -> crate::operation::Retryability { | ||
self.run_command.retryability() | ||
} | ||
|
||
fn update_for_retry(&mut self) { | ||
self.run_command.update_for_retry() | ||
} | ||
|
||
fn pinned_connection(&self) -> Option<&PinnedConnectionHandle> { | ||
self.run_command.pinned_connection() | ||
} | ||
|
||
fn name(&self) -> &str { | ||
self.run_command.name() | ||
} | ||
|
||
fn handle_response( | ||
&self, | ||
response: RawCommandResponse, | ||
description: &StreamDescription, | ||
) -> Result<Self::O> { | ||
let doc = Operation::handle_response(&self.run_command, response, description)?; | ||
let cursor_info = bson::from_document(doc)?; | ||
let batch_size = match &self.options { | ||
Some(options) => options.batch_size.clone(), | ||
None => None, | ||
}; | ||
let max_time = match &self.options { | ||
Some(options) => options.max_time.clone(), | ||
None => None, | ||
}; | ||
let comment = match &self.options { | ||
Some(options) => options.comment.clone(), | ||
None => None, | ||
}; | ||
Ok(CursorSpecification::new( | ||
cursor_info, | ||
description.server_address.clone(), | ||
batch_size, | ||
max_time, | ||
comment, | ||
)) | ||
} | ||
} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.