File: client_registry_macros.rb

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (26 lines) | stat: -rw-r--r-- 733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true
# rubocop:todo all

module ClientRegistryMacros
  def new_local_client(address, options=nil, &block)
    ClientRegistry.instance.new_local_client(address, options, &block)
  end

  def new_local_client_nmio(address, options=nil, &block)
    # Avoid type converting options.
    base_options = {monitoring_io: false}
    if BSON::Document === options || options&.keys&.any? { |key| String === key }
      base_options = Mongo::Options::Redacted.new(base_options)
    end
    options = if options
      base_options.merge(options)
    else
      base_options
    end
    new_local_client(address, options, &block)
  end

  def close_local_clients
    ClientRegistry.instance.close_local_clients
  end
end