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, **opts) ⇒ Monitor
constructor
private
Creates the SRV monitor.
Methods included from BackgroundThread
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
#initialize(cluster, **opts) ⇒ 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.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mongo/srv/monitor.rb', line 45 def initialize(cluster, **opts) @cluster = cluster unless @srv_uri = opts.delete(:srv_uri) raise ArgumentError, 'SRV URI is required' end @options = opts.freeze @resolver = Srv::Resolver.new(**opts) @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.
58 59 60 |
# File 'lib/mongo/srv/monitor.rb', line 58 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.
63 64 65 |
# File 'lib/mongo/srv/monitor.rb', line 63 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.
56 57 58 |
# File 'lib/mongo/srv/monitor.rb', line 56 def @options end |