Method: Mongo::Cluster#next_primary

Defined in:
lib/mongo/cluster.rb

#next_primary(ping = nil, session = nil, timeout: nil) ⇒ Mongo::Server

Get the next primary server we can send an operation to.

Examples:

Get the next primary server.

cluster.next_primary

Parameters:

  • ping (true, false) (defaults to: nil)

    Whether to ping the server before selection. Deprecated and ignored.

  • session (Session | nil) (defaults to: nil)

    Optional session to take into account for mongos pinning.

  • :timeout (Float | nil)

    Timeout in seconds for the operation, if any.

Returns:

Since:

  • 2.0.0



788
789
790
791
792
793
794
795
# File 'lib/mongo/cluster.rb', line 788

def next_primary(ping = nil, session = nil, timeout: nil)
  ServerSelector.primary.select_server(
    self,
    nil,
    session,
    timeout: timeout
  )
end