3#include <grpcpp/completion_queue.h> 
    4#include <grpcpp/impl/service_type.h> 
    5#include <grpcpp/server_context.h> 
    7#include <userver/ugrpc/server/impl/call_traits.hpp> 
   11namespace ugrpc::
server::impl {
 
   13template <
typename Service>
 
   14class AsyncService final : 
public Service::Service {
 
   16  explicit AsyncService(std::size_t method_count) {
 
   18    for (std::size_t i = 0; i < method_count; ++i) {
 
   19      this->MarkMethodAsync(i);
 
   23  template <
typename CallTraits>
 
   24  void Prepare(
int method_id, grpc::ServerContext& context,
 
   25               typename CallTraits::InitialRequest& initial_request,
 
   26               typename CallTraits::RawCall& stream,
 
   27               grpc::CompletionQueue& call_cq,
 
   28               grpc::ServerCompletionQueue& notification_cq, 
void* tag) {
 
   29    constexpr auto kCallCategory = CallTraits::kCallCategory;
 
   31    if constexpr (kCallCategory == CallCategory::kUnary) {
 
   32      this->RequestAsyncUnary(method_id, &context, &initial_request, &stream,
 
   33                              &call_cq, ¬ification_cq, tag);
 
   34    } 
else if constexpr (kCallCategory == CallCategory::kInputStream) {
 
   35      this->RequestAsyncClientStreaming(method_id, &context, &stream, &call_cq,
 
   36                                        ¬ification_cq, tag);
 
   37    } 
else if constexpr (kCallCategory == CallCategory::kOutputStream) {
 
   38      this->RequestAsyncServerStreaming(method_id, &context, &initial_request,
 
   39                                        &stream, &call_cq, ¬ification_cq,
 
   42      this->RequestAsyncBidiStreaming(method_id, &context, &stream, &call_cq,
 
   43                                      ¬ification_cq, tag);