Class: Mongo::Cluster::Topology::Single
- Inherits:
-
Object
- Object
- Mongo::Cluster::Topology::Single
- 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
-
#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.
-
#initialize(options, seeds = []) ⇒ Single
constructor
Initialize the topology with the options.
-
#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.
Constructor Details
#initialize(options, seeds = []) ⇒ Single
Initialize the topology with the options.
65 66 67 68 |
# File 'lib/mongo/cluster/topology/single.rb', line 65 def initialize(, seeds = []) @options = @seed = seeds.first end |
Instance Attribute Details
#seed ⇒ String (readonly)
Returns seed The seed address.
25 26 27 |
# File 'lib/mongo/cluster/topology/single.rb', line 25 def seed @seed end |
Instance Method Details
#add_hosts?(description, servers) ⇒ false
Whether a server description’s hosts may be added to the cluster.
116 |
# File 'lib/mongo/cluster/topology/single.rb', line 116 def add_hosts?(description, servers); false; end |
#display_name ⇒ String
Get the display name.
40 41 42 |
# File 'lib/mongo/cluster/topology/single.rb', line 40 def display_name NAME end |
#elect_primary(description, servers) ⇒ Single
Elect a primary server within this topology.
55 |
# File 'lib/mongo/cluster/topology/single.rb', line 55 def elect_primary(description, servers); self; end |
#remove_hosts?(description) ⇒ true
Whether a description can be used to remove hosts from the cluster.
the cluster.
topology.remove_hosts?(description)
130 |
# File 'lib/mongo/cluster/topology/single.rb', line 130 def remove_hosts?(description); false; end |
#remove_server?(description, server) ⇒ false
Whether a specific server in the cluster can be removed, given a description.
143 |
# File 'lib/mongo/cluster/topology/single.rb', line 143 def remove_server?(description, server); false; end |
#replica_set? ⇒ false
A single topology is not a replica set.
78 |
# File 'lib/mongo/cluster/topology/single.rb', line 78 def replica_set?; false; end |
#replica_set_name ⇒ nil
Single topologies have no replica set name.
88 |
# File 'lib/mongo/cluster/topology/single.rb', line 88 def replica_set_name; nil; end |
#servers(servers, name = nil) ⇒ Array<Server>
Select appropriate servers for this topology.
100 101 102 |
# File 'lib/mongo/cluster/topology/single.rb', line 100 def servers(servers, name = nil) [ servers.detect { |server| !server.unknown? } ] end |
#sharded? ⇒ false
A single topology is not sharded.
153 |
# File 'lib/mongo/cluster/topology/single.rb', line 153 def sharded?; false; end |
#single? ⇒ true
A single topology is single.
163 |
# File 'lib/mongo/cluster/topology/single.rb', line 163 def single?; true; end |
#standalone_discovered ⇒ Topology::Single
Notify the topology that a standalone was discovered.
183 |
# File 'lib/mongo/cluster/topology/single.rb', line 183 def standalone_discovered; self; end |
#unknown? ⇒ false
An single topology is not unknown.
173 |
# File 'lib/mongo/cluster/topology/single.rb', line 173 def unknown?; false; end |