api: Register token-metadata API next to token-metadata itsels

Right now API registration happens quite late because it waits storage
service to register its "function" first. This can be done beforeheand
and the t.m. API can be moved to where it should be.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2024-07-10 08:34:38 +03:00
parent 10566256fd
commit 6ae09cc6bf
2 changed files with 9 additions and 8 deletions

View File

@@ -73,6 +73,8 @@ future<> set_server_init(http_context& ctx) {
set_error_injection(ctx, r);
rb->register_function(r, "storage_proxy",
"The storage proxy API");
rb->register_function(r, "storage_service",
"The storage service API");
});
}
@@ -115,7 +117,7 @@ future<> unset_thrift_controller(http_context& ctx) {
}
future<> set_server_storage_service(http_context& ctx, sharded<service::storage_service>& ss, service::raft_group0_client& group0_client) {
return register_api(ctx, "storage_service", "The storage service API", [&ss, &group0_client] (http_context& ctx, routes& r) {
return ctx.http_server.set_routes([&ctx, &ss, &group0_client] (routes& r) {
set_storage_service(ctx, r, ss, group0_client);
});
}

13
main.cc
View File

@@ -985,6 +985,12 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
// token_metadata.stop().get();
//});
api::set_server_token_metadata(ctx, token_metadata).get();
auto stop_tokens_api = defer_verbose_shutdown("token metadata API", [&ctx] {
api::unset_server_token_metadata(ctx).get();
});
supervisor::notify("starting effective_replication_map factory");
erm_factory.start().get();
auto stop_erm_factory = deferred_stop(erm_factory);
@@ -1492,13 +1498,6 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
tablet_allocator.stop().get();
});
// FIXME -- this can happen next to token_metadata start, but it needs "storage_service"
// API register, so it comes that late for now
api::set_server_token_metadata(ctx, token_metadata).get();
auto stop_tokens_api = defer_verbose_shutdown("token metadata API", [&ctx] {
api::unset_server_token_metadata(ctx).get();
});
supervisor::notify("starting mapreduce service");
mapreduce_service.start(std::ref(messaging), std::ref(proxy), std::ref(db), std::ref(token_metadata), std::ref(stop_signal.as_sharded_abort_source())).get();
auto stop_mapreduce_service_handlers = defer_verbose_shutdown("mapreduce service", [&mapreduce_service] {