diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-08-01 15:50:37 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-08-02 19:21:34 -0400 |
commit | 68051585b17682c1e13acdf440b2c78868054513 (patch) | |
tree | 1b677a81d5ef5d801a69cd9ce7fa7a9d7aac6295 /src/mongo/db/sessions_collection.h | |
parent | 0eea3fc035718c7ae6fc570670f1c51f8f3d71a5 (diff) | |
download | mongo-68051585b17682c1e13acdf440b2c78868054513.tar.gz |
SERVER-29201 Implement SessionsCollectionStandalone
Diffstat (limited to 'src/mongo/db/sessions_collection.h')
-rw-r--r-- | src/mongo/db/sessions_collection.h | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/mongo/db/sessions_collection.h b/src/mongo/db/sessions_collection.h index 4a7503a293e..e1cda80934f 100644 --- a/src/mongo/db/sessions_collection.h +++ b/src/mongo/db/sessions_collection.h @@ -29,9 +29,14 @@ #pragma once #include "mongo/db/logical_session_id.h" +#include "mongo/stdx/functional.h" namespace mongo { +class BSONArrayBuilder; +class BSONObjBuilder; +class OperationContext; + /** * An abstract interface describing the entrypoint into the sessions collection. * @@ -42,37 +47,50 @@ class SessionsCollection { public: virtual ~SessionsCollection(); + static constexpr StringData kSessionsDb = "admin"_sd; + static constexpr StringData kSessionsCollection = "system.sessions"_sd; + static constexpr StringData kSessionsFullNS = "admin.system.sessions"_sd; + /** * Returns a LogicalSessionRecord for the given session id. This method * may run networking operations on the calling thread. */ - virtual StatusWith<LogicalSessionRecord> fetchRecord(LogicalSessionId id) = 0; - - /** - * Inserts the given record into the sessions collection. This method may run - * networking operations on the calling thread. - * - * Returns a DuplicateSession error if the session already exists in the - * sessions collection. - */ - virtual Status insertRecord(LogicalSessionRecord record) = 0; + virtual StatusWith<LogicalSessionRecord> fetchRecord(OperationContext* opCtx, + const LogicalSessionId& id) = 0; /** * Updates the last-use times on the given sessions to be greater than - * or equal to the current time. + * or equal to the given time. * * Returns a list of sessions for which no authoritative record was found, - * and hence were not refreshed. + * and hence were not refreshed. Returns an error if a networking issue occurred. */ - virtual LogicalSessionIdSet refreshSessions(LogicalSessionIdSet sessions) = 0; + virtual Status refreshSessions(OperationContext* opCtx, + const LogicalSessionRecordSet& sessions, + Date_t refreshTime) = 0; /** * Removes the authoritative records for the specified sessions. * * Implementations should perform authentication checks to ensure that * session records may only be removed if their owner is logged in. + * + * Returns an error if the removal fails, for example from a network error. + */ + virtual Status removeRecords(OperationContext* opCtx, const LogicalSessionIdSet& sessions) = 0; + +protected: + using SendBatchFn = stdx::function<Status(BSONObj batch)>; + + /** + * Formats and sends batches of refreshes for the given set of sessions. + */ + Status doRefresh(const LogicalSessionRecordSet& sessions, Date_t refreshTime, SendBatchFn send); + + /** + * Formats and sends batches of deletes for the given set of sessions. */ - virtual void removeRecords(LogicalSessionIdSet sessions) = 0; + Status doRemove(const LogicalSessionIdSet& sessions, SendBatchFn send); }; } // namespace mongo |