diff options
author | Andrew Shuvalov <andrew.shuvalov@mongodb.com> | 2021-09-14 17:07:17 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-14 17:29:39 +0000 |
commit | f2b2fdd68de5fe88e21ea74d0736b365757d6543 (patch) | |
tree | 5906e7a0a319d6ef2367820a97a55121b94d1c30 /src/mongo/db/process_health/health_observer_registration.h | |
parent | 0b99ee14e9f3b13f42d9197d4361b5e50e34c17d (diff) | |
download | mongo-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.h | 23 |
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 |