Method: Mongo::Server#initialize
- Defined in:
- lib/mongo/server.rb
#initialize(address, cluster, monitoring, event_listeners, options = {}) ⇒ Server
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.
Note:
Server must never be directly instantiated outside of a Cluster.
Instantiate a new server object. Will start the background refresh and subscribe to the appropriate events.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/mongo/server.rb', line 71 def initialize(address, cluster, monitoring, event_listeners, = {}) @address = address @cluster = cluster @monitoring = monitoring = .dup _monitor = .delete(:monitor) = .freeze @event_listeners = event_listeners @connection_id_gen = Class.new do include Id end @scan_semaphore = DistinguishingSemaphore.new @round_trip_time_calculator = RoundTripTimeCalculator.new @description = Description.new(address, {}, load_balancer: !![:load_balancer], force_load_balancer: force_load_balancer?, ) @last_scan = nil @last_scan_monotime = nil unless [:monitoring_io] == false @monitor = Monitor.new(self, event_listeners, monitoring, .merge( app_metadata: cluster., push_monitor_app_metadata: cluster., heartbeat_interval: cluster.heartbeat_interval, )) unless _monitor == false start_monitoring end end @connected = true @pool_lock = Mutex.new end |