Module: Mongo::Cluster::Topology

Extended by:
Topology
Included in:
Topology
Defined in:
lib/mongo/cluster/topology.rb,
lib/mongo/cluster/topology/single.rb,
lib/mongo/cluster/topology/unknown.rb,
lib/mongo/cluster/topology/sharded.rb,
lib/mongo/cluster/topology/replica_set.rb

Overview

Defines behaviour for getting servers.

Since:

  • 2.0.0

Defined Under Namespace

Classes: ReplicaSet, Sharded, Single, Unknown

Constant Summary

OPTIONS =

The various topologies for server selection.

Since:

  • 2.0.0

{
  replica_set: ReplicaSet,
  sharded: Sharded,
  direct: Single
}.freeze

Instance Method Summary collapse

Instance Method Details

#initial(seeds, monitoring, options) ⇒ ReplicaSet, ...

Get the initial cluster topology for the provided options.

Examples:

Get the initial cluster topology.

Topology.initial(topology: :replica_set)

Parameters:

  • seeds (Array<String>)

    The addresses of the configured servers.

  • monitoring (Monitoring)

    The monitoring.

  • options (Hash)

    The cluster options.

Returns:

Since:

  • 2.0.0



50
51
52
53
54
55
56
57
58
# File 'lib/mongo/cluster/topology.rb', line 50

def initial(seeds, monitoring, options)
  if options.has_key?(:connect)
    OPTIONS.fetch(options[:connect].to_sym).new(options, monitoring, seeds)
  elsif options.has_key?(:replica_set)
    ReplicaSet.new(options, monitoring, options)
  else
    Unknown.new(options, monitoring, seeds)
  end
end