Module Mongo::Cluster::Topology
In: lib/mongo/cluster/topology.rb
lib/mongo/cluster/topology/replica_set_no_primary.rb
lib/mongo/cluster/topology/base.rb
lib/mongo/cluster/topology/replica_set_with_primary.rb
lib/mongo/cluster/topology/unknown.rb
lib/mongo/cluster/topology/no_replica_set_options.rb
lib/mongo/cluster/topology/single.rb
lib/mongo/cluster/topology/sharded.rb

Defines behavior for getting servers.

Topologies are associated with their clusters - for example, a ReplicaSet topology contains the replica set name. A topology object therefore cannot be used with multiple cluster objects.

At the same time, topology objects do not know anything about specific servers in a cluster, despite what their constructor may suggest. Which means, in particular, that topology change events require the application to maintain cluster references on its own if it wants to track server changes within a replica set.

@since 2.0.0

Methods

initial  

Classes and Modules

Module Mongo::Cluster::Topology::NoReplicaSetOptions
Class Mongo::Cluster::Topology::Base
Class Mongo::Cluster::Topology::ReplicaSetNoPrimary
Class Mongo::Cluster::Topology::ReplicaSetWithPrimary
Class Mongo::Cluster::Topology::Sharded
Class Mongo::Cluster::Topology::Single
Class Mongo::Cluster::Topology::Unknown

Constants

OPTIONS = { replica_set: ReplicaSetNoPrimary, sharded: Sharded, direct: Single, }.freeze   The various topologies for server selection.

@since 2.0.0

Public Instance methods

Get the initial cluster topology for the provided options.

@example Get the initial cluster topology.

  Topology.initial(topology: :replica_set)

@param [ Cluster ] cluster The cluster. @param [ Monitoring ] monitoring The monitoring. @param [ Hash ] options The cluster options.

@return [ ReplicaSet, Sharded, Single ] The topology.

@since 2.0.0 @api private

[Validate]