Module: Mongo::Operation::Write Private
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
ResponseHandling
|
|
Defined in: | lib/mongo/operation/shared/write.rb |
Overview
Shared behavior of operations that write (update, insert, delete).
Instance Method Summary
-
#bulk_execute(connection, context:) ⇒ Mongo::Operation::Delete::BulkResult, ...
Internal use only
Execute the bulk write operation.
-
#execute(server, context:) ⇒ Mongo::Operation::Result
Internal use only
Execute the operation.
-
#execute_with_connection(connection, context:) ⇒ Mongo::Operation::Result
Internal use only
Execute the operation.
- #validate!(connection) private Internal use only
ResponseHandling
- Included
#add_error_labels | Adds error labels to exceptions raised in the yielded to block, which should perform MongoDB operations and raise Mongo::Errors on failure. |
#add_server_diagnostics | Yields to the block and, if the block raises an exception, adds a note to the exception with the address of the specified server. |
#maybe_add_retryable_write_error_label! | A method that will add the RetryableWriteError label to an error if any of the following conditions are true: |
#unpin_maybe | Unpins the session and/or the connection if the yielded to block raises errors that are required to unpin the session and the connection. |
#validate_result |
Instance Method Details
#bulk_execute(connection, context:) ⇒ Mongo::Operation::Delete::BulkResult, ...
Execute the bulk write operation.
# File 'lib/mongo/operation/shared/write.rb', line 73
def bulk_execute(connection, context:) Lint.assert_type(connection, Server::Connection) if connection.features.op_msg_enabled? self.class::OpMsg.new(spec).execute(connection, context: context).bulk_result else self.class::Command.new(spec).execute(connection, context: context).bulk_result end end
#execute(server, context:) ⇒ Mongo::Operation::Result
Execute the operation.
# File 'lib/mongo/operation/shared/write.rb', line 37
def execute(server, context:) server.with_connection( connection_global_id: context.connection_global_id, context: context ) do |connection| execute_with_connection(connection, context: context) end end
#execute_with_connection(connection, context:) ⇒ Mongo::Operation::Result
Execute the operation.
#validate!(connection) (private)
# File 'lib/mongo/operation/shared/write.rb', line 85
def validate!(connection) if !acknowledged_write? if collation raise Error::UnsupportedCollation.new( Error::UnsupportedCollation::UNACKNOWLEDGED_WRITES_MESSAGE) end if array_filters(connection) raise Error::UnsupportedArrayFilters.new( Error::UnsupportedArrayFilters::UNACKNOWLEDGED_WRITES_MESSAGE) end end end