// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "ifetchercallback.h" #include "ihandle.h" #include #include #include namespace config { class IConfigContext; class ConfigSubscriber; /** * A config poller runs a polling sequence on a set of configs that it has * subscribed to. */ class ConfigPoller : public vespalib::Runnable { public: ConfigPoller(std::shared_ptr context); ~ConfigPoller() override; void run() override; template void subscribe(const std::string & configId, IFetcherCallback * callback, vespalib::duration subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); void poll(); void close(); int64_t getGeneration() const { return _generation; } private: int64_t _generation; std::unique_ptr _subscriber; std::vector _handleList; std::vector _callbackList; }; } // namespace config