Method: Mongo::Session#pin_to_server

Defined in:
lib/mongo/session.rb

#pin_to_server(server) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pins this session to the specified server, which should be a mongos.

Parameters:

  • server (Server)

    The server to pin this session to.

Since:

  • 2.5.0


828
829
830
831
832
833
834
835
836
837
838
# File 'lib/mongo/session.rb', line 828

def pin_to_server(server)
  if server.nil?
    raise ArgumentError, 'Cannot pin to a nil server'
  end
  if Lint.enabled?
    unless server.mongos?
      raise Error::LintError, "Attempted to pin the session to server #{server.summary} which is not a mongos"
    end
  end
  @pinned_server = server
end