summaryrefslogtreecommitdiff
path: root/src/mongo/db/logical_session_record.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/logical_session_record.h')
-rw-r--r--src/mongo/db/logical_session_record.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/mongo/db/logical_session_record.h b/src/mongo/db/logical_session_record.h
index 7ab60dc94dd..e576cd82eb5 100644
--- a/src/mongo/db/logical_session_record.h
+++ b/src/mongo/db/logical_session_record.h
@@ -71,7 +71,8 @@ public:
*/
static LogicalSessionRecord makeAuthoritativeRecord(LogicalSessionId id,
UserName user,
- boost::optional<OID> userId);
+ boost::optional<OID> userId,
+ Date_t now);
/**
* Return a BSON representation of this session record.
@@ -79,6 +80,19 @@ public:
BSONObj toBSON() const;
/**
+ * Return a string represenation of this session record.
+ */
+ std::string toString() const;
+
+ inline bool operator==(const LogicalSessionRecord& rhs) const {
+ return getLsid() == rhs.getLsid() && getSessionOwner() == rhs.getSessionOwner();
+ }
+
+ inline bool operator!=(const LogicalSessionRecord& rhs) const {
+ return !(*this == rhs);
+ }
+
+ /**
* Return the username and id of the User who owns this session. Only a User
* that matches both the name and id returned by this method should be
* permitted to use this session.
@@ -93,9 +107,20 @@ public:
private:
LogicalSessionRecord() = default;
- LogicalSessionRecord(LogicalSessionId id, UserName user, boost::optional<OID> userId);
+ LogicalSessionRecord(LogicalSessionId id,
+ UserName user,
+ boost::optional<OID> userId,
+ Date_t now);
Owner _owner;
};
+inline std::ostream& operator<<(std::ostream& s, const LogicalSessionRecord& record) {
+ return (s << record.toString());
+}
+
+inline StringBuilder& operator<<(StringBuilder& s, const LogicalSessionRecord& record) {
+ return (s << record.toString());
+}
+
} // namespace mongo