mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-05-31 17:53:59 +00:00
* Update class diagrams * Implement BoundedChannel and multithreaded logging infra * Integrate logging channel system * Update string concatenations to use std::format * Add pretty print log
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_
|
|
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_
|
|
|
|
/**
|
|
* @file services/wikipedia_service.h
|
|
* @brief Wikipedia summary retrieval service with in-memory caching.
|
|
*/
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <unordered_map>
|
|
|
|
#include "enrichment_service.h"
|
|
#include "services/logging/logger.h"
|
|
#include "web_client/web_client.h"
|
|
|
|
/// @brief Provides Wikipedia summary lookups backed by cached raw extracts.
|
|
class WikipediaEnrichmentService final : public IEnrichmentService {
|
|
public:
|
|
/// @brief Creates a new Wikipedia service with the provided web client.
|
|
explicit WikipediaEnrichmentService(std::unique_ptr<WebClient> client,
|
|
std::shared_ptr<ILogger> logger);
|
|
|
|
/// @brief Returns the Wikipedia-derived context for a location.
|
|
[[nodiscard]] std::string GetLocationContext(const Location& loc) override;
|
|
|
|
private:
|
|
std::string FetchExtract(std::string_view query);
|
|
std::unique_ptr<WebClient> client_;
|
|
std::shared_ptr<ILogger> logger_;
|
|
/// @brief Canonical cache for raw Wikipedia query extracts.
|
|
std::unordered_map<std::string, std::string> extract_cache_;
|
|
};
|
|
|
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_
|