Class: Mongo::Cluster::Topology::Single

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

Overview

Defines behaviour for when a cluster is in single topology.

Since:

  • 2.0.0

Constant Summary collapse

NAME =

The display name for the topology.

Since:

  • 2.0.0

'Single'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, seeds = []) ⇒ Single

Initialize the topology with the options.

Examples:

Initialize the topology.

Single.new(options)

Parameters:

  • options (Hash)

    The options.

Since:

  • 2.0.0



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

def initialize(options, seeds = [])
  @options = options
  @seed = seeds.first
end

Instance Attribute Details

#seedString (readonly)

Returns seed The seed address.

Returns:

  • (String)

    seed The seed address.

Since:

  • 2.0.0



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.

Examples:

Check if a description’s hosts may be added to the cluster.

topology.add_hosts?(description, servers)

Parameters:

Returns:

  • (false)

    A description’s hosts are never added to a cluster of Single topology.

Since:

  • 2.0.6



116
# File 'lib/mongo/cluster/topology/single.rb', line 116

def add_hosts?(description, servers); false; end

#display_nameString

Get the display name.

Examples:

Get the display name.

Single.display_name

Returns:

  • (String)

    The display name.

Since:

  • 2.0.0



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.

Examples:

Elect a primary server.

topology.elect_primary(description, servers)

Parameters:

  • description (Server::Description)

    The description of the elected primary.

  • servers (Array<Server>)

    The list of known servers to the cluster.

Returns:

Since:

  • 2.0.0



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)

Examples:

Check if a description can be used to remove hosts from

Parameters:

Returns:

  • (true)

    A description can never be used to remove hosts from a cluster of Single topology.

Since:

  • 2.0.6



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.

Examples:

Check if a specific server can be removed from the cluster.

topology.remove_server?(description, server)

Parameters:

Returns:

  • (false)

    A server is never removed from a cluster of Single topology.

Since:

  • 2.0.6



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.

Examples:

Is the topology a replica set?

Single.replica_set?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



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

def replica_set?; false; end

#replica_set_namenil

Single topologies have no replica set name.

Examples:

Get the replica set name.

single.replica_set_name

Returns:

  • (nil)

    Always nil.

Since:

  • 2.0.0



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.

Examples:

Select the servers.

Single.servers(servers, 'test')

Parameters:

  • servers (Array<Server>)

    The known servers.

Returns:

  • (Array<Server>)

    The single servers.

Since:

  • 2.0.0



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.

Examples:

Is the topology sharded?

Single.sharded?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



153
# File 'lib/mongo/cluster/topology/single.rb', line 153

def sharded?; false; end

#single?true

A single topology is single.

Examples:

Is the topology single?

Single.single?

Returns:

  • (true)

    Always true.

Since:

  • 2.0.0



163
# File 'lib/mongo/cluster/topology/single.rb', line 163

def single?; true; end

#standalone_discoveredTopology::Single

Notify the topology that a standalone was discovered.

Examples:

Notify the topology that a standalone was discovered.

topology.standalone_discovered

Returns:

Since:

  • 2.0.6



183
# File 'lib/mongo/cluster/topology/single.rb', line 183

def standalone_discovered; self; end

#unknown?false

An single topology is not unknown.

Examples:

Is the topology unknown?

Single.unknown?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



173
# File 'lib/mongo/cluster/topology/single.rb', line 173

def unknown?; false; end