Module: Mongo::Operation::Executable Private

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Shared executable behavior of operations.

Since:

  • 2.5.2

Instance Method Summary collapse

Instance Method Details

#do_execute(connection, context, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.5.2



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'build/ruby-driver-master/lib/mongo/operation/shared/executable.rb', line 29

def do_execute(connection, context, options = {})
  unpin_maybe(session) do
    add_error_labels(connection, context) do
      add_server_diagnostics(connection) do
        get_result(connection, context, options).tap do |result|
          if session
            if session.in_transaction? &&
              connection.description.load_balancer?
            then
              if session.pinned_service_id
                unless session.pinned_service_id == connection.service_id
                  raise Error::InternalDriverError, "Expected operation to use service #{session.pinned_session_id} but it used #{connection.service_id}"
                end
              else
                session.pin_to_service(connection.service_id)
              end
            end

            if session.snapshot? && !session.snapshot_timestamp
              session.snapshot_timestamp = result.snapshot_timestamp
            end
          end
          process_result(result, connection)
        end
      end
    end
  end
end

#execute(connection, context:, options: {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.5.2



58
59
60
61
62
63
64
65
66
67
68
# File 'build/ruby-driver-master/lib/mongo/operation/shared/executable.rb', line 58

def execute(connection, context:, options: {})
  if Lint.enabled?
    unless connection.is_a?(Mongo::Server::Connection)
      raise Error::LintError, "Connection argument is of wrong type: #{connection}"
    end
  end

  do_execute(connection, context, options).tap do |result|
    validate_result(result, connection, context)
  end
end