Merge pull request #15771 from ncteisen/serialization

Support Per-Method Codegen Generic on Server Side
pull/15938/head
Noah Eisen 7 years ago committed by GitHub
commit 024c663312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      BUILD
  2. 57
      CMakeLists.txt
  3. 64
      Makefile
  4. 15
      build.yaml
  5. 1
      gRPC-C++.podspec
  6. 2
      gRPC-Core.podspec
  7. 14
      grpc.def
  8. 2
      grpc.gemspec
  9. 112
      include/grpc/impl/codegen/log.h
  10. 2
      include/grpc/module.modulemap
  11. 90
      include/grpc/support/log.h
  12. 58
      include/grpcpp/generic/async_generic_service.h
  13. 81
      include/grpcpp/impl/codegen/async_generic_service.h
  14. 44
      include/grpcpp/impl/codegen/rpc_service_method.h
  15. 21
      include/grpcpp/impl/codegen/service_type.h
  16. 2
      package.xml
  17. 127
      src/compiler/cpp_generator.cc
  18. 28
      src/ruby/ext/grpc/rb_grpc_imports.generated.c
  19. 44
      src/ruby/ext/grpc/rb_grpc_imports.generated.h
  20. 15
      test/core/surface/public_headers_must_be_c89.c
  21. 127
      test/cpp/codegen/compiler_test_golden
  22. 20
      test/cpp/end2end/BUILD
  23. 100
      test/cpp/end2end/hybrid_end2end_test.cc
  24. 370
      test/cpp/end2end/raw_end2end_test.cc
  25. 13
      test/cpp/util/byte_buffer_proto_helper.cc
  26. 3
      test/cpp/util/byte_buffer_proto_helper.h
  27. 2
      tools/doxygen/Doxyfile.c++
  28. 2
      tools/doxygen/Doxyfile.c++.internal
  29. 2
      tools/doxygen/Doxyfile.core
  30. 2
      tools/doxygen/Doxyfile.core.internal
  31. 23
      tools/run_tests/generated/sources_and_headers.json
  32. 24
      tools/run_tests/generated/tests.json

@ -581,6 +581,7 @@ grpc_cc_library(
"include/grpc/impl/codegen/fork.h",
"include/grpc/impl/codegen/gpr_slice.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/log.h",
"include/grpc/impl/codegen/port_platform.h",
"include/grpc/impl/codegen/sync.h",
"include/grpc/impl/codegen/sync_custom.h",
@ -1902,6 +1903,7 @@ grpc_cc_library(
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h",
"include/grpcpp/impl/codegen/async_generic_service.h",
"include/grpcpp/impl/codegen/async_stream.h",
"include/grpcpp/impl/codegen/async_unary_call.h",
"include/grpcpp/impl/codegen/byte_buffer.h",

@ -616,6 +616,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx qps_openloop_test)
endif()
add_dependencies(buildtests_cxx qps_worker)
add_dependencies(buildtests_cxx raw_end2end_test)
add_dependencies(buildtests_cxx reconnect_interop_client)
add_dependencies(buildtests_cxx reconnect_interop_server)
add_dependencies(buildtests_cxx ref_counted_ptr_test)
@ -870,6 +871,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -1290,6 +1292,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -1659,6 +1662,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -1973,6 +1977,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -2279,6 +2284,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -2594,6 +2600,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -2911,6 +2918,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -2967,6 +2975,7 @@ foreach(_hdr
include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h
include/grpcpp/impl/codegen/async_generic_service.h
include/grpcpp/impl/codegen/async_stream.h
include/grpcpp/impl/codegen/async_unary_call.h
include/grpcpp/impl/codegen/byte_buffer.h
@ -3475,6 +3484,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -3531,6 +3541,7 @@ foreach(_hdr
include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h
include/grpcpp/impl/codegen/async_generic_service.h
include/grpcpp/impl/codegen/async_stream.h
include/grpcpp/impl/codegen/async_unary_call.h
include/grpcpp/impl/codegen/byte_buffer.h
@ -3940,6 +3951,7 @@ foreach(_hdr
include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h
include/grpcpp/impl/codegen/async_generic_service.h
include/grpcpp/impl/codegen/async_stream.h
include/grpcpp/impl/codegen/async_unary_call.h
include/grpcpp/impl/codegen/byte_buffer.h
@ -3985,6 +3997,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -4116,6 +4129,7 @@ foreach(_hdr
include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h
include/grpcpp/impl/codegen/async_generic_service.h
include/grpcpp/impl/codegen/async_stream.h
include/grpcpp/impl/codegen/async_unary_call.h
include/grpcpp/impl/codegen/byte_buffer.h
@ -4161,6 +4175,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -4375,6 +4390,7 @@ foreach(_hdr
include/grpc/impl/codegen/fork.h
include/grpc/impl/codegen/gpr_slice.h
include/grpc/impl/codegen/gpr_types.h
include/grpc/impl/codegen/log.h
include/grpc/impl/codegen/port_platform.h
include/grpc/impl/codegen/sync.h
include/grpc/impl/codegen/sync_custom.h
@ -4431,6 +4447,7 @@ foreach(_hdr
include/grpc++/impl/codegen/stub_options.h
include/grpc++/impl/codegen/sync_stream.h
include/grpc++/impl/codegen/time.h
include/grpcpp/impl/codegen/async_generic_service.h
include/grpcpp/impl/codegen/async_stream.h
include/grpcpp/impl/codegen/async_unary_call.h
include/grpcpp/impl/codegen/byte_buffer.h
@ -13257,6 +13274,46 @@ target_link_libraries(qps_worker
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(raw_end2end_test
test/cpp/end2end/raw_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(raw_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(raw_end2end_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc++_test_util
grpc_test_util
grpc++
grpc
gpr_test_util
gpr
${_gRPC_GFLAGS_LIBRARIES}
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(reconnect_interop_client
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.cc

@ -1199,6 +1199,7 @@ qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test
qps_json_driver: $(BINDIR)/$(CONFIG)/qps_json_driver
qps_openloop_test: $(BINDIR)/$(CONFIG)/qps_openloop_test
qps_worker: $(BINDIR)/$(CONFIG)/qps_worker
raw_end2end_test: $(BINDIR)/$(CONFIG)/raw_end2end_test
reconnect_interop_client: $(BINDIR)/$(CONFIG)/reconnect_interop_client
reconnect_interop_server: $(BINDIR)/$(CONFIG)/reconnect_interop_server
ref_counted_ptr_test: $(BINDIR)/$(CONFIG)/ref_counted_ptr_test
@ -1687,6 +1688,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/raw_end2end_test \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/ref_counted_ptr_test \
@ -1864,6 +1866,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/raw_end2end_test \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/ref_counted_ptr_test \
@ -2334,6 +2337,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/proto_utils_test || ( echo test proto_utils_test failed ; exit 1 )
$(E) "[RUN] Testing qps_openloop_test"
$(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 )
$(E) "[RUN] Testing raw_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/raw_end2end_test || ( echo test raw_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing ref_counted_ptr_test"
$(Q) $(BINDIR)/$(CONFIG)/ref_counted_ptr_test || ( echo test ref_counted_ptr_test failed ; exit 1 )
$(E) "[RUN] Testing ref_counted_test"
@ -3306,6 +3311,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -3697,6 +3703,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -4065,6 +4072,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -4380,6 +4388,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -4677,6 +4686,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -4968,6 +4978,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -5264,6 +5275,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -5320,6 +5332,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \
@ -5835,6 +5848,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -5891,6 +5905,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \
@ -6280,6 +6295,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \
@ -6325,6 +6341,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -6432,6 +6449,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \
@ -6477,6 +6495,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -6695,6 +6714,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/sync.h \
include/grpc/impl/codegen/sync_custom.h \
@ -6751,6 +6771,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync_stream.h \
include/grpc++/impl/codegen/time.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \
@ -18942,6 +18963,49 @@ endif
endif
RAW_END2END_TEST_SRC = \
test/cpp/end2end/raw_end2end_test.cc \
RAW_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RAW_END2END_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/raw_end2end_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
$(BINDIR)/$(CONFIG)/raw_end2end_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/raw_end2end_test: $(PROTOBUF_DEP) $(RAW_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(RAW_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/raw_end2end_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/raw_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_raw_end2end_test: $(RAW_END2END_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(RAW_END2END_TEST_OBJS:.o=.dep)
endif
endif
RECONNECT_INTEROP_CLIENT_SRC = \
$(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc \

@ -209,6 +209,7 @@ filegroups:
- include/grpc/impl/codegen/fork.h
- include/grpc/impl/codegen/gpr_slice.h
- include/grpc/impl/codegen/gpr_types.h
- include/grpc/impl/codegen/log.h
- include/grpc/impl/codegen/port_platform.h
- include/grpc/impl/codegen/sync.h
- include/grpc/impl/codegen/sync_custom.h
@ -1139,6 +1140,7 @@ filegroups:
- include/grpc++/impl/codegen/stub_options.h
- include/grpc++/impl/codegen/sync_stream.h
- include/grpc++/impl/codegen/time.h
- include/grpcpp/impl/codegen/async_generic_service.h
- include/grpcpp/impl/codegen/async_stream.h
- include/grpcpp/impl/codegen/async_unary_call.h
- include/grpcpp/impl/codegen/byte_buffer.h
@ -5097,6 +5099,19 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
- name: raw_end2end_test
gtest: true
build: test
language: c++
src:
- test/cpp/end2end/raw_end2end_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
- name: reconnect_interop_client
build: test
run: false

@ -121,6 +121,7 @@ Pod::Spec.new do |s|
'include/grpcpp/support/stub_options.h',
'include/grpcpp/support/sync_stream.h',
'include/grpcpp/support/time.h',
'include/grpcpp/impl/codegen/async_generic_service.h',
'include/grpcpp/impl/codegen/async_stream.h',
'include/grpcpp/impl/codegen/async_unary_call.h',
'include/grpcpp/impl/codegen/byte_buffer.h',

@ -133,6 +133,7 @@ Pod::Spec.new do |s|
'include/grpc/impl/codegen/fork.h',
'include/grpc/impl/codegen/gpr_slice.h',
'include/grpc/impl/codegen/gpr_types.h',
'include/grpc/impl/codegen/log.h',
'include/grpc/impl/codegen/port_platform.h',
'include/grpc/impl/codegen/sync.h',
'include/grpc/impl/codegen/sync_custom.h',
@ -154,6 +155,7 @@ Pod::Spec.new do |s|
'include/grpc/impl/codegen/fork.h',
'include/grpc/impl/codegen/gpr_slice.h',
'include/grpc/impl/codegen/gpr_types.h',
'include/grpc/impl/codegen/log.h',
'include/grpc/impl/codegen/port_platform.h',
'include/grpc/impl/codegen/sync.h',
'include/grpc/impl/codegen/sync_custom.h',

@ -129,6 +129,13 @@ EXPORTS
grpc_byte_buffer_reader_next
grpc_byte_buffer_reader_readall
grpc_raw_byte_buffer_from_reader
gpr_log_severity_string
gpr_log
gpr_should_log
gpr_log_message
gpr_set_log_verbosity
gpr_log_verbosity_init
gpr_set_log_function
grpc_slice_ref
grpc_slice_unref
grpc_slice_copy
@ -187,13 +194,6 @@ EXPORTS
gpr_get_allocation_functions
gpr_cpu_num_cores
gpr_cpu_current_cpu
gpr_log_severity_string
gpr_log
gpr_should_log
gpr_log_message
gpr_set_log_verbosity
gpr_log_verbosity_init
gpr_set_log_function
gpr_format_message
gpr_strdup
gpr_asprintf

@ -75,6 +75,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/fork.h )
s.files += %w( include/grpc/impl/codegen/gpr_slice.h )
s.files += %w( include/grpc/impl/codegen/gpr_types.h )
s.files += %w( include/grpc/impl/codegen/log.h )
s.files += %w( include/grpc/impl/codegen/port_platform.h )
s.files += %w( include/grpc/impl/codegen/sync.h )
s.files += %w( include/grpc/impl/codegen/sync_custom.h )
@ -160,6 +161,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/fork.h )
s.files += %w( include/grpc/impl/codegen/gpr_slice.h )
s.files += %w( include/grpc/impl/codegen/gpr_types.h )
s.files += %w( include/grpc/impl/codegen/log.h )
s.files += %w( include/grpc/impl/codegen/port_platform.h )
s.files += %w( include/grpc/impl/codegen/sync.h )
s.files += %w( include/grpc/impl/codegen/sync_custom.h )

@ -0,0 +1,112 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_IMPL_CODEGEN_LOG_H
#define GRPC_IMPL_CODEGEN_LOG_H
#include <grpc/impl/codegen/port_platform.h>
#include <stdarg.h>
#include <stdlib.h> /* for abort() */
#ifdef __cplusplus
extern "C" {
#endif
/** GPR log API.
Usage (within grpc):
int argument1 = 3;
char* argument2 = "hello";
gpr_log(GPR_DEBUG, "format string %d", argument1);
gpr_log(GPR_INFO, "hello world");
gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */
/** The severity of a log message - use the #defines below when calling into
gpr_log to additionally supply file and line data */
typedef enum gpr_log_severity {
GPR_LOG_SEVERITY_DEBUG,
GPR_LOG_SEVERITY_INFO,
GPR_LOG_SEVERITY_ERROR
} gpr_log_severity;
#define GPR_LOG_VERBOSITY_UNSET -1
/** Returns a string representation of the log severity */
GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity);
/** Macros to build log contexts at various severity levels */
#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
#define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
#define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
/** Log a message. It's advised to use GPR_xxx above to generate the context
* for each message */
GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
GPRAPI int gpr_should_log(gpr_log_severity severity);
GPRAPI void gpr_log_message(const char* file, int line,
gpr_log_severity severity, const char* message);
/** Set global log verbosity */
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
GPRAPI void gpr_log_verbosity_init(void);
/** Log overrides: applications can use this API to intercept logging calls
and use their own implementations */
struct gpr_log_func_args {
const char* file;
int line;
gpr_log_severity severity;
const char* message;
};
typedef struct gpr_log_func_args gpr_log_func_args;
typedef void (*gpr_log_func)(gpr_log_func_args* args);
GPRAPI void gpr_set_log_function(gpr_log_func func);
/** abort() the process if x is zero, having written a line to the log.
Intended for internal invariants. If the error can be recovered from,
without the possibility of corruption, or might best be reflected via
an exception in a higher-level language, consider returning error code. */
#define GPR_ASSERT(x) \
do { \
if (GPR_UNLIKELY(!(x))) { \
gpr_log(GPR_ERROR, "assertion failed: %s", #x); \
abort(); \
} \
} while (0)
#ifndef NDEBUG
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(x)
#else
#define GPR_DEBUG_ASSERT(x)
#endif
#ifdef __cplusplus
}
#endif
#endif /* GRPC_IMPL_CODEGEN_LOG_H */

@ -17,6 +17,7 @@ framework module grpc {
header "impl/codegen/fork.h"
header "impl/codegen/gpr_slice.h"
header "impl/codegen/gpr_types.h"
header "impl/codegen/log.h"
header "impl/codegen/port_platform.h"
header "impl/codegen/sync.h"
header "impl/codegen/sync_generic.h"
@ -32,6 +33,7 @@ framework module grpc {
header "impl/codegen/fork.h"
header "impl/codegen/gpr_slice.h"
header "impl/codegen/gpr_types.h"
header "impl/codegen/log.h"
header "impl/codegen/port_platform.h"
header "impl/codegen/sync.h"
header "impl/codegen/sync_generic.h"

@ -19,94 +19,8 @@
#ifndef GRPC_SUPPORT_LOG_H
#define GRPC_SUPPORT_LOG_H
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/support/port_platform.h>
#include <stdarg.h>
#include <stdlib.h> /* for abort() */
#ifdef __cplusplus
extern "C" {
#endif
/** GPR log API.
Usage (within grpc):
int argument1 = 3;
char* argument2 = "hello";
gpr_log(GPR_DEBUG, "format string %d", argument1);
gpr_log(GPR_INFO, "hello world");
gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */
/** The severity of a log message - use the #defines below when calling into
gpr_log to additionally supply file and line data */
typedef enum gpr_log_severity {
GPR_LOG_SEVERITY_DEBUG,
GPR_LOG_SEVERITY_INFO,
GPR_LOG_SEVERITY_ERROR
} gpr_log_severity;
#define GPR_LOG_VERBOSITY_UNSET -1
/** Returns a string representation of the log severity */
GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity);
/** Macros to build log contexts at various severity levels */
#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
#define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
#define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
/** Log a message. It's advised to use GPR_xxx above to generate the context
* for each message */
GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
GPRAPI int gpr_should_log(gpr_log_severity severity);
GPRAPI void gpr_log_message(const char* file, int line,
gpr_log_severity severity, const char* message);
/** Set global log verbosity */
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
GPRAPI void gpr_log_verbosity_init(void);
/** Log overrides: applications can use this API to intercept logging calls
and use their own implementations */
struct gpr_log_func_args {
const char* file;
int line;
gpr_log_severity severity;
const char* message;
};
typedef struct gpr_log_func_args gpr_log_func_args;
typedef void (*gpr_log_func)(gpr_log_func_args* args);
GPRAPI void gpr_set_log_function(gpr_log_func func);
/** abort() the process if x is zero, having written a line to the log.
Intended for internal invariants. If the error can be recovered from,
without the possibility of corruption, or might best be reflected via
an exception in a higher-level language, consider returning error code. */
#define GPR_ASSERT(x) \
do { \
if (GPR_UNLIKELY(!(x))) { \
gpr_log(GPR_ERROR, "assertion failed: %s", #x); \
abort(); \
} \
} while (0)
#ifndef NDEBUG
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(x)
#else
#define GPR_DEBUG_ASSERT(x)
#endif
#ifdef __cplusplus
}
#endif
#include <grpc/impl/codegen/log.h>
#endif /* GRPC_SUPPORT_LOG_H */

@ -1,6 +1,6 @@
/*
*
* Copyright 2015 gRPC authors.
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,60 +19,6 @@
#ifndef GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H
#define GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H
#include <grpcpp/support/async_stream.h>
#include <grpcpp/support/byte_buffer.h>
struct grpc_server;
namespace grpc {
typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer>
GenericServerAsyncReaderWriter;
class GenericServerContext final : public ServerContext {
public:
const grpc::string& method() const { return method_; }
const grpc::string& host() const { return host_; }
private:
friend class Server;
friend class ServerInterface;
grpc::string method_;
grpc::string host_;
};
// A generic service at the server side accepts all RPC methods and hosts. It is
// typically used in proxies. The generic service can be registered to a server
// which also has other services.
// Sample usage:
// ServerBuilder builder;
// auto cq = builder.AddCompletionQueue();
// AsyncGenericService generic_service;
// builder.RegisterAsyncGeneicService(&generic_service);
// auto server = builder.BuildAndStart();
//
// // request a new call
// GenericServerContext context;
// GenericAsyncReaderWriter stream;
// generic_service.RequestCall(&context, &stream, cq.get(), cq.get(), tag);
//
// When tag is retrieved from cq->Next(), context.method() can be used to look
// at the method and the RPC can be handled accordingly.
class AsyncGenericService final {
public:
AsyncGenericService() : server_(nullptr) {}
void RequestCall(GenericServerContext* ctx,
GenericServerAsyncReaderWriter* reader_writer,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag);
private:
friend class Server;
Server* server_;
};
} // namespace grpc
#include <grpcpp/impl/codegen/async_generic_service.h>
#endif // GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H

@ -0,0 +1,81 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H
#define GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/byte_buffer.h>
struct grpc_server;
namespace grpc {
typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer>
GenericServerAsyncReaderWriter;
typedef ServerAsyncResponseWriter<ByteBuffer> GenericServerAsyncResponseWriter;
typedef ServerAsyncReader<ByteBuffer, ByteBuffer> GenericServerAsyncReader;
typedef ServerAsyncWriter<ByteBuffer> GenericServerAsyncWriter;
class GenericServerContext final : public ServerContext {
public:
const grpc::string& method() const { return method_; }
const grpc::string& host() const { return host_; }
private:
friend class Server;
friend class ServerInterface;
grpc::string method_;
grpc::string host_;
};
// A generic service at the server side accepts all RPC methods and hosts. It is
// typically used in proxies. The generic service can be registered to a server
// which also has other services.
// Sample usage:
// ServerBuilder builder;
// auto cq = builder.AddCompletionQueue();
// AsyncGenericService generic_service;
// builder.RegisterAsyncGeneicService(&generic_service);
// auto server = builder.BuildAndStart();
//
// // request a new call
// GenericServerContext context;
// GenericAsyncReaderWriter stream;
// generic_service.RequestCall(&context, &stream, cq.get(), cq.get(), tag);
//
// When tag is retrieved from cq->Next(), context.method() can be used to look
// at the method and the RPC can be handled accordingly.
class AsyncGenericService final {
public:
AsyncGenericService() : server_(nullptr) {}
void RequestCall(GenericServerContext* ctx,
GenericServerAsyncReaderWriter* reader_writer,
CompletionQueue* call_cq,
ServerCompletionQueue* notification_cq, void* tag);
private:
friend class Server;
Server* server_;
};
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H

@ -25,6 +25,7 @@
#include <memory>
#include <vector>
#include <grpc/impl/codegen/log.h>
#include <grpcpp/impl/codegen/byte_buffer.h>
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/rpc_method.h>
@ -58,18 +59,57 @@ class RpcServiceMethod : public RpcMethod {
/// Takes ownership of the handler
RpcServiceMethod(const char* name, RpcMethod::RpcType type,
MethodHandler* handler)
: RpcMethod(name, type), server_tag_(nullptr), handler_(handler) {}
: RpcMethod(name, type),
server_tag_(nullptr),
async_type_(AsyncType::UNSET),
handler_(handler) {}
enum class AsyncType {
UNSET,
ASYNC,
RAW,
};
void set_server_tag(void* tag) { server_tag_ = tag; }
void* server_tag() const { return server_tag_; }
/// if MethodHandler is nullptr, then this is an async method
MethodHandler* handler() const { return handler_.get(); }
void ResetHandler() { handler_.reset(); }
void SetHandler(MethodHandler* handler) { handler_.reset(handler); }
void SetServerAsyncType(RpcServiceMethod::AsyncType type) {
if (async_type_ == AsyncType::UNSET) {
// this marks this method as async
handler_.reset();
} else {
// this is not an error condition, as it allows users to declare a server
// like WithRawMethod_foo<AsyncService>. However since it
// overwrites behavior, it should be logged.
gpr_log(
GPR_INFO,
"You are marking method %s as '%s', even though it was "
"previously marked '%s'. This behavior will overwrite the original "
"behavior. If you expected this then ignore this message.",
name(), TypeToString(async_type_), TypeToString(type));
}
async_type_ = type;
}
private:
void* server_tag_;
AsyncType async_type_;
std::unique_ptr<MethodHandler> handler_;
const char* TypeToString(RpcServiceMethod::AsyncType type) {
switch (type) {
case AsyncType::UNSET:
return "unset";
case AsyncType::ASYNC:
return "async";
case AsyncType::RAW:
return "raw";
default:
GPR_UNREACHABLE_CODE(return "unknown");
}
}
};
} // namespace internal

@ -124,22 +124,39 @@ class Service {
}
void MarkMethodAsync(int index) {
// 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.
GPR_CODEGEN_ASSERT(
methods_[index].get() != nullptr &&
"Cannot mark the method as 'async' because it has already been "
"marked as 'generic'.");
methods_[index]->ResetHandler();
methods_[index]->SetServerAsyncType(
internal::RpcServiceMethod::AsyncType::ASYNC);
}
void MarkMethodRaw(int index) {
// 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.
GPR_CODEGEN_ASSERT(methods_[index].get() != nullptr &&
"Cannot mark the method as 'raw' because it has already "
"been marked as 'generic'.");
methods_[index]->SetServerAsyncType(
internal::RpcServiceMethod::AsyncType::RAW);
}
void MarkMethodGeneric(int index) {
// 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.
GPR_CODEGEN_ASSERT(
methods_[index]->handler() != nullptr &&
"Cannot mark the method as 'generic' because it has already been "
"marked as 'async'.");
"marked as 'async' or 'raw'.");
methods_[index].reset();
}
void MarkMethodStreamed(int index, internal::MethodHandler* streamed_method) {
// 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.
GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() &&
"Cannot mark an async or generic method Streamed");
methods_[index]->SetHandler(streamed_method);

@ -80,6 +80,7 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/fork.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_slice.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_types.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/log.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/port_platform.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_custom.h" role="src" />
@ -165,6 +166,7 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/fork.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_slice.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/gpr_types.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/log.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/port_platform.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_custom.h" role="src" />

@ -128,6 +128,7 @@ grpc::string GetHeaderIncludes(grpc_generator::File* file,
"");
}
static const char* headers_strs[] = {
"grpcpp/impl/codegen/async_generic_service.h",
"grpcpp/impl/codegen/async_stream.h",
"grpcpp/impl/codegen/async_unary_call.h",
"grpcpp/impl/codegen/method_handler_impl.h",
@ -588,43 +589,27 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer* printer,
printer->Print(method->GetTrailingComments("//").c_str());
}
void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars,
"class WithAsyncMethod_$Method$ : public BaseClass {\n");
printer->Print(
" private:\n"
" void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
"WithAsyncMethod_$Method$() {\n"
" ::grpc::Service::MarkMethodAsync($Idx$);\n"
"}\n");
printer->Print(*vars,
"~WithAsyncMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n"
"}\n");
// Helper generator. Disabled the sync API for Request and Response, then adds
// in an async API for RealRequest and RealResponse types. This is to be used
// to generate async and raw APIs.
void PrintHeaderServerAsyncMethodsHelper(
grpc_generator::Printer* printer, const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
if (method->NoStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
"::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response) final override {\n"
"$Response$* response) override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
printer->Print(
*vars,
"void Request$Method$("
"::grpc::ServerContext* context, $Request$* request, "
"::grpc::ServerAsyncResponseWriter< $Response$>* response, "
"::grpc::ServerContext* context, $RealRequest$* request, "
"::grpc::ServerAsyncResponseWriter< $RealResponse$>* response, "
"::grpc::CompletionQueue* new_call_cq, "
"::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n");
printer->Print(*vars,
@ -638,7 +623,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
"::grpc::Status $Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerReader< $Request$>* reader, "
"$Response$* response) final override {\n"
"$Response$* response) override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@ -646,7 +631,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
*vars,
"void Request$Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerAsyncReader< $Response$, $Request$>* reader, "
"::grpc::ServerAsyncReader< $RealResponse$, $RealRequest$>* reader, "
"::grpc::CompletionQueue* new_call_cq, "
"::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n");
printer->Print(*vars,
@ -659,7 +644,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
"// disable synchronous version of this method\n"
"::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer) final override "
"::grpc::ServerWriter< $Response$>* writer) override "
"{\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
@ -667,8 +652,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
printer->Print(
*vars,
"void Request$Method$("
"::grpc::ServerContext* context, $Request$* request, "
"::grpc::ServerAsyncWriter< $Response$>* writer, "
"::grpc::ServerContext* context, $RealRequest$* request, "
"::grpc::ServerAsyncWriter< $RealResponse$>* writer, "
"::grpc::CompletionQueue* new_call_cq, "
"::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n");
printer->Print(
@ -683,7 +668,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
"::grpc::Status $Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerReaderWriter< $Response$, $Request$>* stream) "
"final override {\n"
" override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@ -691,7 +676,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
*vars,
"void Request$Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerAsyncReaderWriter< $Response$, $Request$>* stream, "
"::grpc::ServerAsyncReaderWriter< $RealResponse$, $RealRequest$>* "
"stream, "
"::grpc::CompletionQueue* new_call_cq, "
"::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n");
printer->Print(*vars,
@ -699,6 +685,35 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
"context, stream, new_call_cq, notification_cq, tag);\n");
printer->Print("}\n");
}
}
void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer,
const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
// These will be disabled
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
// These will be used for the async API
(*vars)["RealRequest"] = method->input_type_name();
(*vars)["RealResponse"] = method->output_type_name();
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars,
"class WithAsyncMethod_$Method$ : public BaseClass {\n");
printer->Print(
" private:\n"
" void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
"WithAsyncMethod_$Method$() {\n"
" ::grpc::Service::MarkMethodAsync($Idx$);\n"
"}\n");
printer->Print(*vars,
"~WithAsyncMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n"
"}\n");
PrintHeaderServerAsyncMethodsHelper(printer, method, vars);
printer->Outdent();
printer->Print(*vars, "};\n");
}
@ -738,7 +753,7 @@ void PrintHeaderServerMethodStreamedUnary(
"// disable regular version of this method\n"
"::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response) final override {\n"
"$Response$* response) override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@ -790,7 +805,7 @@ void PrintHeaderServerMethodSplitStreaming(
"// disable regular version of this method\n"
"::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer) final override "
"::grpc::ServerWriter< $Response$>* writer) override "
"{\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
@ -835,7 +850,7 @@ void PrintHeaderServerMethodGeneric(
"// disable synchronous version of this method\n"
"::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response) final override {\n"
"$Response$* response) override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@ -846,7 +861,7 @@ void PrintHeaderServerMethodGeneric(
"::grpc::Status $Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerReader< $Request$>* reader, "
"$Response$* response) final override {\n"
"$Response$* response) override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@ -856,7 +871,7 @@ void PrintHeaderServerMethodGeneric(
"// disable synchronous version of this method\n"
"::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer) final override "
"::grpc::ServerWriter< $Response$>* writer) override "
"{\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
@ -868,7 +883,7 @@ void PrintHeaderServerMethodGeneric(
"::grpc::Status $Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerReaderWriter< $Response$, $Request$>* stream) "
"final override {\n"
" override {\n"
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
@ -877,6 +892,36 @@ void PrintHeaderServerMethodGeneric(
printer->Print(*vars, "};\n");
}
void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer,
const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
// These will be disabled
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
// These will be used for raw API
(*vars)["RealRequest"] = "::grpc::ByteBuffer";
(*vars)["RealResponse"] = "::grpc::ByteBuffer";
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n");
printer->Print(
" private:\n"
" void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
"WithRawMethod_$Method$() {\n"
" ::grpc::Service::MarkMethodRaw($Idx$);\n"
"}\n");
printer->Print(*vars,
"~WithRawMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n"
"}\n");
PrintHeaderServerAsyncMethodsHelper(printer, method, vars);
printer->Outdent();
printer->Print(*vars, "};\n");
}
void PrintHeaderService(grpc_generator::Printer* printer,
const grpc_generator::Service* service,
std::map<grpc::string, grpc::string>* vars) {
@ -981,6 +1026,12 @@ void PrintHeaderService(grpc_generator::Printer* printer,
PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars);
}
// Server side - Raw
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);
PrintHeaderServerMethodRaw(printer, service->method(i).get(), vars);
}
// Server side - Streamed Unary
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);

@ -152,6 +152,13 @@ grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import;
grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import;
grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
gpr_log_severity_string_type gpr_log_severity_string_import;
gpr_log_type gpr_log_import;
gpr_should_log_type gpr_should_log_import;
gpr_log_message_type gpr_log_message_import;
gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
gpr_set_log_function_type gpr_set_log_function_import;
grpc_slice_ref_type grpc_slice_ref_import;
grpc_slice_unref_type grpc_slice_unref_import;
grpc_slice_copy_type grpc_slice_copy_import;
@ -210,13 +217,6 @@ gpr_set_allocation_functions_type gpr_set_allocation_functions_import;
gpr_get_allocation_functions_type gpr_get_allocation_functions_import;
gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
gpr_log_severity_string_type gpr_log_severity_string_import;
gpr_log_type gpr_log_import;
gpr_should_log_type gpr_should_log_import;
gpr_log_message_type gpr_log_message_import;
gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
gpr_set_log_function_type gpr_set_log_function_import;
gpr_format_message_type gpr_format_message_import;
gpr_strdup_type gpr_strdup_import;
gpr_asprintf_type gpr_asprintf_import;
@ -398,6 +398,13 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_byte_buffer_reader_next_import = (grpc_byte_buffer_reader_next_type) GetProcAddress(library, "grpc_byte_buffer_reader_next");
grpc_byte_buffer_reader_readall_import = (grpc_byte_buffer_reader_readall_type) GetProcAddress(library, "grpc_byte_buffer_reader_readall");
grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader");
gpr_log_severity_string_import = (gpr_log_severity_string_type) GetProcAddress(library, "gpr_log_severity_string");
gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log");
gpr_should_log_import = (gpr_should_log_type) GetProcAddress(library, "gpr_should_log");
gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message");
gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity");
gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init");
gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function");
grpc_slice_ref_import = (grpc_slice_ref_type) GetProcAddress(library, "grpc_slice_ref");
grpc_slice_unref_import = (grpc_slice_unref_type) GetProcAddress(library, "grpc_slice_unref");
grpc_slice_copy_import = (grpc_slice_copy_type) GetProcAddress(library, "grpc_slice_copy");
@ -456,13 +463,6 @@ void grpc_rb_load_imports(HMODULE library) {
gpr_get_allocation_functions_import = (gpr_get_allocation_functions_type) GetProcAddress(library, "gpr_get_allocation_functions");
gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores");
gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu");
gpr_log_severity_string_import = (gpr_log_severity_string_type) GetProcAddress(library, "gpr_log_severity_string");
gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log");
gpr_should_log_import = (gpr_should_log_type) GetProcAddress(library, "gpr_should_log");
gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message");
gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity");
gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init");
gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function");
gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message");
gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup");
gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf");

@ -30,11 +30,11 @@
#include <grpc/grpc_posix.h>
#include <grpc/grpc_security.h>
#include <grpc/impl/codegen/byte_buffer.h>
#include <grpc/impl/codegen/log.h>
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
@ -431,6 +431,27 @@ extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_impo
typedef grpc_byte_buffer*(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader* reader);
extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
#define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import
typedef const char*(*gpr_log_severity_string_type)(gpr_log_severity severity);
extern gpr_log_severity_string_type gpr_log_severity_string_import;
#define gpr_log_severity_string gpr_log_severity_string_import
typedef void(*gpr_log_type)(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
extern gpr_log_type gpr_log_import;
#define gpr_log gpr_log_import
typedef int(*gpr_should_log_type)(gpr_log_severity severity);
extern gpr_should_log_type gpr_should_log_import;
#define gpr_should_log gpr_should_log_import
typedef void(*gpr_log_message_type)(const char* file, int line, gpr_log_severity severity, const char* message);
extern gpr_log_message_type gpr_log_message_import;
#define gpr_log_message gpr_log_message_import
typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print);
extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
#define gpr_set_log_verbosity gpr_set_log_verbosity_import
typedef void(*gpr_log_verbosity_init_type)(void);
extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
#define gpr_log_verbosity_init gpr_log_verbosity_init_import
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
typedef grpc_slice(*grpc_slice_ref_type)(grpc_slice s);
extern grpc_slice_ref_type grpc_slice_ref_import;
#define grpc_slice_ref grpc_slice_ref_import
@ -605,27 +626,6 @@ extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
typedef unsigned(*gpr_cpu_current_cpu_type)(void);
extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
#define gpr_cpu_current_cpu gpr_cpu_current_cpu_import
typedef const char*(*gpr_log_severity_string_type)(gpr_log_severity severity);
extern gpr_log_severity_string_type gpr_log_severity_string_import;
#define gpr_log_severity_string gpr_log_severity_string_import
typedef void(*gpr_log_type)(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
extern gpr_log_type gpr_log_import;
#define gpr_log gpr_log_import
typedef int(*gpr_should_log_type)(gpr_log_severity severity);
extern gpr_should_log_type gpr_should_log_import;
#define gpr_should_log gpr_should_log_import
typedef void(*gpr_log_message_type)(const char* file, int line, gpr_log_severity severity, const char* message);
extern gpr_log_message_type gpr_log_message_import;
#define gpr_log_message gpr_log_message_import
typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print);
extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
#define gpr_set_log_verbosity gpr_set_log_verbosity_import
typedef void(*gpr_log_verbosity_init_type)(void);
extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
#define gpr_log_verbosity_init gpr_log_verbosity_init_import
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
typedef char*(*gpr_format_message_type)(int messageid);
extern gpr_format_message_type gpr_format_message_import;
#define gpr_format_message gpr_format_message_import

@ -33,6 +33,7 @@
#include <grpc/impl/codegen/gpr_slice.h>
#include <grpc/impl/codegen/gpr_types.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/log.h>
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/impl/codegen/propagation_bits.h>
#include <grpc/impl/codegen/slice.h>
@ -187,6 +188,13 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_byte_buffer_reader_next);
printf("%lx", (unsigned long) grpc_byte_buffer_reader_readall);
printf("%lx", (unsigned long) grpc_raw_byte_buffer_from_reader);
printf("%lx", (unsigned long) gpr_log_severity_string);
printf("%lx", (unsigned long) gpr_log);
printf("%lx", (unsigned long) gpr_should_log);
printf("%lx", (unsigned long) gpr_log_message);
printf("%lx", (unsigned long) gpr_set_log_verbosity);
printf("%lx", (unsigned long) gpr_log_verbosity_init);
printf("%lx", (unsigned long) gpr_set_log_function);
printf("%lx", (unsigned long) grpc_slice_ref);
printf("%lx", (unsigned long) grpc_slice_unref);
printf("%lx", (unsigned long) grpc_slice_copy);
@ -245,13 +253,6 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) gpr_get_allocation_functions);
printf("%lx", (unsigned long) gpr_cpu_num_cores);
printf("%lx", (unsigned long) gpr_cpu_current_cpu);
printf("%lx", (unsigned long) gpr_log_severity_string);
printf("%lx", (unsigned long) gpr_log);
printf("%lx", (unsigned long) gpr_should_log);
printf("%lx", (unsigned long) gpr_log_message);
printf("%lx", (unsigned long) gpr_set_log_verbosity);
printf("%lx", (unsigned long) gpr_log_verbosity_init);
printf("%lx", (unsigned long) gpr_set_log_function);
printf("%lx", (unsigned long) gpr_strdup);
printf("%lx", (unsigned long) gpr_asprintf);
printf("%lx", (unsigned long) gpr_mu_init);

@ -26,6 +26,7 @@
#include "src/proto/grpc/testing/compiler_test.pb.h"
#include <grpcpp/impl/codegen/async_generic_service.h>
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/method_handler_impl.h>
@ -207,7 +208,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -227,7 +228,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) final override {
::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -247,7 +248,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) final override {
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -267,7 +268,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) final override {
::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -288,7 +289,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -305,7 +306,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) final override {
::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -322,7 +323,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) final override {
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -339,12 +340,92 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) final override {
::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
class WithRawMethod_MethodA1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithRawMethod_MethodA1() {
::grpc::Service::MarkMethodRaw(0);
}
~WithRawMethod_MethodA1() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestMethodA1(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithRawMethod_MethodA2 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithRawMethod_MethodA2() {
::grpc::Service::MarkMethodRaw(1);
}
~WithRawMethod_MethodA2() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestMethodA2(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncClientStreaming(1, context, reader, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithRawMethod_MethodA3 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithRawMethod_MethodA3() {
::grpc::Service::MarkMethodRaw(2);
}
~WithRawMethod_MethodA3() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestMethodA3(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncWriter< ::grpc::ByteBuffer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncServerStreaming(2, context, request, writer, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithRawMethod_MethodA4 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithRawMethod_MethodA4() {
::grpc::Service::MarkMethodRaw(3);
}
~WithRawMethod_MethodA4() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestMethodA4(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithStreamedUnaryMethod_MethodA1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
@ -357,7 +438,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -378,7 +459,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) final override {
::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -450,7 +531,7 @@ class ServiceB final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@ -471,12 +552,32 @@ class ServiceB final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
class WithRawMethod_MethodB1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithRawMethod_MethodB1() {
::grpc::Service::MarkMethodRaw(0);
}
~WithRawMethod_MethodB1() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestMethodB1(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithStreamedUnaryMethod_MethodB1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
@ -489,7 +590,7 @@ class ServiceB final {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

@ -241,6 +241,26 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "raw_end2end_test",
srcs = ["raw_end2end_test.cc"],
external_deps = [
"gtest",
],
deps = [
":test_service_impl",
"//:gpr",
"//:grpc",
"//:grpc++",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
)
grpc_cc_test(
name = "mock_test",
srcs = ["mock_test.cc"],

@ -74,6 +74,27 @@ void HandleEcho(Service* service, ServerCompletionQueue* cq, bool dup_service) {
Verify(cq, 2, true);
}
// Handlers to handle raw request at a server. To be run in a
// separate thread. Note that this is the same as the async version, except
// that the req/resp are ByteBuffers
template <class Service>
void HandleRawEcho(Service* service, ServerCompletionQueue* cq,
bool dup_service) {
ServerContext srv_ctx;
GenericServerAsyncResponseWriter response_writer(&srv_ctx);
ByteBuffer recv_buffer;
service->RequestEcho(&srv_ctx, &recv_buffer, &response_writer, cq, cq,
tag(1));
Verify(cq, 1, true);
EchoRequest recv_request;
EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request));
EchoResponse send_response;
send_response.set_message(recv_request.message());
auto send_buffer = SerializeToByteBuffer(&send_response);
response_writer.Finish(*send_buffer, Status::OK, tag(2));
Verify(cq, 2, true);
}
template <class Service>
void HandleClientStreaming(Service* service, ServerCompletionQueue* cq) {
ServerContext srv_ctx;
@ -92,6 +113,30 @@ void HandleClientStreaming(Service* service, ServerCompletionQueue* cq) {
Verify(cq, 100, true);
}
template <class Service>
void HandleRawClientStreaming(Service* service, ServerCompletionQueue* cq) {
ServerContext srv_ctx;
ByteBuffer recv_buffer;
EchoRequest recv_request;
EchoResponse send_response;
GenericServerAsyncReader srv_stream(&srv_ctx);
service->RequestRequestStream(&srv_ctx, &srv_stream, cq, cq, tag(1));
Verify(cq, 1, true);
int i = 1;
while (true) {
i++;
srv_stream.Read(&recv_buffer, tag(i));
if (!VerifyReturnSuccess(cq, i)) {
break;
}
EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request));
send_response.mutable_message()->append(recv_request.message());
}
auto send_buffer = SerializeToByteBuffer(&send_response);
srv_stream.Finish(*send_buffer, Status::OK, tag(100));
Verify(cq, 100, true);
}
template <class Service>
void HandleServerStreaming(Service* service, ServerCompletionQueue* cq) {
ServerContext srv_ctx;
@ -379,6 +424,61 @@ TEST_F(HybridEnd2endTest, AsyncEcho) {
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, RawEcho) {
typedef EchoTestService::WithRawMethod_Echo<TestServiceImpl> SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(HandleRawEcho<SType>, &service, cqs_[0].get(),
false);
TestAllMethods();
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, RawRequestStream) {
typedef EchoTestService::WithRawMethod_RequestStream<TestServiceImpl> SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
&service, cqs_[0].get());
TestAllMethods();
request_stream_handler_thread.join();
}
TEST_F(HybridEnd2endTest, AsyncEchoRawRequestStream) {
typedef EchoTestService::WithRawMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>
SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(),
false);
std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
request_stream_handler_thread.join();
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, GenericEchoRawRequestStream) {
typedef EchoTestService::WithRawMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
generic_handler_thread.join();
request_stream_handler_thread.join();
}
TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>

@ -0,0 +1,370 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <cinttypes>
#include <memory>
#include <thread>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/port.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/util/byte_buffer_proto_helper.h"
#include "test/cpp/util/string_ref_helper.h"
#include <gtest/gtest.h>
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
namespace grpc {
namespace testing {
namespace {
void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); }
class Verifier {
public:
Verifier() {}
// Expect sets the expected ok value for a specific tag
Verifier& Expect(int i, bool expect_ok) {
expectations_[tag(i)] = expect_ok;
return *this;
}
// Next waits for 1 async tag to complete, checks its
// expectations, and returns the tag
int Next(CompletionQueue* cq, bool ignore_ok) {
bool ok;
void* got_tag;
EXPECT_TRUE(cq->Next(&got_tag, &ok));
GotTag(got_tag, ok, ignore_ok);
return detag(got_tag);
}
// Verify keeps calling Next until all currently set
// expected tags are complete
void Verify(CompletionQueue* cq) {
GPR_ASSERT(!expectations_.empty());
while (!expectations_.empty()) {
Next(cq, false);
}
}
private:
void GotTag(void* got_tag, bool ok, bool ignore_ok) {
auto it = expectations_.find(got_tag);
if (it != expectations_.end()) {
if (!ignore_ok) {
EXPECT_EQ(it->second, ok);
}
expectations_.erase(it);
}
}
std::map<void*, bool> expectations_;
};
class RawEnd2EndTest : public ::testing::Test {
protected:
RawEnd2EndTest() {}
void SetUp() override {
port_ = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port_;
}
void TearDown() override {
server_->Shutdown();
void* ignored_tag;
bool ignored_ok;
cq_->Shutdown();
while (cq_->Next(&ignored_tag, &ignored_ok))
;
stub_.reset();
grpc_recycle_unused_port(port_);
}
template <typename ServerType>
std::unique_ptr<ServerType> BuildAndStartServer() {
ServerBuilder builder;
builder.AddListeningPort(server_address_.str(),
grpc::InsecureServerCredentials());
std::unique_ptr<ServerType> service(new ServerType());
builder.RegisterService(service.get());
cq_ = builder.AddCompletionQueue();
server_ = builder.BuildAndStart();
return service;
}
void ResetStub() {
ChannelArguments args;
std::shared_ptr<Channel> channel = CreateChannel(
server_address_.str(), grpc::InsecureChannelCredentials());
stub_ = grpc::testing::EchoTestService::NewStub(channel);
}
std::unique_ptr<ServerCompletionQueue> cq_;
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
std::unique_ptr<Server> server_;
std::ostringstream server_address_;
int port_;
// For the client application to populate and send to server.
EchoRequest send_request_;
::grpc::ByteBuffer send_request_buffer_;
// For the server to give to gRPC to be populated by incoming request
// from client.
EchoRequest recv_request_;
::grpc::ByteBuffer recv_request_buffer_;
// For the server application to populate and send back to client.
EchoResponse send_response_;
::grpc::ByteBuffer send_response_buffer_;
// For the client to give to gRPC to be populated by incoming response
// from server.
EchoResponse recv_response_;
::grpc::ByteBuffer recv_response_buffer_;
Status recv_status_;
// Both sides need contexts
ClientContext cli_ctx_;
ServerContext srv_ctx_;
};
// Regular Async, both peers use proto
TEST_F(RawEnd2EndTest, PureAsyncService) {
typedef grpc::testing::EchoTestService::AsyncService SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx_);
send_request_.set_message("hello");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
stub_->AsyncEcho(&cli_ctx_, send_request_, cq_.get()));
service->RequestEcho(&srv_ctx_, &recv_request_, &response_writer, cq_.get(),
cq_.get(), tag(2));
response_reader->Finish(&recv_response_, &recv_status_, tag(4));
Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request_.message(), recv_request_.message());
send_response_.set_message(recv_request_.message());
response_writer.Finish(send_response_, Status::OK, tag(3));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_response_.message(), recv_response_.message());
EXPECT_TRUE(recv_status_.ok());
}
// Client uses proto, server uses generic codegen, unary
TEST_F(RawEnd2EndTest, RawServerUnary) {
typedef grpc::testing::EchoTestService::WithRawMethod_Echo<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
grpc::GenericServerAsyncResponseWriter response_writer(&srv_ctx_);
send_request_.set_message("hello unary");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
stub_->AsyncEcho(&cli_ctx_, send_request_, cq_.get()));
service->RequestEcho(&srv_ctx_, &recv_request_buffer_, &response_writer,
cq_.get(), cq_.get(), tag(2));
response_reader->Finish(&recv_response_, &recv_status_, tag(4));
Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_TRUE(ParseFromByteBuffer(&recv_request_buffer_, &recv_request_));
EXPECT_EQ(send_request_.message(), recv_request_.message());
send_response_.set_message(recv_request_.message());
EXPECT_TRUE(
SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_));
response_writer.Finish(send_response_buffer_, Status::OK, tag(3));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_response_.message(), recv_response_.message());
EXPECT_TRUE(recv_status_.ok());
}
// Client uses proto, server uses generic codegen, client streaming
TEST_F(RawEnd2EndTest, RawServerClientStreaming) {
typedef grpc::testing::EchoTestService::WithRawMethod_RequestStream<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
grpc::GenericServerAsyncReader srv_stream(&srv_ctx_);
send_request_.set_message("hello client streaming");
std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream(
stub_->AsyncRequestStream(&cli_ctx_, &recv_response_, cq_.get(), tag(1)));
service->RequestRequestStream(&srv_ctx_, &srv_stream, cq_.get(), cq_.get(),
tag(2));
Verifier().Expect(2, true).Expect(1, true).Verify(cq_.get());
cli_stream->Write(send_request_, tag(3));
srv_stream.Read(&recv_request_buffer_, tag(4));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
EXPECT_EQ(send_request_.message(), recv_request_.message());
cli_stream->Write(send_request_, tag(5));
srv_stream.Read(&recv_request_buffer_, tag(6));
Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get());
ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
EXPECT_EQ(send_request_.message(), recv_request_.message());
cli_stream->WritesDone(tag(7));
srv_stream.Read(&recv_request_buffer_, tag(8));
Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get());
ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
send_response_.set_message(recv_request_.message());
SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_);
srv_stream.Finish(send_response_buffer_, Status::OK, tag(9));
cli_stream->Finish(&recv_status_, tag(10));
Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get());
EXPECT_EQ(send_response_.message(), recv_response_.message());
EXPECT_TRUE(recv_status_.ok());
}
// Client uses proto, server uses generic codegen, server streaming
TEST_F(RawEnd2EndTest, RawServerServerStreaming) {
typedef grpc::testing::EchoTestService::WithRawMethod_ResponseStream<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
grpc::GenericServerAsyncWriter srv_stream(&srv_ctx_);
send_request_.set_message("hello server streaming");
std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream(
stub_->AsyncResponseStream(&cli_ctx_, send_request_, cq_.get(), tag(1)));
service->RequestResponseStream(&srv_ctx_, &recv_request_buffer_, &srv_stream,
cq_.get(), cq_.get(), tag(2));
Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get());
ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
EXPECT_EQ(send_request_.message(), recv_request_.message());
send_response_.set_message(recv_request_.message());
SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_);
srv_stream.Write(send_response_buffer_, tag(3));
cli_stream->Read(&recv_response_, tag(4));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
EXPECT_EQ(send_response_.message(), recv_response_.message());
srv_stream.Write(send_response_buffer_, tag(5));
cli_stream->Read(&recv_response_, tag(6));
Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_response_.message(), recv_response_.message());
srv_stream.Finish(Status::OK, tag(7));
cli_stream->Read(&recv_response_, tag(8));
Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get());
cli_stream->Finish(&recv_status_, tag(9));
Verifier().Expect(9, true).Verify(cq_.get());
EXPECT_TRUE(recv_status_.ok());
}
// Client uses proto, server uses generic codegen, bidi streaming
TEST_F(RawEnd2EndTest, RawServerBidiStreaming) {
typedef grpc::testing::EchoTestService::WithRawMethod_BidiStream<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
grpc::GenericServerAsyncReaderWriter srv_stream(&srv_ctx_);
send_request_.set_message("hello bidi streaming");
std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>>
cli_stream(stub_->AsyncBidiStream(&cli_ctx_, cq_.get(), tag(1)));
service->RequestBidiStream(&srv_ctx_, &srv_stream, cq_.get(), cq_.get(),
tag(2));
Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get());
cli_stream->Write(send_request_, tag(3));
srv_stream.Read(&recv_request_buffer_, tag(4));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
EXPECT_EQ(send_request_.message(), recv_request_.message());
send_response_.set_message(recv_request_.message());
SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_);
srv_stream.Write(send_response_buffer_, tag(5));
cli_stream->Read(&recv_response_, tag(6));
Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get());
EXPECT_EQ(send_response_.message(), recv_response_.message());
cli_stream->WritesDone(tag(7));
srv_stream.Read(&recv_request_buffer_, tag(8));
Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get());
srv_stream.Finish(Status::OK, tag(9));
cli_stream->Finish(&recv_status_, tag(10));
Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get());
EXPECT_TRUE(recv_status_.ok());
}
// Testing that this pattern compiles
TEST_F(RawEnd2EndTest, CompileTest) {
typedef grpc::testing::EchoTestService::WithRawMethod_Echo<
grpc::testing::EchoTestService::AsyncService>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
}
} // namespace
} // namespace testing
} // namespace grpc
int main(int argc, char** argv) {
// Change the backup poll interval from 5s to 100ms to speed up the
// ReconnectChannel test
grpc_test_init(argc, argv);
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}

@ -40,5 +40,18 @@ std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
return std::unique_ptr<ByteBuffer>(new ByteBuffer(&slice, 1));
}
bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,
ByteBuffer* buffer) {
grpc::string buf;
if (!message->SerializeToString(&buf)) {
return false;
}
buffer->Clear();
Slice slice(buf);
ByteBuffer tmp(&slice, 1);
buffer->Swap(&tmp);
return true;
}
} // namespace testing
} // namespace grpc

@ -32,6 +32,9 @@ bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message);
std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
grpc::protobuf::Message* message);
bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,
ByteBuffer* buffer);
} // namespace testing
} // namespace grpc

@ -891,6 +891,7 @@ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@ -936,6 +937,7 @@ include/grpcpp/health_check_service_interface.h \
include/grpcpp/impl/call.h \
include/grpcpp/impl/channel_argument_option.h \
include/grpcpp/impl/client_unary_call.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \

@ -892,6 +892,7 @@ include/grpc/impl/codegen/fork.h \
include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/propagation_bits.h \
include/grpc/impl/codegen/slice.h \
@ -937,6 +938,7 @@ include/grpcpp/health_check_service_interface.h \
include/grpcpp/impl/call.h \
include/grpcpp/impl/channel_argument_option.h \
include/grpcpp/impl/client_unary_call.h \
include/grpcpp/impl/codegen/async_generic_service.h \
include/grpcpp/impl/codegen/async_stream.h \
include/grpcpp/impl/codegen/async_unary_call.h \
include/grpcpp/impl/codegen/byte_buffer.h \

@ -825,6 +825,8 @@ include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/propagation_bits.h \

@ -825,6 +825,8 @@ include/grpc/impl/codegen/gpr_slice.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/gpr_types.h \
include/grpc/impl/codegen/grpc_types.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/log.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/port_platform.h \
include/grpc/impl/codegen/propagation_bits.h \

@ -4280,6 +4280,25 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc++",
"grpc++_test_util",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c++",
"name": "raw_end2end_test",
"src": [
"test/cpp/end2end/raw_end2end_test.cc"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -9252,6 +9271,7 @@
"include/grpc/impl/codegen/fork.h",
"include/grpc/impl/codegen/gpr_slice.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/log.h",
"include/grpc/impl/codegen/port_platform.h",
"include/grpc/impl/codegen/sync.h",
"include/grpc/impl/codegen/sync_custom.h",
@ -9270,6 +9290,7 @@
"include/grpc/impl/codegen/fork.h",
"include/grpc/impl/codegen/gpr_slice.h",
"include/grpc/impl/codegen/gpr_types.h",
"include/grpc/impl/codegen/log.h",
"include/grpc/impl/codegen/port_platform.h",
"include/grpc/impl/codegen/sync.h",
"include/grpc/impl/codegen/sync_custom.h",
@ -10886,6 +10907,7 @@
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h",
"include/grpcpp/impl/codegen/async_generic_service.h",
"include/grpcpp/impl/codegen/async_stream.h",
"include/grpcpp/impl/codegen/async_unary_call.h",
"include/grpcpp/impl/codegen/byte_buffer.h",
@ -10951,6 +10973,7 @@
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync_stream.h",
"include/grpc++/impl/codegen/time.h",
"include/grpcpp/impl/codegen/async_generic_service.h",
"include/grpcpp/impl/codegen/async_stream.h",
"include/grpcpp/impl/codegen/async_unary_call.h",
"include/grpcpp/impl/codegen/byte_buffer.h",

@ -4709,6 +4709,30 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "raw_end2end_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,

Loading…
Cancel
Save