Class: Mongo::Cluster::Topology::Single
- Inherits:
-
Object
- Object
- Mongo::Cluster::Topology::Single
- Includes:
- Monitoring::Publishable
- Defined in:
- lib/mongo/cluster/topology/single.rb
Overview
Defines behaviour for when a cluster is in single topology.
Constant Summary collapse
- NAME =
The display name for the topology.
'Single'.freeze
Instance Attribute Summary collapse
-
#monitoring ⇒ monitoring
readonly
Monitoring the monitoring.
-
#options ⇒ Hash
readonly
Options The options.
-
#seed ⇒ String
readonly
Seed The seed address.
Instance Method Summary collapse
-
#add_hosts?(description, servers) ⇒ false
Whether a server description’s hosts may be added to the cluster.
-
#display_name ⇒ String
Get the display name.
-
#elect_primary(description, servers) ⇒ Single
Elect a primary server within this topology.
-
#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.
-
#initialize(options, monitoring, seeds = []) ⇒ Single
constructor
Initialize the topology with the options.
-
#member_discovered ⇒ Object
Publish that a member of this topology was discovered.
-
#remove_hosts?(description) ⇒ true
Whether a description can be used to remove hosts from the cluster.
-
#remove_server?(description, server) ⇒ false
Whether a specific server in the cluster can be removed, given a description.
-
#replica_set? ⇒ false
A single topology is not a replica set.
-
#replica_set_name ⇒ nil
Single topologies have no replica set name.
-
#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.
-
#standalone_discovered ⇒ Topology::Single
Notify the topology that a standalone was discovered.
-
#unknown? ⇒ false
An single topology is not unknown.
Methods included from Monitoring::Publishable
#publish_command, #publish_event, #publish_sdam_event
Constructor Details
#initialize(options, monitoring, seeds = []) ⇒ Single
Initialize the topology with the options.
102 103 104 105 106 |
# File 'lib/mongo/cluster/topology/single.rb', line 102 def initialize(, monitoring, seeds = []) = @monitoring = monitoring @seed = seeds.first end |
Instance Attribute Details
#monitoring ⇒ monitoring (readonly)
Returns monitoring the monitoring.
37 38 39 |
# File 'lib/mongo/cluster/topology/single.rb', line 37 def monitoring @monitoring end |
#options ⇒ Hash (readonly)
Returns options The options.
31 32 33 |
# File 'lib/mongo/cluster/topology/single.rb', line 31 def end |
#seed ⇒ String (readonly)
Returns seed The seed address.
34 35 36 |
# File 'lib/mongo/cluster/topology/single.rb', line 34 def seed @seed end |
Instance Method Details
#add_hosts?(description, servers) ⇒ false
Whether a server description’s hosts may be added to the cluster.
154 |
# File 'lib/mongo/cluster/topology/single.rb', line 154 def add_hosts?(description, servers); false; end |
#display_name ⇒ String
Get the display name.
47 48 49 |
# File 'lib/mongo/cluster/topology/single.rb', line 47 def display_name NAME end |
#elect_primary(description, servers) ⇒ Single
Elect a primary server within this topology.
62 |
# File 'lib/mongo/cluster/topology/single.rb', line 62 def elect_primary(description, servers); self; 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.
77 |
# File 'lib/mongo/cluster/topology/single.rb', line 77 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.
90 |
# File 'lib/mongo/cluster/topology/single.rb', line 90 def has_writable_server?(cluster); true; end |
#member_discovered ⇒ Object
Publish that a member of this topology was discovered.
229 230 231 232 233 234 |
# File 'lib/mongo/cluster/topology/single.rb', line 229 def member_discovered publish_sdam_event( Monitoring::TOPOLOGY_CHANGED, Monitoring::Event::TopologyChanged.new(self, self) ) end |
#remove_hosts?(description) ⇒ true
Whether a description can be used to remove hosts from the cluster.
the cluster.
topology.remove_hosts?(description)
168 |
# File 'lib/mongo/cluster/topology/single.rb', line 168 def remove_hosts?(description); false; end |
#remove_server?(description, server) ⇒ false
Whether a specific server in the cluster can be removed, given a description.
181 |
# File 'lib/mongo/cluster/topology/single.rb', line 181 def remove_server?(description, server); false; end |
#replica_set? ⇒ false
A single topology is not a replica set.
116 |
# File 'lib/mongo/cluster/topology/single.rb', line 116 def replica_set?; false; end |
#replica_set_name ⇒ nil
Single topologies have no replica set name.
126 |
# File 'lib/mongo/cluster/topology/single.rb', line 126 def replica_set_name; nil; end |
#servers(servers, name = nil) ⇒ Array<Server>
Select appropriate servers for this topology.
138 139 140 |
# File 'lib/mongo/cluster/topology/single.rb', line 138 def servers(servers, name = nil) [ servers.detect { |server| !server.unknown? } ] end |
#sharded? ⇒ false
A single topology is not sharded.
191 |
# File 'lib/mongo/cluster/topology/single.rb', line 191 def sharded?; false; end |
#single? ⇒ true
A single topology is single.
201 |
# File 'lib/mongo/cluster/topology/single.rb', line 201 def single?; true; end |
#standalone_discovered ⇒ Topology::Single
Notify the topology that a standalone was discovered.
221 |
# File 'lib/mongo/cluster/topology/single.rb', line 221 def standalone_discovered; self; end |
#unknown? ⇒ false
An single topology is not unknown.
211 |
# File 'lib/mongo/cluster/topology/single.rb', line 211 def unknown?; false; end |