lib/mongo/operation/shared/executable.rb in mongo-2.9.2 vs lib/mongo/operation/shared/executable.rb in mongo-2.10.0.rc0
- old
+ new
@@ -18,14 +18,24 @@
# Shared executable behavior of operations.
#
# @since 2.5.2
module Executable
+ def do_execute(server)
+ unpin_maybe(session) do
+ add_error_labels do
+ get_result(server).tap do |result|
+ process_result(result, server)
+ end
+ end
+ end
+ end
+
def execute(server)
- result = get_result(server)
- process_result(result, server)
- result.validate!
+ do_execute(server).tap do |result|
+ validate_result(result)
+ end
end
private
def result_class
@@ -37,23 +47,27 @@
end
# Returns a Protocol::Message or nil
def dispatch_message(server)
server.with_connection do |connection|
- connection.dispatch([ message(server) ], operation_id)
+ connection.dispatch([ build_message(server) ], operation_id)
end
end
+ def build_message(server)
+ message(server)
+ end
+
def process_result(result, server)
server.update_cluster_time(result)
if result.not_master? || result.node_recovering?
if result.node_shutting_down?
disconnect_pool = true
else
# Max wire version needs to be checked prior to marking the
# server unknown
- disconnect_pool = server.description.max_wire_version < 8
+ disconnect_pool = !server.description.server_version_gte?('4.2')
end
server.unknown!
if disconnect_pool