// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include #include #include #include #include namespace config { class ConfigPoller; class IConfigContext; /** * A config fetcher subscribes to a config and notifies a callback when done */ class ConfigFetcher { public: ConfigFetcher(std::shared_ptr context); ConfigFetcher(const SourceSpec & spec = ServerSpec()); ~ConfigFetcher(); template void subscribe(const std::string & configId, IFetcherCallback * callback, vespalib::duration subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); void start(); void close(); int64_t getGeneration() const; private: std::unique_ptr _poller; std::thread _thread; std::atomic _closed; std::atomic _started; }; } // namespace config