Class: Mongo::Srv::Monitor Private
- Inherits:
-
Object
- Object
- Mongo::Srv::Monitor
- Includes:
- BackgroundThread, Loggable
- Defined in:
- lib/mongo/srv/monitor.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Periodically retrieves SRV records for the cluster’s SRV URI, and sets the cluster’s server list to the SRV lookup result.
If an error is encountered during SRV lookup or an SRV record is invalid or disallowed for security reasons, a warning is logged and monitoring continues.
Constant Summary collapse
- MIN_SCAN_INTERVAL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
60- DEFAULT_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
10
Constants included from Loggable
Instance Attribute Summary collapse
- #cluster ⇒ Object readonly private
-
#last_result ⇒ Srv::Result
readonly
private
Last known SRV lookup result.
- #options ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(cluster, options = nil) ⇒ Monitor
constructor
private
Creates the SRV monitor.
- #start! ⇒ Object private
Methods included from BackgroundThread
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
#initialize(cluster, options = nil) ⇒ Monitor
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.
Creates the SRV monitor.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mongo/srv/monitor.rb', line 43 def initialize(cluster, = nil) = if .dup else {} end @cluster = cluster @resolver = Srv::Resolver.new() unless @srv_uri = .delete(:srv_uri) raise ArgumentError, 'SRV URI is required' end @options = .freeze @last_result = @srv_uri.srv_result @stop_semaphore = Semaphore.new end |
Instance Attribute Details
#cluster ⇒ Object (readonly)
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.
61 62 63 |
# File 'lib/mongo/srv/monitor.rb', line 61 def cluster @cluster end |
#last_result ⇒ Srv::Result (readonly)
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.
Returns Last known SRV lookup result. Used for determining intervals between SRV lookups, which depend on SRV DNS records’ TTL values.
66 67 68 |
# File 'lib/mongo/srv/monitor.rb', line 66 def last_result @last_result end |
#options ⇒ Object (readonly)
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.
59 60 61 |
# File 'lib/mongo/srv/monitor.rb', line 59 def @options end |
Instance Method Details
#start! ⇒ 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.
68 69 70 71 |
# File 'lib/mongo/srv/monitor.rb', line 68 def start! super ObjectSpace.define_finalizer(self, self.class.finalize(@thread)) end |