Merge pull request #18379 from grpc/grpc_namespace_server_initializer

Move ServerInitializer to grpc_impl namespace from grpc
pull/18419/head^2
Karthik Ravi Shankar 6 years ago committed by GitHub
commit 87c98ad3fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 1
      BUILD.gn
  3. 3
      CMakeLists.txt
  4. 3
      Makefile
  5. 1
      build.yaml
  6. 1
      gRPC-C++.podspec
  7. 9
      include/grpcpp/ext/proto_server_reflection_plugin.h
  8. 9
      include/grpcpp/impl/server_builder_plugin.h
  9. 31
      include/grpcpp/impl/server_initializer.h
  10. 57
      include/grpcpp/impl/server_initializer_impl.h
  11. 11
      include/grpcpp/server.h
  12. 6
      src/cpp/server/load_reporter/load_reporting_service_server_builder_plugin.h
  13. 2
      src/cpp/server/server_builder.cc
  14. 2
      src/cpp/server/server_cc.cc
  15. 1
      tools/doxygen/Doxyfile.c++
  16. 1
      tools/doxygen/Doxyfile.c++.internal
  17. 2
      tools/run_tests/generated/sources_and_headers.json

@ -240,6 +240,7 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/server_builder_option_impl.h",
"include/grpcpp/impl/server_builder_plugin.h",
"include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/server_initializer_impl.h",
"include/grpcpp/impl/service_type.h",
"include/grpcpp/impl/sync_cxx11.h",
"include/grpcpp/impl/sync_no_cxx11.h",

@ -1073,6 +1073,7 @@ config("grpc_config") {
"include/grpcpp/impl/server_builder_option_impl.h",
"include/grpcpp/impl/server_builder_plugin.h",
"include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/server_initializer_impl.h",
"include/grpcpp/impl/service_type.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/security/auth_context.h",

@ -3021,6 +3021,7 @@ foreach(_hdr
include/grpcpp/impl/server_builder_option_impl.h
include/grpcpp/impl/server_builder_plugin.h
include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/server_initializer_impl.h
include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
@ -3617,6 +3618,7 @@ foreach(_hdr
include/grpcpp/impl/server_builder_option_impl.h
include/grpcpp/impl/server_builder_plugin.h
include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/server_initializer_impl.h
include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
@ -4585,6 +4587,7 @@ foreach(_hdr
include/grpcpp/impl/server_builder_option_impl.h
include/grpcpp/impl/server_builder_plugin.h
include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/server_initializer_impl.h
include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h

@ -5352,6 +5352,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
@ -5956,6 +5957,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
@ -6873,6 +6875,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \

@ -1367,6 +1367,7 @@ filegroups:
- include/grpcpp/impl/server_builder_option_impl.h
- include/grpcpp/impl/server_builder_plugin.h
- include/grpcpp/impl/server_initializer.h
- include/grpcpp/impl/server_initializer_impl.h
- include/grpcpp/impl/service_type.h
- include/grpcpp/resource_quota.h
- include/grpcpp/resource_quota_impl.h

@ -106,6 +106,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/server_builder_option_impl.h',
'include/grpcpp/impl/server_builder_plugin.h',
'include/grpcpp/impl/server_initializer.h',
'include/grpcpp/impl/server_initializer_impl.h',
'include/grpcpp/impl/service_type.h',
'include/grpcpp/resource_quota.h',
'include/grpcpp/resource_quota_impl.h',

@ -22,8 +22,11 @@
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/config.h>
namespace grpc {
namespace grpc_impl {
class ServerInitializer;
}
namespace grpc {
class ProtoServerReflection;
} // namespace grpc
@ -34,8 +37,8 @@ class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin {
public:
ProtoServerReflectionPlugin();
::grpc::string name() override;
void InitServer(::grpc::ServerInitializer* si) override;
void Finish(::grpc::ServerInitializer* si) override;
void InitServer(::grpc_impl::ServerInitializer* si) override;
void Finish(::grpc_impl::ServerInitializer* si) override;
void ChangeArguments(const ::grpc::string& name, void* value) override;
bool has_async_methods() const override;
bool has_sync_methods() const override;

@ -23,10 +23,13 @@
#include <grpcpp/support/config.h>
namespace grpc_impl {
class ServerInitializer;
}
namespace grpc {
class ServerBuilder;
class ServerInitializer;
class ChannelArguments;
/// This interface is meant for internal usage only. Implementations of this
@ -44,10 +47,10 @@ class ServerBuilderPlugin {
/// InitServer will be called in ServerBuilder::BuildAndStart(), after the
/// Server instance is created.
virtual void InitServer(ServerInitializer* si) = 0;
virtual void InitServer(grpc_impl::ServerInitializer* si) = 0;
/// Finish will be called at the end of ServerBuilder::BuildAndStart().
virtual void Finish(ServerInitializer* si) = 0;
virtual void Finish(grpc_impl::ServerInitializer* si) = 0;
/// ChangeArguments is an interface that can be used in
/// ServerBuilderOption::UpdatePlugins

@ -1,6 +1,6 @@
/*
*
* Copyright 2016 gRPC authors.
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,36 +19,11 @@
#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_H
#define GRPCPP_IMPL_SERVER_INITIALIZER_H
#include <memory>
#include <vector>
#include <grpcpp/server.h>
#include <grpcpp/impl/server_initializer_impl.h>
namespace grpc {
class Server;
class Service;
class ServerInitializer {
public:
ServerInitializer(Server* server) : server_(server) {}
bool RegisterService(std::shared_ptr<Service> service) {
if (!server_->RegisterService(nullptr, service.get())) {
return false;
}
default_services_.push_back(service);
return true;
}
const std::vector<grpc::string>* GetServiceList() {
return &server_->services_;
}
private:
Server* server_;
std::vector<std::shared_ptr<Service> > default_services_;
};
typedef ::grpc_impl::ServerInitializer ServerInitializer;
} // namespace grpc

@ -0,0 +1,57 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H
#define GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H
#include <memory>
#include <vector>
#include <grpcpp/server.h>
namespace grpc {
class Server;
class Service;
} // namespace grpc
namespace grpc_impl {
class ServerInitializer {
public:
ServerInitializer(grpc::Server* server) : server_(server) {}
bool RegisterService(std::shared_ptr<grpc::Service> service) {
if (!server_->RegisterService(nullptr, service.get())) {
return false;
}
default_services_.push_back(service);
return true;
}
const std::vector<grpc::string>* GetServiceList() {
return &server_->services_;
}
private:
grpc::Server* server_;
std::vector<std::shared_ptr<grpc::Service> > default_services_;
};
} // namespace grpc_impl
#endif // GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H

@ -41,11 +41,14 @@
struct grpc_server;
namespace grpc_impl {
class ServerInitializer;
}
namespace grpc {
class AsyncGenericService;
class ServerContext;
class ServerInitializer;
/// Represents a gRPC server.
///
@ -199,7 +202,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
friend class AsyncGenericService;
friend class ServerBuilder;
friend class ServerInitializer;
friend class grpc_impl::ServerInitializer;
class SyncRequest;
class CallbackRequestBase;
@ -257,7 +260,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
CompletionQueue* CallbackCQ() override;
ServerInitializer* initializer();
grpc_impl::ServerInitializer* initializer();
// A vector of interceptor factory objects.
// This should be destroyed after health_check_service_ and this requirement
@ -321,7 +324,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
// Pointer to the wrapped grpc_server.
grpc_server* server_;
std::unique_ptr<ServerInitializer> server_initializer_;
std::unique_ptr<grpc_impl::ServerInitializer> server_initializer_;
std::unique_ptr<HealthCheckServiceInterface> health_check_service_;
bool health_check_service_disabled_;

@ -36,13 +36,13 @@ class LoadReportingServiceServerBuilderPlugin : public ServerBuilderPlugin {
grpc::string name() override { return "load_reporting_service"; }
// Creates a load reporting service.
void UpdateServerBuilder(grpc::ServerBuilder* builder) override;
void UpdateServerBuilder(ServerBuilder* builder) override;
// Registers the load reporter service.
void InitServer(grpc::ServerInitializer* si) override;
void InitServer(grpc_impl::ServerInitializer* si) override;
// Starts the load reporter service.
void Finish(grpc::ServerInitializer* si) override;
void Finish(grpc_impl::ServerInitializer* si) override;
void ChangeArguments(const grpc::string& name, void* value) override {}
void UpdateChannelArguments(grpc::ChannelArguments* args) override {}

@ -314,7 +314,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
sync_server_settings_.cq_timeout_msec, resource_quota_,
std::move(interceptor_creators_)));
ServerInitializer* initializer = server->initializer();
grpc_impl::ServerInitializer* initializer = server->initializer();
// Register all the completion queues with the server. i.e
// 1. sync_server_cqs: internal completion queues created IF this is a sync

@ -766,7 +766,7 @@ Server::Server(
shutdown_(false),
shutdown_notified_(false),
server_(nullptr),
server_initializer_(new ServerInitializer(this)),
server_initializer_(new grpc_impl::ServerInitializer(this)),
health_check_service_disabled_(false) {
g_gli_initializer.summon();
gpr_once_init(&g_once_init_callbacks, InitGlobalCallbacks);

@ -996,6 +996,7 @@ include/grpcpp/impl/server_builder_option.h \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \

@ -998,6 +998,7 @@ include/grpcpp/impl/server_builder_option.h \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \

@ -10112,6 +10112,7 @@
"include/grpcpp/impl/server_builder_option_impl.h",
"include/grpcpp/impl/server_builder_plugin.h",
"include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/server_initializer_impl.h",
"include/grpcpp/impl/service_type.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",
@ -10226,6 +10227,7 @@
"include/grpcpp/impl/server_builder_option_impl.h",
"include/grpcpp/impl/server_builder_plugin.h",
"include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/server_initializer_impl.h",
"include/grpcpp/impl/service_type.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",

Loading…
Cancel
Save