GRPC C++  1.39.1
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 
26 #include <grpcpp/server_builder.h>
28 
31 
32 namespace grpc {
33 namespace internal {
34 
36  : public std::enable_shared_from_this<ExternalConnectionAcceptorImpl> {
37  public:
39  const std::string& name,
41  std::shared_ptr<ServerCredentials> creds);
42  // Should only be called once.
43  std::unique_ptr<experimental::ExternalConnectionAcceptor> GetAcceptor();
44 
47 
48  void Shutdown();
49 
50  void Start();
51 
52  const char* name() { return name_.c_str(); }
53 
54  ServerCredentials* GetCredentials() { return creds_.get(); }
55 
57 
58  private:
59  const std::string name_;
60  std::shared_ptr<ServerCredentials> creds_;
61  grpc_core::TcpServerFdHandler* handler_ = nullptr; // not owned
62  grpc_core::Mutex mu_;
63  bool has_acceptor_ = false;
64  bool started_ = false;
65  bool shutdown_ = false;
66 };
67 
68 } // namespace internal
69 } // namespace grpc
70 
71 #endif // SRC_CPP_SERVER_EXTERNAL_CONNECTION_ACCEPTOR_IMPL_H_
Options for channel creation.
Definition: channel_arguments.h:39
ExternalConnectionType
Definition: server_builder.h:267
Wrapper around grpc_server_credentials, a way to authenticate a server.
Definition: server_credentials.h:70
Definition: external_connection_acceptor_impl.h:36
const char * name()
Definition: external_connection_acceptor_impl.h:52
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:54
ExternalConnectionAcceptorImpl(const std::string &name, ServerBuilder::experimental_type::ExternalConnectionType type, std::shared_ptr< ServerCredentials > creds)
Definition: external_connection_acceptor_impl.cc:44
Definition: sync.h:59
Definition: tcp_server.h:57
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
DiscoveryMechanismType type
Definition: xds_cluster_resolver.cc:73