summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-08-23 15:49:48 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-08-25 16:01:28 +0100
commitd3117520013d7ee0268e73cf8aaf3fb02e631a42 (patch)
tree9e65a395a3ec3c88f2685c7960048d38e53c1a69
parent52f0880cd05d346120fb3a0a9310592d50ec8bcb (diff)
downloadwebstat-d3117520013d7ee0268e73cf8aaf3fb02e631a42.tar.bz2
webstat-d3117520013d7ee0268e73cf8aaf3fb02e631a42.tar.xz
webstat-d3117520013d7ee0268e73cf8aaf3fb02e631a42.zip
Pass a DB connection to Ingestor
-rw-r--r--src/Jamfile.jam6
-rw-r--r--src/ingestor.cpp2
-rw-r--r--src/ingestor.hpp6
-rw-r--r--src/webstat_logger_main.cpp4
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 :
<include>.
<library>..//adhocutil
+ <library>..//dbppcore
<library>../thirdparty//scn
<library>..//z
: :
<include>.
;
-exe webstat_logger : webstat_logger_main.cpp : <library>webstat ;
+exe webstat_logger : webstat_logger_main.cpp :
+ <library>webstat
+ <library>..//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 <c++11Helpers.h>
+#include <connection_fwd.h>
#include <cstdio>
#include <scn/scan.h>
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 <pq-connection.h>
int
main(int, char **)
{
- WebStat::Ingestor {}.ingestLog(stdin);
+ auto dbconn = std::make_shared<PQ::Connection>("dbname=webstat user=webstat");
+ WebStat::Ingestor {dbconn}.ingestLog(stdin);
}