RemoteTagCache: new glue class for integrating RemoteTagScanner

This commit also puts an instance of RemoteTagScanner into the
Instance class, and hooks it into the "add" and "addid" commands.
This commit is contained in:
Max Kellermann
2018-01-29 12:02:14 +01:00
parent 7d16d8c887
commit ce2b6dc84d
11 changed files with 417 additions and 0 deletions

View File

@@ -26,6 +26,10 @@
#include "event/MaskMonitor.hxx"
#include "Compiler.h"
#ifdef ENABLE_CURL
#include "RemoteTagCacheHandler.hxx"
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
#include "neighbor/Listener.hxx"
class NeighborGlue;
@@ -38,11 +42,13 @@ class Storage;
class UpdateService;
#endif
#include <memory>
#include <list>
class ClientList;
struct Partition;
class StateFile;
class RemoteTagCache;
/**
* A utility class which, when used as the first base class, ensures
@@ -66,6 +72,9 @@ struct Instance final
#ifdef ENABLE_NEIGHBOR_PLUGINS
public NeighborListener
#endif
#ifdef ENABLE_CURL
, public RemoteTagCacheHandler
#endif
{
EventThread io_thread;
@@ -87,6 +96,10 @@ struct Instance final
UpdateService *update = nullptr;
#endif
#ifdef ENABLE_CURL
std::unique_ptr<RemoteTagCache> remote_tag_cache;
#endif
ClientList *client_list;
std::list<Partition> partitions;
@@ -139,6 +152,14 @@ struct Instance final
void FinishShutdownUpdate() noexcept;
void ShutdownDatabase() noexcept;
#ifdef ENABLE_CURL
void LookupRemoteTag(const char *uri) noexcept;
#else
void LookupRemoteTag(const char *) noexcept {
/* no-op */
}
#endif
private:
#ifdef ENABLE_DATABASE
void OnDatabaseModified() override;
@@ -151,6 +172,11 @@ private:
void LostNeighbor(const NeighborInfo &info) noexcept override;
#endif
#ifdef ENABLE_CURL
/* virtual methods from class RemoteTagCacheHandler */
void OnRemoteTag(const char *uri, const Tag &tag) noexcept override;
#endif
/* callback for #idle_monitor */
void OnIdle(unsigned mask);
};