From d3117520013d7ee0268e73cf8aaf3fb02e631a42 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Aug 2025 15:49:48 +0100 Subject: Pass a DB connection to Ingestor --- src/Jamfile.jam | 6 +++++- src/ingestor.cpp | 2 ++ src/ingestor.hpp | 6 +++++- src/webstat_logger_main.cpp | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Jamfile.jam b/src/Jamfile.jam index f63ff81..adbdc02 100644 --- a/src/Jamfile.jam +++ b/src/Jamfile.jam @@ -1,9 +1,13 @@ lib webstat : ingestor.cpp logTypes.cpp : . ..//adhocutil + ..//dbppcore ../thirdparty//scn ..//z : : . ; -exe webstat_logger : webstat_logger_main.cpp : webstat ; +exe webstat_logger : webstat_logger_main.cpp : + webstat + ..//dbpp-postgresql +; diff --git a/src/ingestor.cpp b/src/ingestor.cpp index 17310c2..d5dd4e2 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -38,6 +38,8 @@ namespace WebStat { } } + Ingestor::Ingestor(DB::ConnectionPtr dbconn) : dbconn {std::move(dbconn)} { } + Ingestor::ScanResult Ingestor::scanLogLine(std::string_view input) { diff --git a/src/ingestor.hpp b/src/ingestor.hpp index 9ae8130..8450e4f 100644 --- a/src/ingestor.hpp +++ b/src/ingestor.hpp @@ -2,13 +2,14 @@ #include "logTypes.hpp" #include +#include #include #include namespace WebStat { class Ingestor { public: - Ingestor() = default; + Ingestor(DB::ConnectionPtr dbconn); virtual ~Ingestor() = default; SPECIAL_MEMBERS_DEFAULT_MOVE_NO_COPY(Ingestor); @@ -26,5 +27,8 @@ namespace WebStat { size_t linesRead = 0; size_t linesParsed = 0; size_t linesDiscarded = 0; + + private: + DB::ConnectionPtr dbconn; }; } diff --git a/src/webstat_logger_main.cpp b/src/webstat_logger_main.cpp index c4d31d6..8f2d45a 100644 --- a/src/webstat_logger_main.cpp +++ b/src/webstat_logger_main.cpp @@ -1,7 +1,9 @@ #include "ingestor.hpp" +#include int main(int, char **) { - WebStat::Ingestor {}.ingestLog(stdin); + auto dbconn = std::make_shared("dbname=webstat user=webstat"); + WebStat::Ingestor {dbconn}.ingestLog(stdin); } -- cgit v1.2.3