GRPC C++  1.26.0
external_connection_acceptor_impl.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_
20 #define SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_
21 
22 #include <memory>
23 
27 #include <grpcpp/server_builder.h>
29 
32 
33 namespace grpc {
34 namespace internal {
35 
37  : public std::enable_shared_from_this<ExternalConnectionAcceptorImpl> {
38  public:
40  const grpc::string& name,
42  std::shared_ptr<ServerCredentials> creds);
43  // Should only be called once.
44  std::unique_ptr<experimental::ExternalConnectionAcceptor> GetAcceptor();
45 
48 
49  void Shutdown();
50 
51  void Start();
52 
53  const char* name() { return name_.c_str(); }
54 
55  ServerCredentials* GetCredentials() { return creds_.get(); }
56 
58 
59  private:
60  const grpc::string name_;
61  std::shared_ptr<ServerCredentials> creds_;
62  grpc_core::TcpServerFdHandler* handler_ = nullptr; // not owned
63  grpc_core::Mutex mu_;
64  bool has_acceptor_ = false;
65  bool started_ = false;
66  bool shutdown_ = false;
67 };
68 
69 } // namespace internal
70 } // namespace grpc
71 
72 #endif // SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_
Definition: external_connection_acceptor_impl.h:37
const char * name()
Definition: external_connection_acceptor_impl.h:53
ExternalConnectionAcceptorImpl(const grpc::string &name, ServerBuilder::experimental_type::ExternalConnectionType type, std::shared_ptr< ServerCredentials > creds)
Definition: external_connection_acceptor_impl.cc:44
void Start()
Definition: external_connection_acceptor_impl.cc:83
void SetToChannelArgs(::grpc::ChannelArguments *args)
Definition: external_connection_acceptor_impl.cc:91
void Shutdown()
Definition: external_connection_acceptor_impl.cc:78
std::unique_ptr< experimental::ExternalConnectionAcceptor > GetAcceptor()
Definition: external_connection_acceptor_impl.cc:54
void HandleNewConnection(experimental::ExternalConnectionAcceptor::NewConnectionParameters *p)
Definition: external_connection_acceptor_impl.cc:62
ServerCredentials * GetCredentials()
Definition: external_connection_acceptor_impl.h:55
Definition: sync.h:40
Definition: tcp_server.h:55
Options for channel creation.
Definition: channel_arguments_impl.h:43
ExternalConnectionType
Definition: server_builder_impl.h:275
Wrapper around grpc_server_credentials, a way to authenticate a server.
Definition: server_credentials_impl.h:40
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
std::string string
Definition: config.h:35