summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/resume_token.h
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@gmail.com>2018-11-27 13:21:29 +0000
committerBernard Gorman <bernard.gorman@gmail.com>2019-01-24 10:03:41 +0000
commit90cd49725f41354509dece813343c62e6ee9f533 (patch)
tree9e7cc3f465c28db548aebe54452ca86952fa8af6 /src/mongo/db/pipeline/resume_token.h
parentb023cfd4db379092f7642dd825d79652d905f847 (diff)
downloadmongo-90cd49725f41354509dece813343c62e6ee9f533.tar.gz
SERVER-38412 Allow resuming from a high-water-mark pseudo resume token
Diffstat (limited to 'src/mongo/db/pipeline/resume_token.h')
-rw-r--r--src/mongo/db/pipeline/resume_token.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/mongo/db/pipeline/resume_token.h b/src/mongo/db/pipeline/resume_token.h
index a50ac20d8b9..099f0dd7d92 100644
--- a/src/mongo/db/pipeline/resume_token.h
+++ b/src/mongo/db/pipeline/resume_token.h
@@ -50,32 +50,41 @@ struct ResumeTokenData {
kNotFromInvalidate = false,
};
+ /**
+ * Flag to indicate the type of resume token we are generating.
+ */
+ enum TokenType : int {
+ kHighWaterMarkToken = 0, // Token refers to a point in time, not an event.
+ kEventToken = 128, // Token refers to an actual event in the stream.
+ };
+
ResumeTokenData(){};
ResumeTokenData(Timestamp clusterTimeIn,
int versionIn,
size_t applyOpsIndexIn,
- Value documentKeyIn,
- const boost::optional<UUID>& uuidIn)
+ const boost::optional<UUID>& uuidIn,
+ Value documentKeyIn)
: clusterTime(clusterTimeIn),
version(versionIn),
applyOpsIndex(applyOpsIndexIn),
- documentKey(std::move(documentKeyIn)),
- uuid(uuidIn){};
+ uuid(uuidIn),
+ documentKey(std::move(documentKeyIn)){};
bool operator==(const ResumeTokenData& other) const;
bool operator!=(const ResumeTokenData& other) const {
return !(*this == other);
- };
+ }
Timestamp clusterTime;
int version = 1;
+ TokenType tokenType = TokenType::kEventToken;
size_t applyOpsIndex = 0;
- Value documentKey;
- boost::optional<UUID> uuid;
// Flag to indicate that this resume token is from an "invalidate" entry. This will not be set
// on a token from a command that *would* invalidate a change stream, but rather the invalidate
// notification itself.
FromInvalidate fromInvalidate = FromInvalidate::kNotFromInvalidate;
+ boost::optional<UUID> uuid;
+ Value documentKey;
};
std::ostream& operator<<(std::ostream& out, const ResumeTokenData& tokenData);
@@ -109,16 +118,16 @@ public:
static ResumeToken parse(const Document& document);
/**
- * Generate a high-water-mark pseudo-token for 'clusterTime', with no UUID or documentKey.
+ * Generate a high-water-mark token for 'clusterTime', with an optional UUID and no documentKey.
*/
- static ResumeToken makeHighWaterMarkResumeToken(Timestamp clusterTime);
+ static ResumeToken makeHighWaterMarkToken(Timestamp clusterTime, boost::optional<UUID> uuid);
/**
* Returns true if the given token data represents a valid high-water-mark resume token; that
* is, it does not refer to a specific operation, but instead specifies a clusterTime after
* which the stream should resume.
*/
- static bool isHighWaterMarkResumeToken(const ResumeTokenData& tokenData);
+ static bool isHighWaterMarkToken(const ResumeTokenData& tokenData);
/**
* The default no-argument constructor is required by the IDL for types used as non-optional