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

@@ -23,6 +23,11 @@
#include "Idle.hxx"
#include "Stats.hxx"
#ifdef ENABLE_CURL
#include "RemoteTagCache.hxx"
#include "util/UriUtil.hxx"
#endif
#ifdef ENABLE_DATABASE
#include "db/DatabaseError.hxx"
@@ -114,3 +119,31 @@ Instance::LostNeighbor(gcc_unused const NeighborInfo &info) noexcept
}
#endif
#ifdef ENABLE_CURL
void
Instance::LookupRemoteTag(const char *uri) noexcept
{
if (!uri_has_scheme(uri))
return;
if (!remote_tag_cache)
remote_tag_cache = std::make_unique<RemoteTagCache>(event_loop,
*this);
remote_tag_cache->Lookup(uri);
}
void
Instance::OnRemoteTag(const char *uri, const Tag &tag) noexcept
{
if (!tag.IsDefined())
/* boring */
return;
for (auto &partition : partitions)
partition.TagModified(uri, tag);
}
#endif