Method: Mongo::Session#validate_read_preference!
- Defined in:
- lib/mongo/session.rb
#validate_read_preference!(command) ⇒ 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.
Ensure that the read preference of a command primary.
918 919 920 921 922 923 924 925 926 927 928 929 |
# File 'lib/mongo/session.rb', line 918 def validate_read_preference!(command) return unless in_transaction? return unless command['$readPreference'] mode = command['$readPreference']['mode'] || command['$readPreference'][:mode] if mode && mode != 'primary' raise Mongo::Error::InvalidTransactionOperation.new( "read preference in a transaction must be primary (requested: #{mode})" ) end end |