diff --git a/src/database.cc b/src/database.cc index 91dd3b5..6d05474 100644 --- a/src/database.cc +++ b/src/database.cc @@ -1,15 +1,36 @@ #include "database.hh" -seastar::future Database::stop() { return seastar::make_ready_future(true); } +#include "noidb.hh" -future Database::get(const sstring& key) { co_return key; } +seastar::future Database::stop() { + lg.info("Stopping the database."); + co_return true; +} -future Database::put(const sstring& key, sstring& val) { co_return true; } +future Database::get(const sstring& key) { + lg.info("get: {}", key); + co_return key; +} -future Database::post(const sstring& key, input_stream* val) { co_return true; } +future Database::put(const sstring& key, sstring& val) { + lg.info("put: {} -> {}", key, val); + co_return true; +} -future Database::del(const sstring& key) { co_return true; } +future Database::post(const sstring& key, input_stream* stream) { + sstring val; + while (auto buf = co_await stream->read()) { + val.append(buf.get(), buf.size()); + } + lg.info("post: {} -> {}", key, val); + co_return true; +} + +future Database::del(const sstring& key) { + lg.info("del: {}", key); + co_return true; +} GetHandler::GetHandler(Database& db) : db(db) {} diff --git a/src/noidb.cc b/src/noidb.cc index f61c190..4b88ad3 100644 --- a/src/noidb.cc +++ b/src/noidb.cc @@ -1,4 +1,6 @@ +#include "noidb.hh" + #include "database.hh" #include @@ -8,17 +10,16 @@ #include #include #include -#include #include using namespace seastar; using namespace httpd; -logger lg("noidb"); - namespace bpo = boost::program_options; +seastar::logger lg("noidb"); + int main(int argc, char** argv) { seastar::app_template app;