diff options
author | aozeritsky <aozeritsky@yandex-team.ru> | 2022-02-10 16:46:40 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:40 +0300 |
commit | b036a557f285146e5e35d4213e29a094ab907bcf (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/grpc/server | |
parent | 4a6816dea1bcaee46ce29a51a5fd7d3495012858 (diff) | |
download | ydb-b036a557f285146e5e35d4213e29a094ab907bcf.tar.gz |
Restoring authorship annotation for <aozeritsky@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/grpc/server')
-rw-r--r-- | library/cpp/grpc/server/grpc_server.cpp | 36 | ||||
-rw-r--r-- | library/cpp/grpc/server/grpc_server.h | 22 |
2 files changed, 29 insertions, 29 deletions
diff --git a/library/cpp/grpc/server/grpc_server.cpp b/library/cpp/grpc/server/grpc_server.cpp index 8863c80832..7437b7a8f5 100644 --- a/library/cpp/grpc/server/grpc_server.cpp +++ b/library/cpp/grpc/server/grpc_server.cpp @@ -56,22 +56,22 @@ void TGRpcServer::Start() { using grpc::ServerBuilder; using grpc::ResourceQuota; ServerBuilder builder; - auto credentials = grpc::InsecureServerCredentials(); - if (Options_.SslData) { + auto credentials = grpc::InsecureServerCredentials(); + if (Options_.SslData) { grpc::SslServerCredentialsOptions::PemKeyCertPair keycert; keycert.cert_chain = std::move(Options_.SslData->Cert); keycert.private_key = std::move(Options_.SslData->Key); grpc::SslServerCredentialsOptions sslOps; sslOps.pem_root_certs = std::move(Options_.SslData->Root); sslOps.pem_key_cert_pairs.push_back(keycert); - credentials = grpc::SslServerCredentials(sslOps); - } - if (Options_.ExternalListener) { - Options_.ExternalListener->Init(builder.experimental().AddExternalConnectionAcceptor( - ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD, - credentials - )); - } else { + credentials = grpc::SslServerCredentials(sslOps); + } + if (Options_.ExternalListener) { + Options_.ExternalListener->Init(builder.experimental().AddExternalConnectionAcceptor( + ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD, + credentials + )); + } else { builder.AddListeningPort(server_address, credentials); } builder.SetMaxReceiveMessageSize(Options_.MaxMessageSize); @@ -171,10 +171,10 @@ void TGRpcServer::Start() { })); } } - - if (Options_.ExternalListener) { - Options_.ExternalListener->Start(); - } + + if (Options_.ExternalListener) { + Options_.ExternalListener->Start(); + } } void TGRpcServer::Stop() { @@ -223,10 +223,10 @@ void TGRpcServer::Stop() { } Ts.clear(); - - if (Options_.ExternalListener) { - Options_.ExternalListener->Stop(); - } + + if (Options_.ExternalListener) { + Options_.ExternalListener->Stop(); + } } ui16 TGRpcServer::GetPort() const { diff --git a/library/cpp/grpc/server/grpc_server.h b/library/cpp/grpc/server/grpc_server.h index 9cb55e3154..d6814a90a0 100644 --- a/library/cpp/grpc/server/grpc_server.h +++ b/library/cpp/grpc/server/grpc_server.h @@ -27,15 +27,15 @@ struct TSslData { TString Root; }; -struct IExternalListener - : public TThrRefBase -{ - using TPtr = TIntrusivePtr<IExternalListener>; - virtual void Init(std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor> acceptor) = 0; - virtual void Start() = 0; - virtual void Stop() = 0; -}; - +struct IExternalListener + : public TThrRefBase +{ + using TPtr = TIntrusivePtr<IExternalListener>; + virtual void Init(std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor> acceptor) = 0; + virtual void Start() = 0; + virtual void Stop() = 0; +}; + //! Server's options. struct TServerOptions { #define DECLARE_FIELD(name, type, default) \ @@ -93,8 +93,8 @@ struct TServerOptions { //! Custom configurator for ServerBuilder. DECLARE_FIELD(ServerBuilderMutator, std::function<void(grpc::ServerBuilder&)>, [](grpc::ServerBuilder&){}); - DECLARE_FIELD(ExternalListener, IExternalListener::TPtr, nullptr); - + DECLARE_FIELD(ExternalListener, IExternalListener::TPtr, nullptr); + //! Logger which will be used to write logs about requests handling (iff appropriate log level is enabled). DECLARE_FIELD(Logger, TLoggerPtr, nullptr); |