summaryrefslogtreecommitdiff
path: root/src/mongo/db/process_health/health_observer_registration.h
diff options
context:
space:
mode:
authorAndrew Shuvalov <andrew.shuvalov@mongodb.com>2021-09-14 17:07:17 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-14 17:29:39 +0000
commitf2b2fdd68de5fe88e21ea74d0736b365757d6543 (patch)
tree5906e7a0a319d6ef2367820a97a55121b94d1c30 /src/mongo/db/process_health/health_observer_registration.h
parent0b99ee14e9f3b13f42d9197d4361b5e50e34c17d (diff)
downloadmongo-f2b2fdd68de5fe88e21ea74d0736b365757d6543.tar.gz
SERVER-59912 changes in the base health package for the Ldap health observer
Diffstat (limited to 'src/mongo/db/process_health/health_observer_registration.h')
-rw-r--r--src/mongo/db/process_health/health_observer_registration.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/mongo/db/process_health/health_observer_registration.h b/src/mongo/db/process_health/health_observer_registration.h
index 332c2d12854..73dbc99d6e7 100644
--- a/src/mongo/db/process_health/health_observer_registration.h
+++ b/src/mongo/db/process_health/health_observer_registration.h
@@ -41,33 +41,30 @@ namespace process_health {
/**
* Registration mechanism for all health observers.
+ * This is static class not requiring an instance to work.
*/
class HealthObserverRegistration {
public:
- static HealthObserverRegistration* get(ServiceContext* svcCtx);
-
- explicit HealthObserverRegistration(ServiceContext* svcCtx);
-
/**
* Registers a factory method, which will be invoked later to instantiate the observer.
+ * This must be invoked by static initializers, the code is not internally synchronized.
*
* @param factoryCallback creates observer instance when invoked.
*/
- void registerObserverFactory(
- std::function<std::unique_ptr<HealthObserver>(ServiceContext* svcCtx)> factoryCallback);
+ static void registerObserverFactory(
+ std::function<std::unique_ptr<HealthObserver>(ClockSource* clockSource)> factoryCallback);
/**
* Invokes all registered factories and returns new instances.
* The ownership of all observers is transferred to the invoker.
*/
- std::vector<std::unique_ptr<HealthObserver>> instantiateAllObservers() const;
-
-private:
- ServiceContext* const _svcCtx;
+ static std::vector<std::unique_ptr<HealthObserver>> instantiateAllObservers(
+ ClockSource* clockSource);
- mutable Mutex _mutex =
- MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "HealthObserverRegistration::_mutex");
- std::vector<std::function<std::unique_ptr<HealthObserver>(ServiceContext* svcCtx)>> _factories;
+ /**
+ * Test-only method to cleanup the list of registered factories.
+ */
+ static void resetObserverFactoriesForTest();
};
} // namespace process_health