summaryrefslogtreecommitdiff
path: root/src/mongo/db/vector_clock.h
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2020-07-07 11:45:40 +0200
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-07 10:18:44 +0000
commitff4465b905b331fc82edb8194092917ad0c7255f (patch)
tree15f837e1f1c701a680d0335ecbe727fad0075098 /src/mongo/db/vector_clock.h
parentb887370e6772548bf91a3816fa2c8a25a49e9f61 (diff)
downloadmongo-ff4465b905b331fc82edb8194092917ad0c7255f.tar.gz
SERVER-49315 Allow definition of custom vector clock gossip formats
Diffstat (limited to 'src/mongo/db/vector_clock.h')
-rw-r--r--src/mongo/db/vector_clock.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/mongo/db/vector_clock.h b/src/mongo/db/vector_clock.h
index a55f3c037f5..6434cd3aa6b 100644
--- a/src/mongo/db/vector_clock.h
+++ b/src/mongo/db/vector_clock.h
@@ -54,7 +54,7 @@ public:
_kNumComponents = 3,
};
-private:
+protected:
template <typename T>
class ComponentArray
: public std::array<T, static_cast<unsigned long>(Component::_kNumComponents)> {
@@ -76,7 +76,6 @@ private:
T& operator[](unsigned long i);
};
-protected:
using LogicalTimeArray = ComponentArray<LogicalTime>;
public:
@@ -137,6 +136,28 @@ public:
void advanceTime_forTest(Component component, LogicalTime newTime);
protected:
+ class ComponentFormat {
+
+ public:
+ ComponentFormat(std::string fieldName) : _fieldName(fieldName) {}
+ virtual ~ComponentFormat() = default;
+
+ // Returns true if the time was output, false otherwise.
+ virtual bool out(ServiceContext* service,
+ OperationContext* opCtx,
+ bool permitRefresh,
+ BSONObjBuilder* out,
+ LogicalTime time,
+ Component component) const = 0;
+ virtual LogicalTime in(ServiceContext* service,
+ OperationContext* opCtx,
+ const BSONObj& in,
+ bool couldBeUnauthenticated,
+ Component component) const = 0;
+
+ const std::string _fieldName;
+ };
+
VectorClock();
virtual ~VectorClock();
@@ -258,7 +279,12 @@ protected:
bool _isEnabled{true};
private:
- class GossipFormat;
+ class PlainComponentFormat;
+ class SignedComponentFormat;
+ template <class ActualFormat>
+ class OnlyOutOnNewFCVComponentFormat;
+
+ static const ComponentArray<std::unique_ptr<ComponentFormat>> _gossipFormatters;
};
} // namespace mongo