#pragma once #include "logTypes.hpp" #include #include #include #include #include namespace WebStat { class Ingestor { public: Ingestor(std::string_view hostname, DB::ConnectionPtr dbconn); virtual ~Ingestor() = default; SPECIAL_MEMBERS_DEFAULT_MOVE_NO_COPY(Ingestor); using ScanResult = decltype(scn::scan(std::declval(), "")); using ScanValues = std::remove_cvref_t()->values())>; [[nodiscard]] static ScanResult scanLogLine(std::string_view); void ingestLog(std::FILE *); void ingestLogLine(std::string_view); template [[nodiscard]] size_t storeEntity(const T &) const; // NOLINTNEXTLINE(modernize-use-nodiscard); testing exposition only size_t storeEntity(Entity) const; // NOLINTNEXTLINE(modernize-use-nodiscard); testing exposition only size_t storeEntity(std::optional) const; template void storeLogLine(const std::tuple &) const; protected: size_t linesRead = 0; size_t linesParsed = 0; size_t linesDiscarded = 0; private: template size_t storeEntities(const std::tuple &) const; mutable std::flat_set existingEntities; uint32_t hostnameId; DB::ConnectionPtr dbconn; }; }