Remove experimental tag from uses of the C++ callback API (#26495)

pull/26519/head
Vijay Pai 3 years ago committed by GitHub
parent 64d1894314
commit cf1ebf7387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      include/grpcpp/alarm.h
  2. 7
      include/grpcpp/impl/codegen/async_generic_service.h
  3. 22
      include/grpcpp/impl/codegen/message_allocator.h
  4. 3
      include/grpcpp/impl/codegen/server_callback.h
  5. 19
      include/grpcpp/impl/codegen/server_callback_handlers.h
  6. 32
      include/grpcpp/impl/codegen/server_context.h
  7. 29
      include/grpcpp/impl/codegen/server_interface.h
  8. 45
      include/grpcpp/impl/codegen/service_type.h
  9. 46
      include/grpcpp/server.h
  10. 27
      include/grpcpp/server_builder.h
  11. 332
      src/compiler/cpp_generator.cc
  12. 26
      src/cpp/server/server_builder.cc
  13. 9
      src/cpp/server/server_cc.cc
  14. 407
      test/cpp/codegen/compiler_test_golden
  15. 5
      test/cpp/end2end/client_callback_end2end_test.cc
  16. 3
      test/cpp/end2end/xds_end2end_test.cc

@ -81,7 +81,6 @@ class Alarm : private ::grpc::GrpcLibraryCodegen {
/// has already fired has no effect. /// has already fired has no effect.
void Cancel(); void Cancel();
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
/// Set an alarm to invoke callback \a f. The argument to the callback /// Set an alarm to invoke callback \a f. The argument to the callback
/// states whether the alarm expired at \a deadline (true) or was cancelled /// states whether the alarm expired at \a deadline (true) or was cancelled
/// (false) /// (false)
@ -89,32 +88,6 @@ class Alarm : private ::grpc::GrpcLibraryCodegen {
void Set(const T& deadline, std::function<void(bool)> f) { void Set(const T& deadline, std::function<void(bool)> f) {
SetInternal(::grpc::TimePoint<T>(deadline).raw_time(), std::move(f)); SetInternal(::grpc::TimePoint<T>(deadline).raw_time(), std::move(f));
} }
#endif
/// NOTE: class experimental_type is not part of the public API of this class
/// TODO(vjpai): Move these contents to the public API of Alarm when
/// they are no longer experimental
class experimental_type {
public:
explicit experimental_type(Alarm* alarm) : alarm_(alarm) {}
/// Set an alarm to invoke callback \a f. The argument to the callback
/// states whether the alarm expired at \a deadline (true) or was cancelled
/// (false)
template <typename T>
void Set(const T& deadline, std::function<void(bool)> f) {
alarm_->SetInternal(::grpc::TimePoint<T>(deadline).raw_time(),
std::move(f));
}
private:
Alarm* alarm_;
};
/// NOTE: The function experimental() is not stable public API. It is a view
/// to the experimental components of this class. It may be changed or removed
/// at any time.
experimental_type experimental() { return experimental_type(this); }
private: private:
void SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline, void SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline,

@ -79,10 +79,6 @@ class AsyncGenericService final {
grpc::Server* server_; grpc::Server* server_;
}; };
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental {
#endif
/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs /// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs
/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with /// invoked on a CallbackGenericService. It is just a ServerBidi reactor with
/// ByteBuffer arguments. /// ByteBuffer arguments.
@ -134,9 +130,6 @@ class CallbackGenericService {
grpc::Server* server_{nullptr}; grpc::Server* server_{nullptr};
}; };
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
} // namespace experimental
#endif
} // namespace grpc } // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H #endif // GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H

@ -20,9 +20,6 @@
#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H #define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H
namespace grpc { namespace grpc {
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental {
#endif
// NOTE: This is an API for advanced users who need custom allocators. // NOTE: This is an API for advanced users who need custom allocators.
// Per rpc struct for the allocator. This is the interface to return to user. // Per rpc struct for the allocator. This is the interface to return to user.
@ -69,25 +66,6 @@ class MessageAllocator {
virtual MessageHolder<RequestT, ResponseT>* AllocateMessages() = 0; virtual MessageHolder<RequestT, ResponseT>* AllocateMessages() = 0;
}; };
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
} // namespace experimental
#endif
// TODO(vjpai): Remove namespace experimental when de-experimentalized fully.
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental {
using ::grpc::RpcAllocatorState;
template <typename RequestT, typename ResponseT>
using MessageHolder = ::grpc::MessageHolder<RequestT, ResponseT>;
template <typename RequestT, typename ResponseT>
using MessageAllocator = ::grpc::MessageAllocator<RequestT, ResponseT>;
} // namespace experimental
#endif
} // namespace grpc } // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H #endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H

@ -158,8 +158,7 @@ class ServerCallbackCall {
}; };
template <class Request, class Response> template <class Request, class Response>
class DefaultMessageHolder class DefaultMessageHolder : public MessageHolder<Request, Response> {
: public ::grpc::experimental::MessageHolder<Request, Response> {
public: public:
DefaultMessageHolder() { DefaultMessageHolder() {
this->set_request(&request_obj_); this->set_request(&request_obj_);

@ -37,16 +37,15 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
: get_reactor_(std::move(get_reactor)) {} : get_reactor_(std::move(get_reactor)) {}
void SetMessageAllocator( void SetMessageAllocator(
::grpc::experimental::MessageAllocator<RequestType, ResponseType>* MessageAllocator<RequestType, ResponseType>* allocator) {
allocator) {
allocator_ = allocator; allocator_ = allocator;
} }
void RunHandler(const HandlerParameter& param) final { void RunHandler(const HandlerParameter& param) final {
// Arena allocate a controller structure (that includes request/response) // Arena allocate a controller structure (that includes request/response)
::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call());
auto* allocator_state = static_cast< auto* allocator_state =
::grpc::experimental::MessageHolder<RequestType, ResponseType>*>( static_cast<MessageHolder<RequestType, ResponseType>*>(
param.internal_data); param.internal_data);
auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
@ -82,8 +81,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
::grpc::ByteBuffer buf; ::grpc::ByteBuffer buf;
buf.set_buffer(req); buf.set_buffer(req);
RequestType* request = nullptr; RequestType* request = nullptr;
::grpc::experimental::MessageHolder<RequestType, ResponseType>* MessageHolder<RequestType, ResponseType>* allocator_state = nullptr;
allocator_state = nullptr;
if (allocator_ != nullptr) { if (allocator_ != nullptr) {
allocator_state = allocator_->AllocateMessages(); allocator_state = allocator_->AllocateMessages();
} else { } else {
@ -109,8 +107,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
std::function<ServerUnaryReactor*(::grpc::CallbackServerContext*, std::function<ServerUnaryReactor*(::grpc::CallbackServerContext*,
const RequestType*, ResponseType*)> const RequestType*, ResponseType*)>
get_reactor_; get_reactor_;
::grpc::experimental::MessageAllocator<RequestType, ResponseType>* MessageAllocator<RequestType, ResponseType>* allocator_ = nullptr;
allocator_ = nullptr;
class ServerCallbackUnaryImpl : public ServerCallbackUnary { class ServerCallbackUnaryImpl : public ServerCallbackUnary {
public: public:
@ -181,8 +178,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
ServerCallbackUnaryImpl( ServerCallbackUnaryImpl(
::grpc::CallbackServerContext* ctx, ::grpc::internal::Call* call, ::grpc::CallbackServerContext* ctx, ::grpc::internal::Call* call,
::grpc::experimental::MessageHolder<RequestType, ResponseType>* MessageHolder<RequestType, ResponseType>* allocator_state,
allocator_state,
std::function<void()> call_requester) std::function<void()> call_requester)
: ctx_(ctx), : ctx_(ctx),
call_(*call), call_(*call),
@ -233,8 +229,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
::grpc::CallbackServerContext* const ctx_; ::grpc::CallbackServerContext* const ctx_;
::grpc::internal::Call call_; ::grpc::internal::Call call_;
::grpc::experimental::MessageHolder<RequestType, ResponseType>* const MessageHolder<RequestType, ResponseType>* const allocator_state_;
allocator_state_;
std::function<void()> call_requester_; std::function<void()> call_requester_;
// reactor_ can always be loaded/stored with relaxed memory ordering because // reactor_ can always be loaded/stored with relaxed memory ordering because
// its value is only set once, independently of other data in the object, // its value is only set once, independently of other data in the object,

@ -110,13 +110,8 @@ typedef ::grpc::CallbackServerContext CallbackServerContext;
} // namespace experimental } // namespace experimental
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental {
#endif
class GenericCallbackServerContext; class GenericCallbackServerContext;
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
} // namespace experimental
#endif
namespace internal { namespace internal {
class Call; class Call;
} // namespace internal } // namespace internal
@ -299,10 +294,7 @@ class ServerContextBase {
/// NOTE: This is an API for advanced users who need custom allocators. /// NOTE: This is an API for advanced users who need custom allocators.
/// Get and maybe mutate the allocator state associated with the current RPC. /// Get and maybe mutate the allocator state associated with the current RPC.
/// Currently only applicable for callback unary RPC methods. /// Currently only applicable for callback unary RPC methods.
/// WARNING: This is experimental API and could be changed or removed. RpcAllocatorState* GetRpcAllocatorState() { return message_allocator_state_; }
::grpc::experimental::RpcAllocatorState* GetRpcAllocatorState() {
return message_allocator_state_;
}
/// Get a library-owned default unary reactor for use in minimal reaction /// Get a library-owned default unary reactor for use in minimal reaction
/// cases. This supports typical unary RPC usage of providing a response and /// cases. This supports typical unary RPC usage of providing a response and
@ -394,11 +386,7 @@ class ServerContextBase {
friend class ::grpc::internal::FinishOnlyReactor; friend class ::grpc::internal::FinishOnlyReactor;
friend class ::grpc::ClientContext; friend class ::grpc::ClientContext;
friend class ::grpc::GenericServerContext; friend class ::grpc::GenericServerContext;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
friend class ::grpc::GenericCallbackServerContext; friend class ::grpc::GenericCallbackServerContext;
#else
friend class ::grpc::experimental::GenericCallbackServerContext;
#endif
/// Prevent copying. /// Prevent copying.
ServerContextBase(const ServerContextBase&); ServerContextBase(const ServerContextBase&);
@ -429,8 +417,7 @@ class ServerContextBase {
return rpc_info_; return rpc_info_;
} }
void set_message_allocator_state( void set_message_allocator_state(RpcAllocatorState* allocator_state) {
::grpc::experimental::RpcAllocatorState* allocator_state) {
message_allocator_state_ = allocator_state; message_allocator_state_ = allocator_state;
} }
@ -471,7 +458,7 @@ class ServerContextBase {
bool has_pending_ops_ = false; bool has_pending_ops_ = false;
::grpc::experimental::ServerRpcInfo* rpc_info_ = nullptr; ::grpc::experimental::ServerRpcInfo* rpc_info_ = nullptr;
::grpc::experimental::RpcAllocatorState* message_allocator_state_ = nullptr; RpcAllocatorState* message_allocator_state_ = nullptr;
ContextAllocator* context_allocator_ = nullptr; ContextAllocator* context_allocator_ = nullptr;
class Reactor : public ::grpc::ServerUnaryReactor { class Reactor : public ::grpc::ServerUnaryReactor {
@ -638,24 +625,13 @@ class ContextAllocator {
virtual CallbackServerContext* NewCallbackServerContext() { return nullptr; } virtual CallbackServerContext* NewCallbackServerContext() { return nullptr; }
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual experimental::GenericCallbackServerContext*
NewGenericCallbackServerContext() {
return nullptr;
}
#else
virtual GenericCallbackServerContext* NewGenericCallbackServerContext() { virtual GenericCallbackServerContext* NewGenericCallbackServerContext() {
return nullptr; return nullptr;
} }
#endif
virtual void Release(CallbackServerContext*) {} virtual void Release(CallbackServerContext*) {}
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual void Release(experimental::GenericCallbackServerContext*) {}
#else
virtual void Release(GenericCallbackServerContext*) {} virtual void Release(GenericCallbackServerContext*) {}
#endif
}; };
} // namespace grpc } // namespace grpc

@ -50,13 +50,7 @@ namespace internal {
class ServerAsyncStreamingInterface; class ServerAsyncStreamingInterface;
} // namespace internal } // namespace internal
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental {
#endif
class CallbackGenericService; class CallbackGenericService;
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
} // namespace experimental
#endif
namespace experimental { namespace experimental {
class ServerInterceptorFactoryInterface; class ServerInterceptorFactoryInterface;
@ -130,35 +124,12 @@ class ServerInterface : public internal::CallHook {
/// service. The service must exist for the lifetime of the Server instance. /// service. The service must exist for the lifetime of the Server instance.
virtual void RegisterAsyncGenericService(AsyncGenericService* service) = 0; virtual void RegisterAsyncGenericService(AsyncGenericService* service) = 0;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
/// Register a callback generic service. This call does not take ownership of /// Register a callback generic service. This call does not take ownership of
/// the service. The service must exist for the lifetime of the Server /// the service. The service must exist for the lifetime of the Server
/// instance. May not be abstract since this is a post-1.0 API addition. /// instance. May not be abstract since this is a post-1.0 API addition.
virtual void RegisterCallbackGenericService(CallbackGenericService* virtual void RegisterCallbackGenericService(CallbackGenericService*
/*service*/) {} /*service*/) {}
#else
/// NOTE: class experimental_registration_interface is not part of the public
/// API of this class
/// TODO(vjpai): Move these contents to public API when no longer experimental
class experimental_registration_interface {
public:
virtual ~experimental_registration_interface() {}
/// May not be abstract since this is a post-1.0 API addition
virtual void RegisterCallbackGenericService(
experimental::CallbackGenericService* /*service*/) {}
virtual void RegisterContextAllocator(
std::unique_ptr<ContextAllocator> /*context_allocator*/) {}
};
/// NOTE: The function experimental_registration() is not stable public API.
/// It is a view to the experimental components of this class. It may be
/// changed or removed at any time. May not be abstract since this is a
/// post-1.0 API addition
virtual experimental_registration_interface* experimental_registration() {
return nullptr;
}
#endif
/// Tries to bind \a server to the given \a addr. /// Tries to bind \a server to the given \a addr.
/// ///

@ -99,29 +99,6 @@ class Service {
} }
protected: protected:
// TODO(vjpai): Promote experimental contents once callback API is accepted
class experimental_type {
public:
explicit experimental_type(Service* service) : service_(service) {}
void MarkMethodCallback(int index, internal::MethodHandler* handler) {
service_->MarkMethodCallbackInternal(index, handler);
}
void MarkMethodRawCallback(int index, internal::MethodHandler* handler) {
service_->MarkMethodRawCallbackInternal(index, handler);
}
internal::MethodHandler* GetHandler(int index) {
return service_->GetHandlerInternal(index);
}
private:
Service* service_;
};
experimental_type experimental() { return experimental_type(this); }
template <class Message> template <class Message>
void RequestAsyncUnary(int index, ::grpc::ServerContext* context, void RequestAsyncUnary(int index, ::grpc::ServerContext* context,
Message* request, Message* request,
@ -216,23 +193,7 @@ class Service {
methods_[idx]->SetMethodType(internal::RpcMethod::BIDI_STREAMING); methods_[idx]->SetMethodType(internal::RpcMethod::BIDI_STREAMING);
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
void MarkMethodCallback(int index, internal::MethodHandler* handler) { void MarkMethodCallback(int index, internal::MethodHandler* handler) {
MarkMethodCallbackInternal(index, handler);
}
void MarkMethodRawCallback(int index, internal::MethodHandler* handler) {
MarkMethodRawCallbackInternal(index, handler);
}
internal::MethodHandler* GetHandler(int index) {
return GetHandlerInternal(index);
}
#endif
private:
// TODO(vjpai): migrate the Internal functions to mainline functions once
// callback API is fully de-experimental
void MarkMethodCallbackInternal(int index, internal::MethodHandler* handler) {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
@ -245,8 +206,7 @@ class Service {
internal::RpcServiceMethod::ApiType::CALL_BACK); internal::RpcServiceMethod::ApiType::CALL_BACK);
} }
void MarkMethodRawCallbackInternal(int index, void MarkMethodRawCallback(int index, internal::MethodHandler* handler) {
internal::MethodHandler* handler) {
// This does not have to be a hard error, however no one has approached us // This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one. // with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
@ -259,11 +219,12 @@ class Service {
internal::RpcServiceMethod::ApiType::RAW_CALL_BACK); internal::RpcServiceMethod::ApiType::RAW_CALL_BACK);
} }
internal::MethodHandler* GetHandlerInternal(int index) { internal::MethodHandler* GetHandler(int index) {
size_t idx = static_cast<size_t>(index); size_t idx = static_cast<size_t>(index);
return methods_[idx]->handler(); return methods_[idx]->handler();
} }
private:
friend class Server; friend class Server;
friend class ServerInterface; friend class ServerInterface;
ServerInterface* server_; ServerInterface* server_;

@ -237,7 +237,6 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
/// service. The service must exist for the lifetime of the Server instance. /// service. The service must exist for the lifetime of the Server instance.
void RegisterAsyncGenericService(AsyncGenericService* service) override; void RegisterAsyncGenericService(AsyncGenericService* service) override;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
/// Register a callback-based generic service. This call does not take /// Register a callback-based generic service. This call does not take
/// ownership of theservice. The service must exist for the lifetime of the /// ownership of theservice. The service must exist for the lifetime of the
/// Server instance. /// Server instance.
@ -248,41 +247,6 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
context_allocator_ = std::move(context_allocator); context_allocator_ = std::move(context_allocator);
} }
#else
/// NOTE: class experimental_registration_type is not part of the public API
/// of this class
/// TODO(vjpai): Move these contents to the public API of Server when
/// they are no longer experimental
class experimental_registration_type final
: public experimental_registration_interface {
public:
explicit experimental_registration_type(Server* server) : server_(server) {}
void RegisterCallbackGenericService(
experimental::CallbackGenericService* service) override {
server_->RegisterCallbackGenericService(service);
}
void RegisterContextAllocator(
std::unique_ptr<ContextAllocator> context_allocator) override {
server_->context_allocator_ = std::move(context_allocator);
}
private:
Server* server_;
};
/// TODO(vjpai): Mark this override when experimental type above is deleted
void RegisterCallbackGenericService(
experimental::CallbackGenericService* service);
/// NOTE: The function experimental_registration() is not stable public API.
/// It is a view to the experimental components of this class. It may be
/// changed or removed at any time.
experimental_registration_interface* experimental_registration() override {
return &experimental_registration_;
}
#endif
void PerformOpsOnCall(internal::CallOpSetInterface* ops, void PerformOpsOnCall(internal::CallOpSetInterface* ops,
internal::Call* call) override; internal::Call* call) override;
@ -327,12 +291,6 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
/// the \a sync_server_cqs) /// the \a sync_server_cqs)
std::vector<std::unique_ptr<SyncRequestThreadManager>> sync_req_mgrs_; std::vector<std::unique_ptr<SyncRequestThreadManager>> sync_req_mgrs_;
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
// For registering experimental callback generic service; remove when that
// method longer experimental
experimental_registration_type experimental_registration_{this};
#endif
// Server status // Server status
internal::Mutex mu_; internal::Mutex mu_;
bool started_; bool started_;
@ -364,11 +322,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
// When appropriate, use a default callback generic service to handle // When appropriate, use a default callback generic service to handle
// unimplemented methods // unimplemented methods
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
std::unique_ptr<CallbackGenericService> unimplemented_service_; std::unique_ptr<CallbackGenericService> unimplemented_service_;
#else
std::unique_ptr<experimental::CallbackGenericService> unimplemented_service_;
#endif
// A special handler for resource exhausted in sync case // A special handler for resource exhausted in sync case
std::unique_ptr<internal::MethodHandler> resource_exhausted_handler_; std::unique_ptr<internal::MethodHandler> resource_exhausted_handler_;

@ -56,13 +56,7 @@ namespace internal {
class ExternalConnectionAcceptorImpl; class ExternalConnectionAcceptorImpl;
} // namespace internal } // namespace internal
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental {
#endif
class CallbackGenericService; class CallbackGenericService;
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
} // namespace experimental
#endif
namespace experimental { namespace experimental {
// EXPERIMENTAL API: // EXPERIMENTAL API:
@ -270,20 +264,6 @@ class ServerBuilder {
builder_->interceptor_creators_ = std::move(interceptor_creators); builder_->interceptor_creators_ = std::move(interceptor_creators);
} }
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
/// Set the allocator for creating and releasing callback server context.
/// Takes the owndership of the allocator.
ServerBuilder& SetContextAllocator(
std::unique_ptr<grpc::ContextAllocator> context_allocator);
/// Register a generic service that uses the callback API.
/// Matches requests with any :authority
/// This is mostly useful for writing generic gRPC Proxies where the exact
/// serialization format is unknown
ServerBuilder& RegisterCallbackGenericService(
grpc::experimental::CallbackGenericService* service);
#endif
enum class ExternalConnectionType { enum class ExternalConnectionType {
FROM_FD = 0 // in the form of a file descriptor FROM_FD = 0 // in the form of a file descriptor
}; };
@ -306,7 +286,6 @@ class ServerBuilder {
ServerBuilder* builder_; ServerBuilder* builder_;
}; };
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
/// Set the allocator for creating and releasing callback server context. /// Set the allocator for creating and releasing callback server context.
/// Takes the owndership of the allocator. /// Takes the owndership of the allocator.
ServerBuilder& SetContextAllocator( ServerBuilder& SetContextAllocator(
@ -318,7 +297,6 @@ class ServerBuilder {
/// serialization format is unknown /// serialization format is unknown
ServerBuilder& RegisterCallbackGenericService( ServerBuilder& RegisterCallbackGenericService(
grpc::CallbackGenericService* service); grpc::CallbackGenericService* service);
#endif
/// NOTE: The function experimental() is not stable public API. It is a view /// NOTE: The function experimental() is not stable public API. It is a view
/// to the experimental components of this class. It may be changed or removed /// to the experimental components of this class. It may be changed or removed
@ -410,12 +388,7 @@ class ServerBuilder {
grpc_resource_quota* resource_quota_; grpc_resource_quota* resource_quota_;
grpc::AsyncGenericService* generic_service_{nullptr}; grpc::AsyncGenericService* generic_service_{nullptr};
std::unique_ptr<ContextAllocator> context_allocator_; std::unique_ptr<ContextAllocator> context_allocator_;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
grpc::CallbackGenericService* callback_generic_service_{nullptr}; grpc::CallbackGenericService* callback_generic_service_{nullptr};
#else
grpc::experimental::CallbackGenericService* callback_generic_service_{
nullptr};
#endif
struct { struct {
bool is_set; bool is_set;

@ -136,12 +136,8 @@ std::string GetHeaderIncludes(grpc_generator::File* file,
PrintIncludes(printer.get(), params.additional_header_includes, false, PrintIncludes(printer.get(), params.additional_header_includes, false,
""); "");
} }
// TODO(vjpai): Remove port_platform.h from header list when callback API is
// fully de-experimentalized since we will no longer be using
// macros from it.
static const char* headers_strs[] = { static const char* headers_strs[] = {
"functional", "functional",
"grpc/impl/codegen/port_platform.h",
"grpcpp/impl/codegen/async_generic_service.h", "grpcpp/impl/codegen/async_generic_service.h",
"grpcpp/impl/codegen/async_stream.h", "grpcpp/impl/codegen/async_stream.h",
"grpcpp/impl/codegen/async_unary_call.h", "grpcpp/impl/codegen/async_unary_call.h",
@ -584,12 +580,12 @@ void PrintHeaderClientMethodCallbackInterfacesStart(
// are pure; even though this is new (post-1.0) API, it can be pure because // are pure; even though this is new (post-1.0) API, it can be pure because
// it is an entirely new interface that happens to be scoped within // it is an entirely new interface that happens to be scoped within
// StubInterface, not new additions to StubInterface itself // StubInterface, not new additions to StubInterface itself
printer->Print("class experimental_async_interface {\n"); printer->Print("class async_interface {\n");
// All methods in this new interface are public. There is no need for private // All methods in this new interface are public. There is no need for private
// "Raw" methods since the callback-based API returns unowned raw pointers // "Raw" methods since the callback-based API returns unowned raw pointers
printer->Print(" public:\n"); printer->Print(" public:\n");
printer->Indent(); printer->Indent();
printer->Print("virtual ~experimental_async_interface() {}\n"); printer->Print("virtual ~async_interface() {}\n");
} }
void PrintHeaderClientMethodCallbackInterfaces( void PrintHeaderClientMethodCallbackInterfaces(
@ -604,55 +600,27 @@ void PrintHeaderClientMethodCallbackInterfaces(
"virtual void $Method$(::grpc::ClientContext* context, " "virtual void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, " "const $Request$* request, $Response$* response, "
"std::function<void(::grpc::Status)>) = 0;\n"); "std::function<void(::grpc::Status)>) = 0;\n");
// TODO(vjpai): Remove experimental versions and macros when callback API is
// fully de-experimentalized.
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual void $Method$(::grpc::ClientContext* context, " "virtual void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, " "const $Request$* request, $Response$* response, "
"::grpc::ClientUnaryReactor* reactor) = 0;\n" "::grpc::ClientUnaryReactor* reactor) = 0;\n");
"#else\n"
"virtual void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, "
"::grpc::experimental::ClientUnaryReactor* reactor) = 0;\n"
"#endif\n");
} else if (ClientOnlyStreaming(method)) { } else if (ClientOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual void $Method$(::grpc::ClientContext* context, " "virtual void $Method$(::grpc::ClientContext* context, "
"$Response$* response, " "$Response$* response, "
"::grpc::ClientWriteReactor< $Request$>* " "::grpc::ClientWriteReactor< $Request$>* "
"reactor) = 0;\n" "reactor) = 0;\n");
"#else\n"
"virtual void $Method$(::grpc::ClientContext* context, "
"$Response$* response, "
"::grpc::experimental::ClientWriteReactor< $Request$>* "
"reactor) = 0;\n"
"#endif\n");
} else if (ServerOnlyStreaming(method)) { } else if (ServerOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual void $Method$(::grpc::ClientContext* context, " "virtual void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, " "const $Request$* request, "
"::grpc::ClientReadReactor< $Response$>* " "::grpc::ClientReadReactor< $Response$>* "
"reactor) = 0;\n" "reactor) = 0;\n");
"#else\n"
"virtual void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, "
"::grpc::experimental::ClientReadReactor< $Response$>* "
"reactor) = 0;\n"
"#endif\n");
} else if (method->BidiStreaming()) { } else if (method->BidiStreaming()) {
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual void $Method$(::grpc::ClientContext* context, " "virtual void $Method$(::grpc::ClientContext* context, "
"::grpc::ClientBidiReactor< " "::grpc::ClientBidiReactor< "
"$Request$,$Response$>* reactor) = 0;\n" "$Request$,$Response$>* reactor) = 0;\n");
"#else\n"
"virtual void $Method$(::grpc::ClientContext* context, "
"::grpc::experimental::ClientBidiReactor< "
"$Request$,$Response$>* reactor) = 0;\n"
"#endif\n");
} }
} }
@ -661,22 +629,23 @@ void PrintHeaderClientMethodCallbackInterfacesEnd(
std::map<std::string, std::string>* /*vars*/) { std::map<std::string, std::string>* /*vars*/) {
printer->Outdent(); printer->Outdent();
printer->Print("};\n"); printer->Print("};\n");
// TODO: Remove typedef when all uses of experimental_async are migrated off.
printer->Print( printer->Print(
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "typedef class async_interface experimental_async_interface;\n");
"typedef class experimental_async_interface async_interface;\n"
"#endif\n");
// Declare a function to give the async stub contents. It can't be pure // Declare a function to give the async stub contents. It can't be pure
// since this is a new API in StubInterface, but it is meaningless by default // since this is a new API in StubInterface, but it is meaningless by default
// (since any stub that wants to use it must have its own implementation of // (since any stub that wants to use it must have its own implementation of
// the callback functions therein), so make the default return value nullptr. // the callback functions therein), so make the default return value nullptr.
// Intentionally include the word "class" to avoid possible shadowing. // Intentionally include the word "class" to avoid possible shadowing.
// TODO: Remove experimental_async call when possible, replace with nullptr.
printer->Print( printer->Print(
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual class async_interface* async() { "
"async_interface* async() { return experimental_async(); }\n" "return experimental_async(); }\n");
"#endif\n");
// TODO: Remove experimental_async call when possible.
printer->Print( printer->Print(
"virtual class experimental_async_interface* experimental_async() { " "virtual class async_interface* experimental_async() { "
"return nullptr; }\n"); "return nullptr; }\n");
} }
@ -684,8 +653,8 @@ void PrintHeaderClientMethodCallbackStart(
grpc_generator::Printer* printer, grpc_generator::Printer* printer,
std::map<std::string, std::string>* /*vars*/) { std::map<std::string, std::string>* /*vars*/) {
// This declares the stub entry for the callback-based API. // This declares the stub entry for the callback-based API.
printer->Print("class experimental_async final :\n"); printer->Print("class async final :\n");
printer->Print(" public StubInterface::experimental_async_interface {\n"); printer->Print(" public StubInterface::async_interface {\n");
printer->Print(" public:\n"); printer->Print(" public:\n");
printer->Indent(); printer->Indent();
} }
@ -702,55 +671,28 @@ void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer,
"void $Method$(::grpc::ClientContext* context, " "void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, " "const $Request$* request, $Response$* response, "
"std::function<void(::grpc::Status)>) override;\n"); "std::function<void(::grpc::Status)>) override;\n");
printer->Print( printer->Print(*vars,
*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, "
"::grpc::ClientUnaryReactor* reactor) override;\n"
"#else\n"
"void $Method$(::grpc::ClientContext* context, " "void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, " "const $Request$* request, $Response$* response, "
"::grpc::experimental::ClientUnaryReactor* reactor) override;\n" "::grpc::ClientUnaryReactor* reactor) override;\n");
"#endif\n");
} else if (ClientOnlyStreaming(method)) { } else if (ClientOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"void $Method$(::grpc::ClientContext* context, " "void $Method$(::grpc::ClientContext* context, "
"$Response$* response, " "$Response$* response, "
"::grpc::ClientWriteReactor< $Request$>* " "::grpc::ClientWriteReactor< $Request$>* "
"reactor) override;\n" "reactor) override;\n");
"#else\n"
"void $Method$(::grpc::ClientContext* context, "
"$Response$* response, "
"::grpc::experimental::ClientWriteReactor< $Request$>* "
"reactor) override;\n"
"#endif\n");
} else if (ServerOnlyStreaming(method)) { } else if (ServerOnlyStreaming(method)) {
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"void $Method$(::grpc::ClientContext* context, " "void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, " "const $Request$* request, "
"::grpc::ClientReadReactor< $Response$>* " "::grpc::ClientReadReactor< $Response$>* "
"reactor) override;\n" "reactor) override;\n");
"#else\n"
"void $Method$(::grpc::ClientContext* context, "
"const $Request$* request, "
"::grpc::experimental::ClientReadReactor< $Response$>* "
"reactor) override;\n"
"#endif\n");
} else if (method->BidiStreaming()) { } else if (method->BidiStreaming()) {
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"void $Method$(::grpc::ClientContext* context, " "void $Method$(::grpc::ClientContext* context, "
"::grpc::ClientBidiReactor< " "::grpc::ClientBidiReactor< "
"$Request$,$Response$>* reactor) override;\n" "$Request$,$Response$>* reactor) override;\n");
"#else\n"
"void $Method$(::grpc::ClientContext* context, "
"::grpc::experimental::ClientBidiReactor< "
"$Request$,$Response$>* reactor) override;\n"
"#endif\n");
} }
} }
@ -761,7 +703,7 @@ void PrintHeaderClientMethodCallbackEnd(
printer->Print(" private:\n"); printer->Print(" private:\n");
printer->Indent(); printer->Indent();
printer->Print("friend class Stub;\n"); printer->Print("friend class Stub;\n");
printer->Print("explicit experimental_async(Stub* stub): stub_(stub) { }\n"); printer->Print("explicit async(Stub* stub): stub_(stub) { }\n");
// include a function with a phony use of stub_ to avoid an unused // include a function with a phony use of stub_ to avoid an unused
// private member warning for service with no methods // private member warning for service with no methods
printer->Print("Stub* stub() { return stub_; }\n"); printer->Print("Stub* stub() { return stub_; }\n");
@ -770,7 +712,10 @@ void PrintHeaderClientMethodCallbackEnd(
printer->Print("};\n"); printer->Print("};\n");
printer->Print( printer->Print(
"class experimental_async_interface* experimental_async() override { " "class async* async() override { "
"return experimental_async(); }\n");
printer->Print(
"class async* experimental_async() override { "
"return &async_stub_; }\n"); "return &async_stub_; }\n");
} }
@ -963,18 +908,10 @@ void PrintHeaderServerCallbackMethodsHelper(
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual ::grpc::ServerUnaryReactor* $Method$(\n" "virtual ::grpc::ServerUnaryReactor* $Method$(\n"
" ::grpc::CallbackServerContext* /*context*/, " " ::grpc::CallbackServerContext* /*context*/, "
"const $RealRequest$* /*request*/, " "const $RealRequest$* /*request*/, "
"$RealResponse$* /*response*/)\n" "$RealResponse$* /*response*/)"
"#else\n"
"virtual ::grpc::experimental::ServerUnaryReactor* "
"$Method$(\n"
" ::grpc::experimental::CallbackServerContext* "
"/*context*/, const $RealRequest$* /*request*/, "
"$RealResponse$* /*response*/)\n"
"#endif\n"
" { return nullptr; }\n"); " { return nullptr; }\n");
} else if (ClientOnlyStreaming(method)) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
@ -988,17 +925,10 @@ void PrintHeaderServerCallbackMethodsHelper(
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n"); "}\n");
printer->Print(*vars, printer->Print(*vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual ::grpc::ServerReadReactor< " "virtual ::grpc::ServerReadReactor< "
"$RealRequest$>* $Method$(\n" "$RealRequest$>* $Method$(\n"
" ::grpc::CallbackServerContext* " " ::grpc::CallbackServerContext* "
"/*context*/, $RealResponse$* /*response*/)\n" "/*context*/, $RealResponse$* /*response*/)"
"#else\n"
"virtual ::grpc::experimental::ServerReadReactor< "
"$RealRequest$>* $Method$(\n"
" ::grpc::experimental::CallbackServerContext* "
"/*context*/, $RealResponse$* /*response*/)\n"
"#endif\n"
" { return nullptr; }\n"); " { return nullptr; }\n");
} else if (ServerOnlyStreaming(method)) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
@ -1013,16 +943,9 @@ void PrintHeaderServerCallbackMethodsHelper(
"}\n"); "}\n");
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual ::grpc::ServerWriteReactor< $RealResponse$>* $Method$(\n" "virtual ::grpc::ServerWriteReactor< $RealResponse$>* $Method$(\n"
" ::grpc::CallbackServerContext* " " ::grpc::CallbackServerContext* "
"/*context*/, const $RealRequest$* /*request*/)\n" "/*context*/, const $RealRequest$* /*request*/)"
"#else\n"
"virtual ::grpc::experimental::ServerWriteReactor< $RealResponse$>* "
"$Method$(\n"
" ::grpc::experimental::CallbackServerContext* "
"/*context*/, const $RealRequest$* /*request*/)\n"
"#endif\n"
" { return nullptr; }\n"); " { return nullptr; }\n");
} else if (method->BidiStreaming()) { } else if (method->BidiStreaming()) {
printer->Print( printer->Print(
@ -1037,16 +960,9 @@ void PrintHeaderServerCallbackMethodsHelper(
"}\n"); "}\n");
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
"virtual ::grpc::ServerBidiReactor< $RealRequest$, $RealResponse$>* " "virtual ::grpc::ServerBidiReactor< $RealRequest$, $RealResponse$>* "
"$Method$(\n" "$Method$(\n"
" ::grpc::CallbackServerContext* /*context*/)\n" " ::grpc::CallbackServerContext* /*context*/)\n"
"#else\n"
"virtual ::grpc::experimental::ServerBidiReactor< "
"$RealRequest$, $RealResponse$>* "
"$Method$(\n"
" ::grpc::experimental::CallbackServerContext* /*context*/)\n"
"#endif\n"
" { return nullptr; }\n"); " { return nullptr; }\n");
} }
} }
@ -1062,117 +978,70 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer,
(*vars)["RealRequest"] = method->input_type_name(); (*vars)["RealRequest"] = method->input_type_name();
(*vars)["RealResponse"] = method->output_type_name(); (*vars)["RealResponse"] = method->output_type_name();
printer->Print(*vars, "template <class BaseClass>\n"); printer->Print(*vars, "template <class BaseClass>\n");
printer->Print( printer->Print(*vars,
*vars, "class WithCallbackMethod_$Method$ : public BaseClass {\n");
"class ExperimentalWithCallbackMethod_$Method$ : public BaseClass {\n");
printer->Print( printer->Print(
" private:\n" " private:\n"
" void BaseClassMustBeDerivedFromService(const Service* /*service*/) " " void BaseClassMustBeDerivedFromService(const Service* /*service*/) "
"{}\n"); "{}\n");
printer->Print(" public:\n"); printer->Print(" public:\n");
printer->Indent(); printer->Indent();
printer->Print(*vars, "ExperimentalWithCallbackMethod_$Method$() {\n"); printer->Print(*vars, "WithCallbackMethod_$Method$() {\n");
if (method->NoStreaming()) { if (method->NoStreaming()) {
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::Service::MarkMethodCallback($Idx$,\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodCallback($Idx$,\n"
" new ::grpc::internal::CallbackUnaryHandler< " " new ::grpc::internal::CallbackUnaryHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context, "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context, "
"const $RealRequest$* " "const $RealRequest$* "
"request, " "request, "
"$RealResponse$* response) { " "$RealResponse$* response) { "
"return this->$Method$(context, request, response); }));}\n"); "return this->$Method$(context, request, response); }));}\n");
printer->Print(*vars, printer->Print(*vars,
"void SetMessageAllocatorFor_$Method$(\n" "void SetMessageAllocatorFor_$Method$(\n"
" ::grpc::experimental::MessageAllocator< " " ::grpc::MessageAllocator< "
"$RealRequest$, $RealResponse$>* allocator) {\n" "$RealRequest$, $RealResponse$>* allocator) {\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
" ::grpc::internal::MethodHandler* const handler = " " ::grpc::internal::MethodHandler* const handler = "
"::grpc::Service::GetHandler($Idx$);\n" "::grpc::Service::GetHandler($Idx$);\n"
"#else\n"
" ::grpc::internal::MethodHandler* const handler = "
"::grpc::Service::experimental().GetHandler($Idx$);\n"
"#endif\n"
" static_cast<::grpc::internal::CallbackUnaryHandler< " " static_cast<::grpc::internal::CallbackUnaryHandler< "
"$RealRequest$, $RealResponse$>*>(handler)\n" "$RealRequest$, $RealResponse$>*>(handler)\n"
" ->SetMessageAllocator(allocator);\n"); " ->SetMessageAllocator(allocator);\n");
} else if (ClientOnlyStreaming(method)) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::Service::MarkMethodCallback($Idx$,\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodCallback($Idx$,\n"
" new ::grpc::internal::CallbackClientStreamingHandler< " " new ::grpc::internal::CallbackClientStreamingHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context, "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context, "
"$RealResponse$* " "$RealResponse$* "
"response) { " "response) { "
"return this->$Method$(context, response); }));\n"); "return this->$Method$(context, response); }));\n");
} else if (ServerOnlyStreaming(method)) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::Service::MarkMethodCallback($Idx$,\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodCallback($Idx$,\n"
" new ::grpc::internal::CallbackServerStreamingHandler< " " new ::grpc::internal::CallbackServerStreamingHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context, "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context, "
"const $RealRequest$* " "const $RealRequest$* "
"request) { " "request) { "
"return this->$Method$(context, request); }));\n"); "return this->$Method$(context, request); }));\n");
} else if (method->BidiStreaming()) { } else if (method->BidiStreaming()) {
printer->Print( printer->Print(*vars,
*vars, " ::grpc::Service::MarkMethodCallback($Idx$,\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodCallback($Idx$,\n"
" new ::grpc::internal::CallbackBidiHandler< " " new ::grpc::internal::CallbackBidiHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context) "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context) "
"{ return this->$Method$(context); }));\n"); "{ return this->$Method$(context); }));\n");
} }
printer->Print(*vars, "}\n"); printer->Print(*vars, "}\n");
printer->Print(*vars, printer->Print(*vars,
"~ExperimentalWithCallbackMethod_$Method$() override {\n" "~WithCallbackMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n" " BaseClassMustBeDerivedFromService(this);\n"
"}\n"); "}\n");
PrintHeaderServerCallbackMethodsHelper(printer, method, vars); PrintHeaderServerCallbackMethodsHelper(printer, method, vars);
@ -1192,7 +1061,7 @@ void PrintHeaderServerMethodRawCallback(
(*vars)["RealResponse"] = "::grpc::ByteBuffer"; (*vars)["RealResponse"] = "::grpc::ByteBuffer";
printer->Print(*vars, "template <class BaseClass>\n"); printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars, printer->Print(*vars,
"class ExperimentalWithRawCallbackMethod_$Method$ : public " "class WithRawCallbackMethod_$Method$ : public "
"BaseClass {\n"); "BaseClass {\n");
printer->Print( printer->Print(
" private:\n" " private:\n"
@ -1200,25 +1069,14 @@ void PrintHeaderServerMethodRawCallback(
"{}\n"); "{}\n");
printer->Print(" public:\n"); printer->Print(" public:\n");
printer->Indent(); printer->Indent();
printer->Print(*vars, "ExperimentalWithRawCallbackMethod_$Method$() {\n"); printer->Print(*vars, "WithRawCallbackMethod_$Method$() {\n");
if (method->NoStreaming()) { if (method->NoStreaming()) {
printer->Print( printer->Print(*vars,
*vars, " ::grpc::Service::MarkMethodRawCallback($Idx$,\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodRawCallback($Idx$,\n"
" new ::grpc::internal::CallbackUnaryHandler< " " new ::grpc::internal::CallbackUnaryHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context, "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context, "
"const $RealRequest$* " "const $RealRequest$* "
"request, " "request, "
"$RealResponse$* response) { return " "$RealResponse$* response) { return "
@ -1226,67 +1084,36 @@ void PrintHeaderServerMethodRawCallback(
} else if (ClientOnlyStreaming(method)) { } else if (ClientOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::Service::MarkMethodRawCallback($Idx$,\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodRawCallback($Idx$,\n"
" new ::grpc::internal::CallbackClientStreamingHandler< " " new ::grpc::internal::CallbackClientStreamingHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context, "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context, "
"$RealResponse$* response) " "$RealResponse$* response) "
"{ return this->$Method$(context, response); }));\n"); "{ return this->$Method$(context, response); }));\n");
} else if (ServerOnlyStreaming(method)) { } else if (ServerOnlyStreaming(method)) {
printer->Print( printer->Print(
*vars, *vars,
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::Service::MarkMethodRawCallback($Idx$,\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodRawCallback($Idx$,\n"
" new ::grpc::internal::CallbackServerStreamingHandler< " " new ::grpc::internal::CallbackServerStreamingHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context, "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context, "
"const" "const"
"$RealRequest$* request) { return " "$RealRequest$* request) { return "
"this->$Method$(context, request); }));\n"); "this->$Method$(context, request); }));\n");
} else if (method->BidiStreaming()) { } else if (method->BidiStreaming()) {
printer->Print( printer->Print(*vars,
*vars, " ::grpc::Service::MarkMethodRawCallback($Idx$,\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"
" ::grpc::Service::\n"
"#else\n"
" ::grpc::Service::experimental().\n"
"#endif\n"
" MarkMethodRawCallback($Idx$,\n"
" new ::grpc::internal::CallbackBidiHandler< " " new ::grpc::internal::CallbackBidiHandler< "
"$RealRequest$, $RealResponse$>(\n" "$RealRequest$, $RealResponse$>(\n"
" [this](\n" " [this](\n"
"#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::CallbackServerContext* context) "
" ::grpc::CallbackServerContext*\n"
"#else\n"
" ::grpc::experimental::CallbackServerContext*\n"
"#endif\n"
" context) "
"{ return this->$Method$(context); }));\n"); "{ return this->$Method$(context); }));\n");
} }
printer->Print(*vars, "}\n"); printer->Print(*vars, "}\n");
printer->Print(*vars, printer->Print(*vars,
"~ExperimentalWithRawCallbackMethod_$Method$() override {\n" "~WithRawCallbackMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n" " BaseClassMustBeDerivedFromService(this);\n"
"}\n"); "}\n");
PrintHeaderServerCallbackMethodsHelper(printer, method, vars); PrintHeaderServerCallbackMethodsHelper(printer, method, vars);
@ -1571,7 +1398,7 @@ void PrintHeaderService(grpc_generator::Printer* printer,
printer->Print("\n private:\n"); printer->Print("\n private:\n");
printer->Indent(); printer->Indent();
printer->Print("std::shared_ptr< ::grpc::ChannelInterface> channel_;\n"); printer->Print("std::shared_ptr< ::grpc::ChannelInterface> channel_;\n");
printer->Print("class experimental_async async_stub_{this};\n"); printer->Print("class async async_stub_{this};\n");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderClientMethod(printer, service->method(i).get(), vars, false); PrintHeaderClientMethod(printer, service->method(i).get(), vars, false);
} }
@ -1624,31 +1451,21 @@ void PrintHeaderService(grpc_generator::Printer* printer,
PrintHeaderServerMethodCallback(printer, service->method(i).get(), vars); PrintHeaderServerMethodCallback(printer, service->method(i).get(), vars);
} }
printer->Print("#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n");
printer->Print("typedef "); printer->Print("typedef ");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
(*vars)["method_name"] = service->method(i)->name(); (*vars)["method_name"] = service->method(i)->name();
printer->Print(*vars, "ExperimentalWithCallbackMethod_$method_name$<"); printer->Print(*vars, "WithCallbackMethod_$method_name$<");
} }
printer->Print("Service"); printer->Print("Service");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
printer->Print(" >"); printer->Print(" >");
} }
printer->Print(" CallbackService;\n"); printer->Print(" CallbackService;\n");
printer->Print("#endif\n\n");
printer->Print("typedef "); // TODO: Remove following typedef once all uses of ExperimentalCallbackService
// are migrated to CallbackService
for (int i = 0; i < service->method_count(); ++i) { printer->Print("typedef CallbackService ExperimentalCallbackService;\n");
(*vars)["method_name"] = service->method(i)->name();
printer->Print(*vars, "ExperimentalWithCallbackMethod_$method_name$<");
}
printer->Print("Service");
for (int i = 0; i < service->method_count(); ++i) {
printer->Print(" >");
}
printer->Print(" ExperimentalCallbackService;\n");
// Server side - Generic // Server side - Generic
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
@ -1894,7 +1711,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer,
"context, request, response);\n}\n\n"); "context, request, response);\n}\n\n");
printer->Print(*vars, printer->Print(*vars,
"void $ns$$Service$::Stub::experimental_async::$Method$(" "void $ns$$Service$::Stub::async::$Method$("
"::grpc::ClientContext* context, " "::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, " "const $Request$* request, $Response$* response, "
"std::function<void(::grpc::Status)> f) {\n"); "std::function<void(::grpc::Status)> f) {\n");
@ -1906,10 +1723,10 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer,
"context, request, response, std::move(f));\n}\n\n"); "context, request, response, std::move(f));\n}\n\n");
printer->Print(*vars, printer->Print(*vars,
"void $ns$$Service$::Stub::experimental_async::$Method$(" "void $ns$$Service$::Stub::async::$Method$("
"::grpc::ClientContext* context, " "::grpc::ClientContext* context, "
"const $Request$* request, $Response$* response, " "const $Request$* request, $Response$* response, "
"::grpc::experimental::ClientUnaryReactor* reactor) {\n"); "::grpc::ClientUnaryReactor* reactor) {\n");
printer->Print(*vars, printer->Print(*vars,
" ::grpc::internal::ClientCallbackUnaryFactory::Create" " ::grpc::internal::ClientCallbackUnaryFactory::Create"
"< ::grpc::protobuf::MessageLite, " "< ::grpc::protobuf::MessageLite, "
@ -1956,12 +1773,11 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer,
"context, response);\n" "context, response);\n"
"}\n\n"); "}\n\n");
printer->Print( printer->Print(*vars,
*vars,
"void $ns$$Service$::" "void $ns$$Service$::"
"Stub::experimental_async::$Method$(::grpc::ClientContext* context, " "Stub::async::$Method$(::grpc::ClientContext* context, "
"$Response$* response, " "$Response$* response, "
"::grpc::experimental::ClientWriteReactor< $Request$>* reactor) {\n"); "::grpc::ClientWriteReactor< $Request$>* reactor) {\n");
printer->Print(*vars, printer->Print(*vars,
" ::grpc::internal::ClientCallbackWriterFactory< " " ::grpc::internal::ClientCallbackWriterFactory< "
"$Request$>::Create(" "$Request$>::Create("
@ -2002,12 +1818,11 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer,
"context, request);\n" "context, request);\n"
"}\n\n"); "}\n\n");
printer->Print( printer->Print(*vars,
*vars, "void $ns$$Service$::Stub::async::$Method$(::grpc::"
"void $ns$$Service$::Stub::experimental_async::$Method$(::grpc::"
"ClientContext* context, " "ClientContext* context, "
"const $Request$* request, " "const $Request$* request, "
"::grpc::experimental::ClientReadReactor< $Response$>* reactor) {\n"); "::grpc::ClientReadReactor< $Response$>* reactor) {\n");
printer->Print(*vars, printer->Print(*vars,
" ::grpc::internal::ClientCallbackReaderFactory< " " ::grpc::internal::ClientCallbackReaderFactory< "
"$Response$>::Create(" "$Response$>::Create("
@ -2048,11 +1863,10 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer,
"context);\n" "context);\n"
"}\n\n"); "}\n\n");
printer->Print( printer->Print(*vars,
*vars, "void $ns$$Service$::Stub::async::$Method$(::grpc::"
"void $ns$$Service$::Stub::experimental_async::$Method$(::grpc::"
"ClientContext* context, " "ClientContext* context, "
"::grpc::experimental::ClientBidiReactor< $Request$,$Response$>* " "::grpc::ClientBidiReactor< $Request$,$Response$>* "
"reactor) {\n"); "reactor) {\n");
printer->Print(*vars, printer->Print(*vars,
" ::grpc::internal::ClientCallbackReaderWriterFactory< " " ::grpc::internal::ClientCallbackReaderWriterFactory< "

@ -102,7 +102,6 @@ ServerBuilder& ServerBuilder::RegisterAsyncGenericService(
return *this; return *this;
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
ServerBuilder& ServerBuilder::RegisterCallbackGenericService( ServerBuilder& ServerBuilder::RegisterCallbackGenericService(
CallbackGenericService* service) { CallbackGenericService* service) {
if (generic_service_ || callback_generic_service_) { if (generic_service_ || callback_generic_service_) {
@ -121,26 +120,6 @@ ServerBuilder& ServerBuilder::SetContextAllocator(
context_allocator_ = std::move(context_allocator); context_allocator_ = std::move(context_allocator);
return *this; return *this;
} }
#else
ServerBuilder& ServerBuilder::experimental_type::RegisterCallbackGenericService(
experimental::CallbackGenericService* service) {
if (builder_->generic_service_ || builder_->callback_generic_service_) {
gpr_log(GPR_ERROR,
"Adding multiple generic services is unsupported for now. "
"Dropping the service %p",
service);
} else {
builder_->callback_generic_service_ = service;
}
return *builder_;
}
ServerBuilder& ServerBuilder::experimental_type::SetContextAllocator(
std::unique_ptr<grpc::ContextAllocator> context_allocator) {
builder_->context_allocator_ = std::move(context_allocator);
return *builder_;
}
#endif
std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor> std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor>
ServerBuilder::experimental_type::AddExternalConnectionAcceptor( ServerBuilder::experimental_type::AddExternalConnectionAcceptor(
@ -399,12 +378,7 @@ std::unique_ptr<grpc::Server> ServerBuilder::BuildAndStart() {
return nullptr; return nullptr;
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
server->RegisterContextAllocator(std::move(context_allocator_)); server->RegisterContextAllocator(std::move(context_allocator_));
#else
server->experimental_registration()->RegisterContextAllocator(
std::move(context_allocator_));
#endif
for (const auto& value : services_) { for (const auto& value : services_) {
if (!server->RegisterService(value->host.get(), value->service)) { if (!server->RegisterService(value->host.get(), value->service)) {

@ -114,15 +114,6 @@ class UnimplementedAsyncRequestContext {
GenericServerAsyncReaderWriter generic_stream_; GenericServerAsyncReaderWriter generic_stream_;
}; };
// TODO(vjpai): Just for this file, use some contents of the experimental
// namespace here to make the code easier to read below. Remove this when
// de-experimentalized fully.
#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
using ::grpc::experimental::CallbackGenericService;
using ::grpc::experimental::CallbackServerContext;
using ::grpc::experimental::GenericCallbackServerContext;
#endif
} // namespace } // namespace
ServerInterface::BaseAsyncRequest::BaseAsyncRequest( ServerInterface::BaseAsyncRequest::BaseAsyncRequest(

@ -27,7 +27,6 @@
#include "src/proto/grpc/testing/compiler_test.pb.h" #include "src/proto/grpc/testing/compiler_test.pb.h"
#include <functional> #include <functional>
#include <grpc/impl/codegen/port_platform.h>
#include <grpcpp/impl/codegen/async_generic_service.h> #include <grpcpp/impl/codegen/async_generic_service.h>
#include <grpcpp/impl/codegen/async_stream.h> #include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h> #include <grpcpp/impl/codegen/async_unary_call.h>
@ -107,49 +106,29 @@ class ServiceA final {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq)); return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq));
} }
// Method A4 trailing comment 1 // Method A4 trailing comment 1
class experimental_async_interface { class async_interface {
public: public:
virtual ~experimental_async_interface() {} virtual ~async_interface() {}
// MethodA1 leading comment 1 // MethodA1 leading comment 1
virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0; virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0;
#else
virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) = 0;
#endif
// MethodA1 trailing comment 1 // MethodA1 trailing comment 1
// MethodA2 detached leading comment 1 // MethodA2 detached leading comment 1
// //
// Method A2 leading comment 1 // Method A2 leading comment 1
// Method A2 leading comment 2 // Method A2 leading comment 2
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::ClientWriteReactor< ::grpc::testing::Request>* reactor) = 0; virtual void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::ClientWriteReactor< ::grpc::testing::Request>* reactor) = 0;
#else
virtual void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::experimental::ClientWriteReactor< ::grpc::testing::Request>* reactor) = 0;
#endif
// MethodA2 trailing comment 1 // MethodA2 trailing comment 1
// Method A3 leading comment 1 // Method A3 leading comment 1
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0; virtual void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0;
#else
virtual void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0;
#endif
// Method A3 trailing comment 1 // Method A3 trailing comment 1
// Method A4 leading comment 1 // Method A4 leading comment 1
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual void MethodA4(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) = 0; virtual void MethodA4(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) = 0;
#else
virtual void MethodA4(::grpc::ClientContext* context, ::grpc::experimental::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) = 0;
#endif
// Method A4 trailing comment 1 // Method A4 trailing comment 1
}; };
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL typedef class async_interface experimental_async_interface;
typedef class experimental_async_interface async_interface; virtual class async_interface* async() { return experimental_async(); }
#endif virtual class async_interface* experimental_async() { return nullptr; }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
async_interface* async() { return experimental_async(); }
#endif
virtual class experimental_async_interface* experimental_async() { return nullptr; }
private: private:
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
@ -200,41 +179,26 @@ class ServiceA final {
std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>> PrepareAsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) { std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>> PrepareAsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq)); return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq));
} }
class experimental_async final : class async final :
public StubInterface::experimental_async_interface { public StubInterface::async_interface {
public: public:
void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override; void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) override; void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) override;
#else
void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) override;
#endif
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::ClientWriteReactor< ::grpc::testing::Request>* reactor) override; void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::ClientWriteReactor< ::grpc::testing::Request>* reactor) override;
#else
void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::experimental::ClientWriteReactor< ::grpc::testing::Request>* reactor) override;
#endif
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) override; void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) override;
#else
void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor< ::grpc::testing::Response>* reactor) override;
#endif
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
void MethodA4(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) override; void MethodA4(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) override;
#else
void MethodA4(::grpc::ClientContext* context, ::grpc::experimental::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) override;
#endif
private: private:
friend class Stub; friend class Stub;
explicit experimental_async(Stub* stub): stub_(stub) { } explicit async(Stub* stub): stub_(stub) { }
Stub* stub() { return stub_; } Stub* stub() { return stub_; }
Stub* stub_; Stub* stub_;
}; };
class experimental_async_interface* experimental_async() override { return &async_stub_; } class async* async() override { return experimental_async(); }
class async* experimental_async() override { return &async_stub_; }
private: private:
std::shared_ptr< ::grpc::ChannelInterface> channel_; std::shared_ptr< ::grpc::ChannelInterface> channel_;
class experimental_async async_stub_{this}; class async async_stub_{this};
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientWriter< ::grpc::testing::Request>* MethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response) override; ::grpc::ClientWriter< ::grpc::testing::Request>* MethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response) override;
@ -355,36 +319,22 @@ class ServiceA final {
}; };
typedef WithAsyncMethod_MethodA1<WithAsyncMethod_MethodA2<WithAsyncMethod_MethodA3<WithAsyncMethod_MethodA4<Service > > > > AsyncService; typedef WithAsyncMethod_MethodA1<WithAsyncMethod_MethodA2<WithAsyncMethod_MethodA3<WithAsyncMethod_MethodA4<Service > > > > AsyncService;
template <class BaseClass> template <class BaseClass>
class ExperimentalWithCallbackMethod_MethodA1 : public BaseClass { class WithCallbackMethod_MethodA1 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithCallbackMethod_MethodA1() { WithCallbackMethod_MethodA1() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodCallback(0,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) { return this->MethodA1(context, request, response); }));}
::grpc::CallbackServerContext*
#else
::grpc::experimental::CallbackServerContext*
#endif
context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) { return this->MethodA1(context, request, response); }));}
void SetMessageAllocatorFor_MethodA1( void SetMessageAllocatorFor_MethodA1(
::grpc::experimental::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) { ::grpc::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(0); ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(0);
#else
::grpc::internal::MethodHandler* const handler = ::grpc::Service::experimental().GetHandler(0);
#endif
static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>(handler) static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>(handler)
->SetMessageAllocator(allocator); ->SetMessageAllocator(allocator);
} }
~ExperimentalWithCallbackMethod_MethodA1() override { ~WithCallbackMethod_MethodA1() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -392,37 +342,21 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerUnaryReactor* MethodA1( virtual ::grpc::ServerUnaryReactor* MethodA1(
::grpc::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) ::grpc::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerUnaryReactor* MethodA1(
::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithCallbackMethod_MethodA2 : public BaseClass { class WithCallbackMethod_MethodA2 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithCallbackMethod_MethodA2() { WithCallbackMethod_MethodA2() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodCallback(1,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodCallback(1,
new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, ::grpc::testing::Response* response) { return this->MethodA2(context, response); }));
::grpc::CallbackServerContext* }
#else ~WithCallbackMethod_MethodA2() override {
::grpc::experimental::CallbackServerContext*
#endif
context, ::grpc::testing::Response* response) { return this->MethodA2(context, response); }));
}
~ExperimentalWithCallbackMethod_MethodA2() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -430,37 +364,21 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerReadReactor< ::grpc::testing::Request>* MethodA2( virtual ::grpc::ServerReadReactor< ::grpc::testing::Request>* MethodA2(
::grpc::CallbackServerContext* /*context*/, ::grpc::testing::Response* /*response*/) ::grpc::CallbackServerContext* /*context*/, ::grpc::testing::Response* /*response*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerReadReactor< ::grpc::testing::Request>* MethodA2(
::grpc::experimental::CallbackServerContext* /*context*/, ::grpc::testing::Response* /*response*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithCallbackMethod_MethodA3 : public BaseClass { class WithCallbackMethod_MethodA3 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithCallbackMethod_MethodA3() { WithCallbackMethod_MethodA3() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodCallback(2,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodCallback(2,
new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>( new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, const ::grpc::testing::Request* request) { return this->MethodA3(context, request); }));
::grpc::CallbackServerContext* }
#else ~WithCallbackMethod_MethodA3() override {
::grpc::experimental::CallbackServerContext*
#endif
context, const ::grpc::testing::Request* request) { return this->MethodA3(context, request); }));
}
~ExperimentalWithCallbackMethod_MethodA3() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -468,37 +386,21 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerWriteReactor< ::grpc::testing::Response>* MethodA3( virtual ::grpc::ServerWriteReactor< ::grpc::testing::Response>* MethodA3(
::grpc::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/) ::grpc::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerWriteReactor< ::grpc::testing::Response>* MethodA3(
::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithCallbackMethod_MethodA4 : public BaseClass { class WithCallbackMethod_MethodA4 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithCallbackMethod_MethodA4() { WithCallbackMethod_MethodA4() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodCallback(3,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodCallback(3,
new ::grpc::internal::CallbackBidiHandler< ::grpc::testing::Request, ::grpc::testing::Response>( new ::grpc::internal::CallbackBidiHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context) { return this->MethodA4(context); }));
::grpc::CallbackServerContext* }
#else ~WithCallbackMethod_MethodA4() override {
::grpc::experimental::CallbackServerContext*
#endif
context) { return this->MethodA4(context); }));
}
~ExperimentalWithCallbackMethod_MethodA4() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -506,20 +408,12 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4( virtual ::grpc::ServerBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4(
::grpc::CallbackServerContext* /*context*/) ::grpc::CallbackServerContext* /*context*/)
#else
virtual ::grpc::experimental::ServerBidiReactor< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4(
::grpc::experimental::CallbackServerContext* /*context*/)
#endif
{ return nullptr; } { return nullptr; }
}; };
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL typedef WithCallbackMethod_MethodA1<WithCallbackMethod_MethodA2<WithCallbackMethod_MethodA3<WithCallbackMethod_MethodA4<Service > > > > CallbackService;
typedef ExperimentalWithCallbackMethod_MethodA1<ExperimentalWithCallbackMethod_MethodA2<ExperimentalWithCallbackMethod_MethodA3<ExperimentalWithCallbackMethod_MethodA4<Service > > > > CallbackService; typedef CallbackService ExperimentalCallbackService;
#endif
typedef ExperimentalWithCallbackMethod_MethodA1<ExperimentalWithCallbackMethod_MethodA2<ExperimentalWithCallbackMethod_MethodA3<ExperimentalWithCallbackMethod_MethodA4<Service > > > > ExperimentalCallbackService;
template <class BaseClass> template <class BaseClass>
class WithGenericMethod_MethodA1 : public BaseClass { class WithGenericMethod_MethodA1 : public BaseClass {
private: private:
@ -669,27 +563,17 @@ class ServiceA final {
} }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithRawCallbackMethod_MethodA1 : public BaseClass { class WithRawCallbackMethod_MethodA1 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithRawCallbackMethod_MethodA1() { WithRawCallbackMethod_MethodA1() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodRawCallback(0,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodRawCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->MethodA1(context, request, response); }));
::grpc::CallbackServerContext* }
#else ~WithRawCallbackMethod_MethodA1() override {
::grpc::experimental::CallbackServerContext*
#endif
context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->MethodA1(context, request, response); }));
}
~ExperimentalWithRawCallbackMethod_MethodA1() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -697,37 +581,21 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerUnaryReactor* MethodA1( virtual ::grpc::ServerUnaryReactor* MethodA1(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerUnaryReactor* MethodA1(
::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithRawCallbackMethod_MethodA2 : public BaseClass { class WithRawCallbackMethod_MethodA2 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithRawCallbackMethod_MethodA2() { WithRawCallbackMethod_MethodA2() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodRawCallback(1,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodRawCallback(1,
new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, ::grpc::ByteBuffer* response) { return this->MethodA2(context, response); }));
::grpc::CallbackServerContext* }
#else ~WithRawCallbackMethod_MethodA2() override {
::grpc::experimental::CallbackServerContext*
#endif
context, ::grpc::ByteBuffer* response) { return this->MethodA2(context, response); }));
}
~ExperimentalWithRawCallbackMethod_MethodA2() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -735,37 +603,21 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerReadReactor< ::grpc::ByteBuffer>* MethodA2( virtual ::grpc::ServerReadReactor< ::grpc::ByteBuffer>* MethodA2(
::grpc::CallbackServerContext* /*context*/, ::grpc::ByteBuffer* /*response*/) ::grpc::CallbackServerContext* /*context*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerReadReactor< ::grpc::ByteBuffer>* MethodA2(
::grpc::experimental::CallbackServerContext* /*context*/, ::grpc::ByteBuffer* /*response*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithRawCallbackMethod_MethodA3 : public BaseClass { class WithRawCallbackMethod_MethodA3 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithRawCallbackMethod_MethodA3() { WithRawCallbackMethod_MethodA3() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodRawCallback(2,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodRawCallback(2,
new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( new ::grpc::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, const::grpc::ByteBuffer* request) { return this->MethodA3(context, request); }));
::grpc::CallbackServerContext* }
#else ~WithRawCallbackMethod_MethodA3() override {
::grpc::experimental::CallbackServerContext*
#endif
context, const::grpc::ByteBuffer* request) { return this->MethodA3(context, request); }));
}
~ExperimentalWithRawCallbackMethod_MethodA3() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -773,37 +625,21 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerWriteReactor< ::grpc::ByteBuffer>* MethodA3( virtual ::grpc::ServerWriteReactor< ::grpc::ByteBuffer>* MethodA3(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/) ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerWriteReactor< ::grpc::ByteBuffer>* MethodA3(
::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithRawCallbackMethod_MethodA4 : public BaseClass { class WithRawCallbackMethod_MethodA4 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithRawCallbackMethod_MethodA4() { WithRawCallbackMethod_MethodA4() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodRawCallback(3,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodRawCallback(3,
new ::grpc::internal::CallbackBidiHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( new ::grpc::internal::CallbackBidiHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context) { return this->MethodA4(context); }));
::grpc::CallbackServerContext* }
#else ~WithRawCallbackMethod_MethodA4() override {
::grpc::experimental::CallbackServerContext*
#endif
context) { return this->MethodA4(context); }));
}
~ExperimentalWithRawCallbackMethod_MethodA4() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -811,13 +647,8 @@ class ServiceA final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA4( virtual ::grpc::ServerBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA4(
::grpc::CallbackServerContext* /*context*/) ::grpc::CallbackServerContext* /*context*/)
#else
virtual ::grpc::experimental::ServerBidiReactor< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* MethodA4(
::grpc::experimental::CallbackServerContext* /*context*/)
#endif
{ return nullptr; } { return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
@ -897,25 +728,17 @@ class ServiceB final {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq)); return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq));
} }
// MethodB1 trailing comment 1 // MethodB1 trailing comment 1
class experimental_async_interface { class async_interface {
public: public:
virtual ~experimental_async_interface() {} virtual ~async_interface() {}
// MethodB1 leading comment 1 // MethodB1 leading comment 1
virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0; virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) = 0;
#else
virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) = 0;
#endif
// MethodB1 trailing comment 1 // MethodB1 trailing comment 1
}; };
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL typedef class async_interface experimental_async_interface;
typedef class experimental_async_interface async_interface; virtual class async_interface* async() { return experimental_async(); }
#endif virtual class async_interface* experimental_async() { return nullptr; }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
async_interface* async() { return experimental_async(); }
#endif
virtual class experimental_async_interface* experimental_async() { return nullptr; }
private: private:
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
@ -930,26 +753,23 @@ class ServiceB final {
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> PrepareAsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> PrepareAsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq)); return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq));
} }
class experimental_async final : class async final :
public StubInterface::experimental_async_interface { public StubInterface::async_interface {
public: public:
void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override; void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) override; void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::ClientUnaryReactor* reactor) override;
#else
void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ClientUnaryReactor* reactor) override;
#endif
private: private:
friend class Stub; friend class Stub;
explicit experimental_async(Stub* stub): stub_(stub) { } explicit async(Stub* stub): stub_(stub) { }
Stub* stub() { return stub_; } Stub* stub() { return stub_; }
Stub* stub_; Stub* stub_;
}; };
class experimental_async_interface* experimental_async() override { return &async_stub_; } class async* async() override { return experimental_async(); }
class async* experimental_async() override { return &async_stub_; }
private: private:
std::shared_ptr< ::grpc::ChannelInterface> channel_; std::shared_ptr< ::grpc::ChannelInterface> channel_;
class experimental_async async_stub_{this}; class async async_stub_{this};
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
const ::grpc::internal::RpcMethod rpcmethod_MethodB1_; const ::grpc::internal::RpcMethod rpcmethod_MethodB1_;
@ -986,36 +806,22 @@ class ServiceB final {
}; };
typedef WithAsyncMethod_MethodB1<Service > AsyncService; typedef WithAsyncMethod_MethodB1<Service > AsyncService;
template <class BaseClass> template <class BaseClass>
class ExperimentalWithCallbackMethod_MethodB1 : public BaseClass { class WithCallbackMethod_MethodB1 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithCallbackMethod_MethodB1() { WithCallbackMethod_MethodB1() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodCallback(0,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>( new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) { return this->MethodB1(context, request, response); }));}
::grpc::CallbackServerContext*
#else
::grpc::experimental::CallbackServerContext*
#endif
context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) { return this->MethodB1(context, request, response); }));}
void SetMessageAllocatorFor_MethodB1( void SetMessageAllocatorFor_MethodB1(
::grpc::experimental::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) { ::grpc::MessageAllocator< ::grpc::testing::Request, ::grpc::testing::Response>* allocator) {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(0); ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(0);
#else
::grpc::internal::MethodHandler* const handler = ::grpc::Service::experimental().GetHandler(0);
#endif
static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>(handler) static_cast<::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>*>(handler)
->SetMessageAllocator(allocator); ->SetMessageAllocator(allocator);
} }
~ExperimentalWithCallbackMethod_MethodB1() override { ~WithCallbackMethod_MethodB1() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -1023,20 +829,11 @@ class ServiceB final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerUnaryReactor* MethodB1( virtual ::grpc::ServerUnaryReactor* MethodB1(
::grpc::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) ::grpc::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerUnaryReactor* MethodB1(
::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::testing::Request* /*request*/, ::grpc::testing::Response* /*response*/)
#endif
{ return nullptr; }
}; };
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL typedef WithCallbackMethod_MethodB1<Service > CallbackService;
typedef ExperimentalWithCallbackMethod_MethodB1<Service > CallbackService; typedef CallbackService ExperimentalCallbackService;
#endif
typedef ExperimentalWithCallbackMethod_MethodB1<Service > ExperimentalCallbackService;
template <class BaseClass> template <class BaseClass>
class WithGenericMethod_MethodB1 : public BaseClass { class WithGenericMethod_MethodB1 : public BaseClass {
private: private:
@ -1075,27 +872,17 @@ class ServiceB final {
} }
}; };
template <class BaseClass> template <class BaseClass>
class ExperimentalWithRawCallbackMethod_MethodB1 : public BaseClass { class WithRawCallbackMethod_MethodB1 : public BaseClass {
private: private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public: public:
ExperimentalWithRawCallbackMethod_MethodB1() { WithRawCallbackMethod_MethodB1() {
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::Service::MarkMethodRawCallback(0,
::grpc::Service::
#else
::grpc::Service::experimental().
#endif
MarkMethodRawCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
[this]( [this](
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->MethodB1(context, request, response); }));
::grpc::CallbackServerContext* }
#else ~WithRawCallbackMethod_MethodB1() override {
::grpc::experimental::CallbackServerContext*
#endif
context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->MethodB1(context, request, response); }));
}
~ExperimentalWithRawCallbackMethod_MethodB1() override {
BaseClassMustBeDerivedFromService(this); BaseClassMustBeDerivedFromService(this);
} }
// disable synchronous version of this method // disable synchronous version of this method
@ -1103,14 +890,8 @@ class ServiceB final {
abort(); abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
virtual ::grpc::ServerUnaryReactor* MethodB1( virtual ::grpc::ServerUnaryReactor* MethodB1(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; }
#else
virtual ::grpc::experimental::ServerUnaryReactor* MethodB1(
::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/)
#endif
{ return nullptr; }
}; };
template <class BaseClass> template <class BaseClass>
class WithStreamedUnaryMethod_MethodB1 : public BaseClass { class WithStreamedUnaryMethod_MethodB1 : public BaseClass {

@ -1406,11 +1406,10 @@ TEST_P(ClientCallbackEnd2endTest, TestTrailersOnlyOnError) {
} }
ResetStub(); ResetStub();
class Reactor : public grpc::experimental::ClientBidiReactor<EchoRequest, class Reactor : public grpc::ClientBidiReactor<EchoRequest, EchoResponse> {
EchoResponse> {
public: public:
explicit Reactor(grpc::testing::EchoTestService::Stub* stub) { explicit Reactor(grpc::testing::EchoTestService::Stub* stub) {
stub->experimental_async()->UnimplementedBidi(&context_, this); stub->async()->UnimplementedBidi(&context_, this);
StartCall(); StartCall();
} }
void Await() { void Await() {

@ -2680,8 +2680,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> {
ConcurrentRpc* rpc = &rpcs[i]; ConcurrentRpc* rpc = &rpcs[i];
rpc_options.SetupRpc(&rpc->context, &request); rpc_options.SetupRpc(&rpc->context, &request);
grpc_millis t0 = NowFromCycleCounter(); grpc_millis t0 = NowFromCycleCounter();
stub->experimental_async()->Echo( stub->async()->Echo(&rpc->context, &request, &rpc->response,
&rpc->context, &request, &rpc->response,
[rpc, &mu, &completed, &cv, num_rpcs, t0](Status s) { [rpc, &mu, &completed, &cv, num_rpcs, t0](Status s) {
rpc->status = s; rpc->status = s;
rpc->elapsed_time = NowFromCycleCounter() - t0; rpc->elapsed_time = NowFromCycleCounter() - t0;

Loading…
Cancel
Save