Class: Mongo::Cluster::Topology::Single
- Defined in:
- lib/mongo/cluster/topology/single.rb
Overview
Defines behavior for when a cluster is in single topology.
Constant Summary collapse
- NAME =
The display name for the topology.
'Single'.freeze
Constants included from Loggable
Instance Attribute Summary
Attributes inherited from Base
#compatibility_error, #logical_session_timeout, #monitoring, #options, #server_descriptions
Attributes included from Monitoring::Publishable
Instance Method Summary collapse
-
#display_name ⇒ String
Get the display name.
-
#has_readable_server?(cluster, server_selector = nil) ⇒ true
Determine if the topology would select a readable server for the provided candidates and read preference.
-
#has_writable_server?(cluster) ⇒ true
Determine if the topology would select a writable server for the provided candidates.
-
#replica_set? ⇒ false
A single topology is not a replica set.
-
#servers(servers, name = nil) ⇒ Array<Server>
Select appropriate servers for this topology.
-
#sharded? ⇒ false
A single topology is not sharded.
-
#single? ⇒ true
A single topology is single.
- #summary ⇒ Object
-
#unknown? ⇒ false
An single topology is not unknown.
Methods inherited from Base
#addresses, #compatible?, #data_bearing_servers?, #initialize, #max_election_id, #max_set_version, #new_max_election_id, #new_max_set_version, #replica_set_name
Methods included from Monitoring::Publishable
#publish_event, #publish_sdam_event
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
This class inherits a constructor from Mongo::Cluster::Topology::Base
Instance Method Details
#display_name ⇒ String
Get the display name.
37 38 39 |
# File 'lib/mongo/cluster/topology/single.rb', line 37 def display_name self.class.name.gsub(/.*::/, '') end |
#has_readable_server?(cluster, server_selector = nil) ⇒ true
Determine if the topology would select a readable server for the provided candidates and read preference.
63 |
# File 'lib/mongo/cluster/topology/single.rb', line 63 def has_readable_server?(cluster, server_selector = nil); true; end |
#has_writable_server?(cluster) ⇒ true
Determine if the topology would select a writable server for the provided candidates.
76 |
# File 'lib/mongo/cluster/topology/single.rb', line 76 def has_writable_server?(cluster); true; end |
#replica_set? ⇒ false
A single topology is not a replica set.
86 |
# File 'lib/mongo/cluster/topology/single.rb', line 86 def replica_set?; false; end |
#servers(servers, name = nil) ⇒ Array<Server>
Select appropriate servers for this topology.
98 99 100 |
# File 'lib/mongo/cluster/topology/single.rb', line 98 def servers(servers, name = nil) [ servers.detect { |server| !server.unknown? } ] end |
#sharded? ⇒ false
A single topology is not sharded.
110 |
# File 'lib/mongo/cluster/topology/single.rb', line 110 def sharded?; false; end |
#single? ⇒ true
A single topology is single.
120 |
# File 'lib/mongo/cluster/topology/single.rb', line 120 def single?; true; end |
#summary ⇒ Object
This method is experimental and subject to change.
45 46 47 48 |
# File 'lib/mongo/cluster/topology/single.rb', line 45 def summary details = server_descriptions.keys.join(',') "#{display_name}[#{details}]" end |
#unknown? ⇒ false
An single topology is not unknown.
130 |
# File 'lib/mongo/cluster/topology/single.rb', line 130 def unknown?; false; end |