Skip to content

Commit

Permalink
refactor(interactive): Remove some dummy code (#4298)
Browse files Browse the repository at this point in the history
As titled. Check the `graph_id` params in http_handler.
  • Loading branch information
zhanglei1949 authored Oct 28, 2024
1 parent 95a3d1e commit e10d273
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 192 deletions.
90 changes: 12 additions & 78 deletions flex/engines/http_server/actor/executor.act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,10 @@ seastar::future<query_result> executor::run_graph_db_query(
}

seastar::future<admin_query_result> executor::create_vertex(
graph_management_param&& param) {
std::string&& graph_id = std::move(param.content.first);
if (metadata_store_) {
auto running_graph_res = metadata_store_->GetRunningGraph();

if (!running_graph_res.ok() || running_graph_res.value() != graph_id)
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(
gs::Status(gs::StatusCode::NOT_FOUND,
"The queried graph is not running: " + graph_id)));
}
query_param&& param) {
rapidjson::Document input_json;
// Parse the input json
if (input_json.Parse(param.content.second.c_str()).HasParseError()) {
if (input_json.Parse(param.content.c_str()).HasParseError()) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(gs::Status(
gs::StatusCode::INVALID_SCHEMA,
Expand All @@ -89,20 +79,9 @@ seastar::future<admin_query_result> executor::create_vertex(
gs::Result<seastar::sstring>(result.status()));
}

seastar::future<admin_query_result> executor::create_edge(
graph_management_param&& param) {
std::string&& graph_id = std::move(param.content.first);
if (metadata_store_) {
auto running_graph_res = metadata_store_->GetRunningGraph();

if (!running_graph_res.ok() || running_graph_res.value() != graph_id)
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(
gs::Status(gs::StatusCode::NOT_FOUND,
"The queried graph is not running: " + graph_id)));
}
seastar::future<admin_query_result> executor::create_edge(query_param&& param) {
rapidjson::Document input_json;
if (input_json.Parse(param.content.second.c_str()).HasParseError()) {
if (input_json.Parse(param.content.c_str()).HasParseError()) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(gs::Status(
gs::StatusCode::INVALID_SCHEMA,
Expand All @@ -120,21 +99,10 @@ seastar::future<admin_query_result> executor::create_edge(
}

seastar::future<admin_query_result> executor::update_vertex(
graph_management_param&& param) {
std::string&& graph_id = std::move(param.content.first);
if (metadata_store_) {
auto running_graph_res = metadata_store_->GetRunningGraph();

if (!running_graph_res.ok() || running_graph_res.value() != graph_id) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(
gs::Status(gs::StatusCode::NOT_FOUND,
"The queried graph is not running: " + graph_id)));
}
}
query_param&& param) {
rapidjson::Document input_json;
// Parse the input json
if (input_json.Parse(param.content.second.c_str()).HasParseError()) {
if (input_json.Parse(param.content.c_str()).HasParseError()) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(gs::Status(
gs::StatusCode::INVALID_SCHEMA,
Expand All @@ -151,22 +119,10 @@ seastar::future<admin_query_result> executor::update_vertex(
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(result.status()));
}
seastar::future<admin_query_result> executor::update_edge(
graph_management_param&& param) {
std::string&& graph_id = std::move(param.content.first);
if (metadata_store_) {
auto running_graph_res = metadata_store_->GetRunningGraph();

if (!running_graph_res.ok() || running_graph_res.value() != graph_id) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(
gs::Status(gs::StatusCode::NOT_FOUND,
"The queried graph is not running: " + graph_id)));
}
}
seastar::future<admin_query_result> executor::update_edge(query_param&& param) {
rapidjson::Document input_json;
// Parse the input json
if (input_json.Parse(param.content.second.c_str()).HasParseError()) {
if (input_json.Parse(param.content.c_str()).HasParseError()) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(gs::Status(
gs::StatusCode::INVALID_SCHEMA,
Expand All @@ -186,19 +142,8 @@ seastar::future<admin_query_result> executor::update_edge(

seastar::future<admin_query_result> executor::get_vertex(
graph_management_query_param&& param) {
std::string&& graph_id = std::move(param.content.first);
if (metadata_store_) {
auto running_graph_res = metadata_store_->GetRunningGraph();

if (!running_graph_res.ok() || running_graph_res.value() != graph_id)
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(
gs::Status(gs::StatusCode::NOT_FOUND,
"The queried graph is not running: " + graph_id)));
}

std::unordered_map<std::string, std::string> params;
for (auto& [key, value] : param.content.second) {
for (auto& [key, value] : param.content) {
params[std::string(key)] = std::string(value);
}
auto result = gs::GraphDBOperations::GetVertex(
Expand All @@ -215,18 +160,8 @@ seastar::future<admin_query_result> executor::get_vertex(

seastar::future<admin_query_result> executor::get_edge(
graph_management_query_param&& param) {
std::string&& graph_id = std::move(param.content.first);
if (metadata_store_) {
auto running_graph_res = metadata_store_->GetRunningGraph();

if (!running_graph_res.ok() || running_graph_res.value() != graph_id)
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(
gs::Status(gs::StatusCode::NOT_FOUND,
"The queried graph is not running: " + graph_id)));
}
std::unordered_map<std::string, std::string> params;
for (auto& [key, value] : param.content.second) {
for (auto& [key, value] : param.content) {
params[std::string(key)] = std::string(value);
}
auto result = gs::GraphDBOperations::GetEdge(
Expand All @@ -242,14 +177,13 @@ seastar::future<admin_query_result> executor::get_edge(
}

seastar::future<admin_query_result> executor::delete_vertex(
graph_management_param&& param) {
query_param&& param) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(gs::Status(
gs::StatusCode::UNIMPLEMENTED, "delete_vertex is not implemented")));
}

seastar::future<admin_query_result> executor::delete_edge(
graph_management_param&& param) {
seastar::future<admin_query_result> executor::delete_edge(query_param&& param) {
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>(gs::Status(
gs::StatusCode::UNIMPLEMENTED, "delete_edge is not implemented")));
Expand Down
12 changes: 6 additions & 6 deletions flex/engines/http_server/actor/executor.act.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ class ANNOTATION(actor:impl) executor : public hiactor::actor {

seastar::future<query_result> ANNOTATION(actor:method) run_graph_db_query(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) create_vertex(graph_management_param&& param);
seastar::future<admin_query_result> ANNOTATION(actor:method) create_vertex(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) create_edge(graph_management_param&& param);
seastar::future<admin_query_result> ANNOTATION(actor:method) create_edge(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) delete_vertex(graph_management_param&& param);
seastar::future<admin_query_result> ANNOTATION(actor:method) delete_vertex(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) delete_edge(graph_management_param&& param);
seastar::future<admin_query_result> ANNOTATION(actor:method) delete_edge(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) update_vertex(graph_management_param&& param);
seastar::future<admin_query_result> ANNOTATION(actor:method) update_vertex(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) update_edge(graph_management_param&& param);
seastar::future<admin_query_result> ANNOTATION(actor:method) update_edge(query_param&& param);

seastar::future<admin_query_result> ANNOTATION(actor:method) get_vertex(graph_management_query_param&& param);

Expand Down
Loading

0 comments on commit e10d273

Please sign in to comment.