API: Adding stub implementation for the cache service

This adds a stub implementation for the cache_service. It also register
the API doc.
The cache_service doc will be available at:
http://localhost:10000/api-doc/cache_service/

The stub implementation returns the correct value type with stubbed
values.

After this patch the following path will be available:
/cache_service/row_cache_save_period
/cache_service/key_cache_save_period
/cache_service/counter_cache_save_period
/cache_service/row_cache_keys_to_save
/cache_service/key_cache_keys_to_save
/cache_service/counter_cache_keys_to_save
/cache_service/invalidate_key_cache
/cache_service/invalidate_counter_cache
/cache_service/row_cache_capacity
/cache_service/key_cache_capacity
/cache_service/counter_cache_capacity
/cache_service/save_caches

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
Amnon Heiman
2015-06-24 14:30:08 +03:00
parent d4b5e65b7c
commit 4258b005db
4 changed files with 137 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
#include "column_family.hh"
#include "messaging_service.hh"
#include "storage_proxy.hh"
#include "cache_service.hh"
namespace api {
@@ -40,7 +41,9 @@ future<> set_server(http_context& ctx) {
set_messaging_service(ctx, r);
rb->register_function(r, "storage_proxy",
"The storage proxy API");
set_storage_proxy(ctx,r);
rb->register_function(r, "cache_service",
"The cache service API");
set_cache_service(ctx,r);
});
}

114
api/cache_service.cc Normal file
View File

@@ -0,0 +1,114 @@
/*
* Copyright 2015 Cloudius Systems
*/
#include "cache_service.hh"
#include "api/api-doc/cache_service.json.hh"
namespace api {
namespace cs = httpd::cache_service_json;
void set_cache_service(http_context& ctx, routes& r) {
cs::get_row_cache_save_period_in_seconds.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>(0);
});
cs::set_row_cache_save_period_in_seconds.set(r, [](std::unique_ptr<request> req) {
// TBD
auto period = req->get_query_param("period");
return make_ready_future<json::json_return_type>("");
});
cs::get_key_cache_save_period_in_seconds.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>(0);
});
cs::set_key_cache_save_period_in_seconds.set(r, [](std::unique_ptr<request> req) {
// TBD
auto period = req->get_query_param("period");
return make_ready_future<json::json_return_type>("");
});
cs::get_counter_cache_save_period_in_seconds.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>(0);
});
cs::set_counter_cache_save_period_in_seconds.set(r, [](std::unique_ptr<request> req) {
// TBD
auto ccspis = req->get_query_param("ccspis");
return make_ready_future<json::json_return_type>("");
});
cs::get_row_cache_keys_to_save.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>(0);
});
cs::set_row_cache_keys_to_save.set(r, [](std::unique_ptr<request> req) {
// TBD
auto rckts = req->get_query_param("rckts");
return make_ready_future<json::json_return_type>("");
});
cs::get_key_cache_keys_to_save.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>(0);
});
cs::set_key_cache_keys_to_save.set(r, [](std::unique_ptr<request> req) {
// TBD
auto kckts = req->get_query_param("kckts");
return make_ready_future<json::json_return_type>("");
});
cs::get_counter_cache_keys_to_save.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>(0);
});
cs::set_counter_cache_keys_to_save.set(r, [](std::unique_ptr<request> req) {
// TBD
auto cckts = req->get_query_param("cckts");
return make_ready_future<json::json_return_type>("");
});
cs::invalidate_key_cache.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>("");
});
cs::invalidate_counter_cache.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>("");
});
cs::set_row_cache_capacity_in_mb.set(r, [](std::unique_ptr<request> req) {
// TBD
auto capacity = req->get_query_param("capacity");
return make_ready_future<json::json_return_type>("");
});
cs::set_key_cache_capacity_in_mb.set(r, [](std::unique_ptr<request> req) {
// TBD
auto period = req->get_query_param("period");
return make_ready_future<json::json_return_type>("");
});
cs::set_counter_cache_capacity_in_mb.set(r, [](std::unique_ptr<request> req) {
// TBD
auto capacity = req->get_query_param("capacity");
return make_ready_future<json::json_return_type>("");
});
cs::save_caches.set(r, [](std::unique_ptr<request> req) {
// TBD
return make_ready_future<json::json_return_type>("");
});
}
}

18
api/cache_service.hh Normal file
View File

@@ -0,0 +1,18 @@
/*
* Copyright 2015 Cloudius Systems
*/
#ifndef API_CACHE_SERVICE_HH_
#define API_CACHE_SERVICE_HH_
#include "api.hh"
namespace api {
void set_cache_service(http_context& ctx, routes& r);
}
#endif /* API_CACHE_SERVICE_HH_ */

View File

@@ -325,6 +325,7 @@ api = ['api/api.cc',
'api/api-doc/storage_proxy.json',
'api/storage_proxy.cc',
'api/api-doc/cache_service.json',
'api/cache_service.cc',
]
boost_test_lib = [