|
|
|
@ -37,7 +37,6 @@ |
|
|
|
|
struct grpc_resource_quota; |
|
|
|
|
|
|
|
|
|
namespace grpc_impl { |
|
|
|
|
class ExternalConnectionAcceptorImpl; |
|
|
|
|
class ResourceQuota; |
|
|
|
|
class ServerCredentials; |
|
|
|
|
} // namespace grpc_impl
|
|
|
|
@ -52,13 +51,17 @@ namespace testing { |
|
|
|
|
class ServerBuilderPluginTest; |
|
|
|
|
} // namespace testing
|
|
|
|
|
|
|
|
|
|
namespace internal { |
|
|
|
|
class ExternalConnectionAcceptorImpl; |
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
|
|
namespace experimental { |
|
|
|
|
class CallbackGenericService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// EXPERIMENTAL API:
|
|
|
|
|
// Interface for a grpc server to handle connections created out of band.
|
|
|
|
|
// See ServerBuilder's AddExternalConnectionAcceptor API for usage.
|
|
|
|
|
// Interface for a grpc server to build transports with connections created out
|
|
|
|
|
// of band.
|
|
|
|
|
// See ServerBuilder's AddExternalConnectionAcceptor API.
|
|
|
|
|
class ExternalConnectionAcceptor { |
|
|
|
|
public: |
|
|
|
|
struct NewConnectionParameters { |
|
|
|
@ -66,11 +69,12 @@ class ExternalConnectionAcceptor { |
|
|
|
|
ByteBuffer read_buffer; // data intended for the grpc server
|
|
|
|
|
}; |
|
|
|
|
virtual ~ExternalConnectionAcceptor() {} |
|
|
|
|
// If called before grpc::Server is started, the new connection will be
|
|
|
|
|
// closed.
|
|
|
|
|
// If called before grpc::Server is started or after it is shut down, the new
|
|
|
|
|
// connection will be closed.
|
|
|
|
|
virtual void HandleNewConnection(NewConnectionParameters* p) = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} // namespace experimental
|
|
|
|
|
} // namespace grpc
|
|
|
|
|
|
|
|
|
|
namespace grpc_impl { |
|
|
|
@ -265,13 +269,15 @@ class ServerBuilder { |
|
|
|
|
ServerBuilder& RegisterCallbackGenericService( |
|
|
|
|
grpc::experimental::CallbackGenericService* service); |
|
|
|
|
|
|
|
|
|
enum ExternalConnectionType { |
|
|
|
|
enum class ExternalConnectionType { |
|
|
|
|
CONNECTION_FROM_FD = 0 // in the form of a file descriptor
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Create an acceptor to take in external connections and pass them to the
|
|
|
|
|
// gRPC server.
|
|
|
|
|
std::unique_ptr<grpc::ExternalConnectionAcceptor> |
|
|
|
|
/// Register an acceptor to handle the externally accepted connection in
|
|
|
|
|
/// grpc server. The returned acceptor can be used to pass the connection
|
|
|
|
|
/// to grpc server, where a channel will be created with the provided
|
|
|
|
|
/// server credentials.
|
|
|
|
|
std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor> |
|
|
|
|
AddExternalConnectionAcceptor(ExternalConnectionType type, |
|
|
|
|
std::shared_ptr<ServerCredentials> creds); |
|
|
|
|
|
|
|
|
@ -374,7 +380,8 @@ class ServerBuilder { |
|
|
|
|
std::vector< |
|
|
|
|
std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>> |
|
|
|
|
interceptor_creators_; |
|
|
|
|
std::vector<std::shared_ptr<ExternalConnectionAcceptorImpl>> acceptors_; |
|
|
|
|
std::vector<std::shared_ptr<grpc::internal::ExternalConnectionAcceptorImpl>> |
|
|
|
|
acceptors_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} // namespace grpc_impl
|
|
|
|
|