module Mongo::Operation::SessionsSupported
Shared behavior of operations that support a session.
@since 2.5.2
Constants
- READ_PREFERENCE
- ZERO_TIMESTAMP
Private Instance Methods
add_write_concern!(sel)
click to toggle source
# File lib/mongo/operation/shared/sessions_supported.rb, line 47 def add_write_concern!(sel) if write_concern sel[:writeConcern] = write_concern.options end end
apply_causal_consistency!(selector, server)
click to toggle source
# File lib/mongo/operation/shared/sessions_supported.rb, line 29 def apply_causal_consistency!(selector, server); end
apply_cluster_time!(selector, server)
click to toggle source
# File lib/mongo/operation/shared/sessions_supported.rb, line 35 def apply_cluster_time!(selector, server) if !server.standalone? cluster_time = [server.cluster_time, (session && session.cluster_time)].max_by do |doc| (doc && doc[Cluster::CLUSTER_TIME]) || ZERO_TIMESTAMP end if cluster_time && (cluster_time[Cluster::CLUSTER_TIME] > ZERO_TIMESTAMP) selector[CLUSTER_TIME] = cluster_time end end end
apply_session_id!(selector)
click to toggle source
# File lib/mongo/operation/shared/sessions_supported.rb, line 53 def apply_session_id!(selector) session.add_id!(selector) end
command(server)
click to toggle source
# File lib/mongo/operation/shared/sessions_supported.rb, line 57 def command(server) sel = selector(server) sel[:writeConcern] = write_concern.options if write_concern sel[Protocol::Msg::DATABASE_IDENTIFIER] = db_name sel[READ_PREFERENCE] = read.to_doc if read if server.features.sessions_enabled? apply_cluster_time!(sel, server) if acknowledged_write? && session sel[:txnNumber] = BSON::Int64.new(txn_num) if txn_num apply_session_id!(sel) apply_causal_consistency!(sel, server) end elsif session && session.explicit? apply_cluster_time!(sel, server) sel[:txnNumber] = BSON::Int64.new(txn_num) if txn_num apply_session_id!(sel) apply_causal_consistency!(sel, server) end sel end
flags()
click to toggle source
# File lib/mongo/operation/shared/sessions_supported.rb, line 31 def flags acknowledged_write? ? [:none] : [:more_to_come] end