Files
scylladb/api/commitlog.cc
Amnon Heiman c6723d2f61 Adding the commitlog API implementation
This adds the implementation of the commitlog API.
Current implementation contains:
/commitlog/segments/active
That returns a list of the active file names, and
/commitlog/segments/archiving
Which always return an empty list as we archiving is not supported at
the moment

The doc file is under:
/api-doc/commitlog

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-05-19 15:27:59 +03:00

36 lines
1.1 KiB
C++

/*
* Copyright 2015 Cloudius Systems
*/
#include "commitlog.hh"
#include <db/commitlog/commitlog.hh>
#include "api/api-doc/commitlog.json.hh"
#include <vector>
namespace api {
void set_commitlog(http_context& ctx, routes& r) {
httpd::commitlog_json::get_active_segment_names.set(r,
[&ctx](std::unique_ptr<request> req) {
auto res = make_shared<std::vector<sstring>>();
return ctx.db.map_reduce([res](std::vector<sstring> names) {
res->insert(res->end(), names.begin(), names.end());
}, [](database& db) {
if (db.commitlog() == nullptr) {
return make_ready_future<std::vector<sstring>>(std::vector<sstring>());
}
return make_ready_future<std::vector<sstring>>(db.commitlog()->get_active_segment_names());
}).then([res] {
return make_ready_future<json::json_return_type>(*res.get());
});
});
// We currently do not support archive segments
httpd::commitlog_json::get_archiving_segment_names.set(r, [](const_req req) {
std::vector<sstring> res;
return res;
});
}
}