Method: Mongo::Server::Monitor::Connection#check_document

Defined in:
lib/mongo/server/monitor/connection.rb

#check_documentBSON::Document

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.

Build a document that should be used for connection check.

Returns:

  • (BSON::Document)

    Document that should be sent to a server for connection check.

Since:

  • 2.0.0



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/mongo/server/monitor/connection.rb', line 229

def check_document
  server_api = .server_api || options[:server_api]
  doc = if hello_ok? || server_api
    _doc = HELLO_DOC
    if server_api
      _doc = _doc.merge(Utils.transform_server_api(server_api))
    end
    _doc
  else
    LEGACY_HELLO_DOC
  end
  # compressors must be set to maintain correct compression status
  # in the server description. See RUBY-2427
  if compressors = options[:compressors]
    doc = doc.merge(compression: compressors)
  end
  doc
end