diff --git a/message-queue/cpp/src/instance.cpp b/message-queue/cpp/src/instance.cpp index ce591d4..070d1b4 100644 --- a/message-queue/cpp/src/instance.cpp +++ b/message-queue/cpp/src/instance.cpp @@ -1,6 +1,8 @@ #include "./instance.hpp" -Instance::Instance() : prometheus(Prometheus(config)) {} +Instance::Instance() +: prometheus(Prometheus(config)), pg(Postgres(config)) +{} prometheus::Labels mk_labels(const Instance& app, const WorkerResult& wr, const SampleDesc& sdesc) { Labels labels = app.runtime.Map(); diff --git a/message-queue/cpp/src/instance.hpp b/message-queue/cpp/src/instance.hpp index 59acc38..1ff2672 100644 --- a/message-queue/cpp/src/instance.hpp +++ b/message-queue/cpp/src/instance.hpp @@ -4,6 +4,7 @@ #include #include "./config.hpp" +#include "./postgres.hpp" #include "./primitives.hpp" #include "./prometheus.hpp" #include "./runtime.hpp" @@ -15,6 +16,7 @@ class Instance { Config config; Runtime runtime; Prometheus prometheus; + Postgres pg; Instance(); }; diff --git a/message-queue/cpp/src/postgres.cpp b/message-queue/cpp/src/postgres.cpp new file mode 100644 index 0000000..05ba6ab --- /dev/null +++ b/message-queue/cpp/src/postgres.cpp @@ -0,0 +1,5 @@ +#include "postgres.hpp" + +Postgres::Postgres(Config &c) +: conn(connection("postgres://mq@localhost/mq")) { +} diff --git a/message-queue/cpp/src/postgres.hpp b/message-queue/cpp/src/postgres.hpp new file mode 100644 index 0000000..0220280 --- /dev/null +++ b/message-queue/cpp/src/postgres.hpp @@ -0,0 +1,24 @@ +#ifndef POSTGRES_CPP +#define POSTGRES_CPP + +#include + +#include + +#include "config.hpp" +#include "runtime.hpp" +#include "primitives.hpp" + +using namespace std; +using namespace pqxx; + +class Postgres { + connection conn; + optional runtime_id = nullopt; + +public: + Postgres(Config&); + void Push(Runtime&, SampleDesc&, Results&); +}; + +#endif diff --git a/message-queue/cpp/src/runtime.hpp b/message-queue/cpp/src/runtime.hpp index efa44af..e0d1f1c 100644 --- a/message-queue/cpp/src/runtime.hpp +++ b/message-queue/cpp/src/runtime.hpp @@ -45,4 +45,5 @@ class Runtime { return ss.str(); } }; + #endif