|
Instead provide an accessor for each Component in VectorTime. This will make external usage less clunky:
auto now = VectorClock::get(opCtx)->getTime();
|
-auto clusterTime = now[VectorClock::Component::ClusterTime];
|
+auto clusterTime = now.clusterTime();
|
The accessors can also use an lvalue ref-qualifier to ensure that the current time is properly stored somewhere, ie. prevent the anti-pattern of:
auto clusterTime = VectorClock::get(opCtx)->getTime().clusterTime();
|
auto configTime = VectorClock::get(opCtx)->getTime().configTime();
|
// Cannot assume that configTime <= clusterTime.
|
which is potentially incorrect, relative to:
auto now = VectorClock::get(opCtx)->getTime();
|
auto clusterTime = now.clusterTime();
|
auto configTime = now.configTime();
|
// Must be true that configTime <= clusterTime.
|
The advanceTime_forTest will also need some consideration, likely by returning a temporary object that provides a mutator for each Component.
|