lib/mongo/cluster/sdam_flow.rb
def check_if_has_primary
      unless topology.replica_set?
        raise ArgumentError, "check_if_has_primary should only be called when topology is replica set, but it is #{topology.class.name.sub(/.*::/, '')}"
      end

      primary = servers_list.detect do |server|
        # A primary with the wrong set name is not a primary
        server.primary? && server.description.replica_set_name == topology.replica_set_name
      end
      unless primary
        @topology = Topology::ReplicaSetNoPrimary.new(
          topology.options, topology.monitoring, self)
      end
    end
# Checks if the cluster has a primary, and if not, transitions the topology
# to ReplicaSetNoPrimary. Topology must be ReplicaSetWithPrimary when
# invoking this method.
Checks if the cluster has a primary, and if not, transitions the topology
to ReplicaSetNoPrimary. Topology must be ReplicaSetWithPrimary when
invoking this method.
Checks if the cluster has a primary and if not transitions the topology to ReplicaSetNoPrimary . Topology must be ReplicaSetWithPrimary when invoking this method .
def check_if_has_primary
      unless topology.replica_set?
        raise ArgumentError, "check_if_has_primary should only be called when topology is replica set, but it is #{topology.class.name.sub(/.*::/, '')}"
      end
      primary = servers_list.detect do |server|
        server.primary? && server.description.replica_set_name == topology.replica_set_name
      end
      unless primary
        @topology = Topology::ReplicaSetNoPrimary.new(
          topology.options, topology.monitoring, self)
      end
    end
def check_if_has_primary unless topology . replica_set? raise ArgumentError , "check_if_has_primary should only be called when topology is replica set, but it is #{topology.class.name.sub(/.*::/, '')}" end primary = servers_list . detect do | server | server . primary? && server . description . replica_set_name == topology . replica_set_name end unless primary @topology = Topology :: ReplicaSetNoPrimary . new ( topology . options , topology . monitoring , self ) end end
Checks if the cluster has a primary, and if not, transitions the topology
to ReplicaSetNoPrimary.
Checks if the cluster has a primary and if not transitions the topology to ReplicaSetNoPrimary .
# A primary with the wrong set name is not a primary