123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base, Forwardable
Instance Chain:
Inherits: Mongo::Cluster::Topology::Base
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

::Mongo::Loggable - Included

PREFIX

Class Method Summary

Base - Inherited

.new

Initialize the topology with the options.

Instance Attribute Summary

Base - Inherited

::Mongo::Monitoring::Publishable - Included

Instance Method Summary

Base - Inherited

#addresses,
#max_election_id

The largest electionId ever reported by a primary.

#max_set_version

The largest setVersion ever reported by a primary.

#new_max_election_id, #new_max_set_version,
#replica_set_name

Get the replica set name configured for this topology.

#server_hosts_match_any?

Compares each server address against the list of patterns.

#validate_options

Validates and/or transforms options as necessary for the topology.

::Mongo::Monitoring::Publishable - Included

::Mongo::Loggable - Included

#log_debug

Convenience method to log debug messages with the standard prefix.

#log_error

Convenience method to log error messages with the standard prefix.

#log_fatal

Convenience method to log fatal messages with the standard prefix.

#log_info

Convenience method to log info messages with the standard prefix.

#log_warn

Convenience method to log warn messages with the standard prefix.

#logger

Get the logger instance.

#_mongo_log_prefix, #format_message

Instance Attribute Details

#replica_set?false (readonly)

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

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 64

def replica_set?; false; end

#sharded?false (readonly)

Returns whether this topology is sharded.

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 78

def sharded?; false; end

#single?true (readonly)

Returns whether this topology is Single.

Returns:

  • (true)

    Always false.

Since:

  • 2.0.0

[ GitHub ]

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

def single?; false; end

#unknown?false (readonly)

Returns whether this topology is Unknown.

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0

[ GitHub ]

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

def unknown?; false; end

Instance Method Details

#display_nameString

Get the display name.

Returns:

  • (String)

    The display name.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 31

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:

  • cluster (Cluster)

    The cluster.

  • server_selector (ServerSelector) (defaults to: nil)

    The server selector.

Returns:

  • (true)

    A standalone always has a readable server.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 51

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

[ GitHub ]

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

def has_writable_server?(cluster); true; 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

[ GitHub ]

  
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 71

def servers(servers, name = nil)
  servers
end

#summary

Note:

This method is experimental and subject to change.

Since:

  • 2.0.0

[ GitHub ]

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

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

#validate_options(options, cluster) (private)

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/cluster/topology/load_balanced.rb', line 92

def validate_options(options, cluster)
  if cluster.servers_list.length > 1
    raise ArgumentError, "Cannot instantiate a load-balanced topology with more than one server in the cluster: #{cluster.servers_list.map(&:address).map(&:seed).join(', ')}"
  end

  super(options, cluster)
end