Class: Mongo::Cluster::Topology::LoadBalanced

Inherits:
Base
  • Object
show all
Defined in:
lib/mongo/cluster/topology/load_balanced.rb

Overview

Defines behavior for when a cluster is in load-balanced topology.

Since:

  • 2.0.0

Constant Summary collapse

NAME =

The display name for the topology.

Since:

  • 2.0.0

'LoadBalanced'

Constants included from Loggable

Loggable::PREFIX

Instance Attribute Summary

Attributes inherited from Base

#compatibility_error, #logical_session_timeout, #monitoring, #options, #server_descriptions

Attributes included from Monitoring::Publishable

#monitoring

Instance Method Summary collapse

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, #server_hosts_match_any?

Methods included from Monitoring::Publishable

#publish_cmap_event, #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_nameString

Get the display name.

Returns:

  • (String)

    The display name.

Since:

  • 2.0.0



28
29
30
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 28

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.

Parameters:

Returns:

  • (true)

    A standalone always has a readable server.

Since:

  • 2.0.0



48
49
50
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 48

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.

Parameters:

  • cluster (Cluster)

    The cluster.

Returns:

  • (true)

    A standalone always has a writable server.

Since:

  • 2.0.0



58
59
60
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 58

def has_writable_server?(_cluster)
  true
end

#replica_set?false

Returns whether this topology is one of the replica set ones.

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



65
66
67
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 65

def replica_set?
  false
end

#servers(servers, _name = nil) ⇒ Array<Server>

Select appropriate servers for this topology.

Parameters:

  • servers (Array<Server>)

    The known servers.

Returns:

  • (Array<Server>)

    All of the known servers.

Since:

  • 2.0.0



74
75
76
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 74

def servers(servers, _name = nil)
  servers
end

#sharded?false

Returns whether this topology is sharded.

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



81
82
83
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 81

def sharded?
  false
end

#single?false

Returns whether this topology is Single.

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



88
89
90
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 88

def single?
  false
end

#summaryObject

Note:

This method is experimental and subject to change.

Since:

  • 2.0.0



35
36
37
38
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 35

def summary
  details = server_descriptions.keys.join(',')
  "#{display_name}[#{details}]"
end

#unknown?false

Returns whether this topology is Unknown.

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



95
96
97
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 95

def unknown?
  false
end