diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-24 21:28:56 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-24 21:33:13 +0100 |
commit | 897546d596d8d7213cff60146123bb8f97d4d1cc (patch) | |
tree | aa3ec6a8db09d6eaf915805986e57d691c7d11f6 /src/ingestor.cpp | |
parent | 71803b97f1c9e31f2027da48bb742353f9c43e62 (diff) | |
download | webstat-897546d596d8d7213cff60146123bb8f97d4d1cc.tar.bz2 webstat-897546d596d8d7213cff60146123bb8f97d4d1cc.tar.xz webstat-897546d596d8d7213cff60146123bb8f97d4d1cc.zip |
Create settings structure
Holds all the settings and their defaults for use in program_options and
tests. Disables missing-field-initializers in tests because its over
sensitive to structures with defaults where you only provide some values
specifically.
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r-- | src/ingestor.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp index db5f317..db11799 100644 --- a/src/ingestor.cpp +++ b/src/ingestor.cpp @@ -58,8 +58,17 @@ namespace WebStat { } } - Ingestor::Ingestor(const utsname & host, DB::ConnectionPoolPtr dbpl) : - dbpool {std::move(dbpl)}, hostnameId {crc32(host.nodename)}, curl {curl_multi_init()} + Ingestor::Ingestor(const utsname & host, IngestorSettings settings) : + Ingestor {host, + std::make_shared<DB::ConnectionPool>( + settings.dbMax, settings.dbKeep, settings.dbType, settings.dbConnStr), + std::move(settings)} + { + } + + Ingestor::Ingestor(const utsname & host, DB::ConnectionPoolPtr dbpl, IngestorSettings settings) : + settings {std::move(settings)}, dbpool {std::move(dbpl)}, hostnameId {crc32(host.nodename)}, + curl {curl_multi_init()} { auto dbconn = dbpool->get(); auto ins = dbconn->modify(SQL::HOST_UPSERT, SQL::HOST_UPSERT_OPTS); @@ -202,7 +211,7 @@ namespace WebStat { if (insert->execute() > 0) { switch (type) { case EntityType::UserAgent: { - auto curlOp = curlGetUserAgentDetail(entityId, value, userAgentAPI.c_str()); + auto curlOp = curlGetUserAgentDetail(entityId, value, settings.userAgentAPI.c_str()); auto added = curlOperations.emplace(curlOp->hnd.get(), std::move(curlOp)); curl_multi_add_handle(curl.get(), added.first->first); break; |