Class: Mongo::Cluster::Topology::Unknown

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

Overview

Defines behavior for when a cluster is in an unknown state.

Since:

  • 2.0.0

Constant Summary collapse

NAME =

The display name for the topology.

Since:

  • 2.0.0

'Unknown'

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.

Examples:

Get the display name.

Unknown.display_name

Returns:

  • (String)

    The display name.

Since:

  • 2.0.0



39
40
41
# File 'lib/mongo/cluster/topology/unknown.rb', line 39

def display_name
  self.class.name.gsub(/.*::/, '')
end

#has_readable_server?(_cluster, _server_selector = nil) ⇒ false

Determine if the topology would select a readable server for the provided candidates and read preference.

Examples:

Is a readable server present?

topology.has_readable_server?(cluster, server_selector)

Parameters:

Returns:

  • (false)

    An Unknown topology will never have a readable server.

Since:

  • 2.4.0



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

def has_readable_server?(_cluster, _server_selector = nil)
  false
end

#has_writable_server?(_cluster) ⇒ false

Determine if the topology would select a writable server for the provided candidates.

Examples:

Is a writable server present?

topology.has_writable_server?(servers)

Parameters:

  • cluster (Cluster)

    The cluster.

Returns:

  • (false)

    An Unknown topology will never have a writable server.

Since:

  • 2.4.0



80
81
82
# File 'lib/mongo/cluster/topology/unknown.rb', line 80

def has_writable_server?(_cluster)
  false
end

#replica_set?false

An unknown topology is not a replica set.

Examples:

Is the topology a replica set?

Unknown.replica_set?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



92
93
94
# File 'lib/mongo/cluster/topology/unknown.rb', line 92

def replica_set?
  false
end

#servers(_servers) ⇒ Object

Select appropriate servers for this topology.

Examples:

Select the servers.

Unknown.servers(servers)

Parameters:

  • servers (Array<Server>)

    The known servers.

Raises:

  • (Unknown)

    Cannot select servers when the topology is unknown.

Since:

  • 2.0.0



107
108
109
# File 'lib/mongo/cluster/topology/unknown.rb', line 107

def servers(_servers)
  []
end

#sharded?false

An unknown topology is not sharded.

Examples:

Is the topology sharded?

Unknown.sharded?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



119
120
121
# File 'lib/mongo/cluster/topology/unknown.rb', line 119

def sharded?
  false
end

#single?true

An unknown topology is not single.

Examples:

Is the topology single?

Unknown.single?

Returns:

  • (true)

    Always false.

Since:

  • 2.0.0



131
132
133
# File 'lib/mongo/cluster/topology/unknown.rb', line 131

def single?
  false
end

#summaryObject

Note:

This method is experimental and subject to change.

Since:

  • 2.7.0



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

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

#unknown?true

An unknown topology is unknown.

Examples:

Is the topology unknown?

Unknown.unknown?

Returns:

  • (true)

    Always true.

Since:

  • 2.0.0



143
144
145
# File 'lib/mongo/cluster/topology/unknown.rb', line 143

def unknown?
  true
end