Skip to content

Commit

Permalink
lb/translation: store ANALYTICS_ID and GENERATOR in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 2, 2024
1 parent 74673db commit 8d710cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cm4all-beng-proxy (18.2) unstable; urgency=low

* spawn: do not log "failed to kill: No such process"
* lb/translation: store ANALYTICS_ID and GENERATOR in the cache

--

Expand Down
6 changes: 6 additions & 0 deletions src/lb/TranslationCache.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ LbTranslationCache::Item::Item(const TranslateResponse &response) noexcept

if (response.site != nullptr)
site = response.site;

if (response.analytics_id != nullptr)
analytics_id = response.analytics_id;

if (response.generator != nullptr)
generator = response.generator;
}

CacheStats
Expand Down
5 changes: 3 additions & 2 deletions src/lb/TranslationCache.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ public:

HttpStatus status = {};
uint16_t https_only = 0;
std::string redirect, message, pool, canonical_host, site;
std::string redirect, message, pool, canonical_host, site, analytics_id, generator;

[[nodiscard]]
explicit Item(const TranslateResponse &response) noexcept;

[[gnu::pure]]
size_t GetAllocatedMemory() const noexcept {
return sizeof(*this) + redirect.length() + message.length() +
pool.length() + canonical_host.length() + site.length();
pool.length() + canonical_host.length() + site.length() +
analytics_id.length() + generator.length();
}

struct GetSite {
Expand Down
2 changes: 2 additions & 0 deletions src/lb/TranslationHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ LbTranslationHandler::Pick(struct pool &pool, const IncomingHttpRequest &request
response.message = item->message.empty() ? nullptr : item->message.c_str();
response.pool = item->pool.empty() ? nullptr : item->pool.c_str();
response.canonical_host = item->canonical_host.empty() ? nullptr : item->canonical_host.c_str();
response.analytics_id = item->analytics_id.empty() ? nullptr : item->analytics_id.c_str();
response.generator = item->generator.empty() ? nullptr : item->generator.c_str();

handler.OnTranslateResponse(std::move(_response));
return;
Expand Down

0 comments on commit 8d710cf

Please sign in to comment.