Added status_helper (#25901)

Added status_util
reviewable/pr26026/r4^2
Esun Kim 4 years ago committed by GitHub
parent 265dc3bd33
commit 2d8936b097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      BUILD
  2. 50
      BUILD.gn
  3. 73
      CMakeLists.txt
  4. 64
      Makefile
  5. 84
      build_autogenerated.yaml
  6. 1
      config.m4
  7. 1
      config.w32
  8. 2
      gRPC-C++.podspec
  9. 3
      gRPC-Core.podspec
  10. 2
      grpc.gemspec
  11. 37
      grpc.gyp
  12. 2
      package.xml
  13. 320
      src/core/lib/gprpp/status_helper.cc
  14. 147
      src/core/lib/gprpp/status_helper.h
  15. 6
      src/core/lib/iomgr/error.cc
  16. 6
      src/core/lib/iomgr/error.h
  17. 1
      src/python/grpcio/grpc_core_dependencies.py
  18. 14
      test/core/gprpp/BUILD
  19. 128
      test/core/gprpp/status_helper_test.cc
  20. 2
      tools/doxygen/Doxyfile.c++.internal
  21. 2
      tools/doxygen/Doxyfile.core.internal
  22. 24
      tools/run_tests/generated/tests.json

@ -591,6 +591,7 @@ grpc_cc_library(
"src/core/lib/gprpp/mpscq.cc",
"src/core/lib/gprpp/stat_posix.cc",
"src/core/lib/gprpp/stat_windows.cc",
"src/core/lib/gprpp/status_helper.cc",
"src/core/lib/gprpp/thd_posix.cc",
"src/core/lib/gprpp/thd_windows.cc",
"src/core/lib/gprpp/time_util.cc",
@ -626,6 +627,7 @@ grpc_cc_library(
"src/core/lib/gprpp/memory.h",
"src/core/lib/gprpp/mpscq.h",
"src/core/lib/gprpp/stat.h",
"src/core/lib/gprpp/status_helper.h",
"src/core/lib/gprpp/sync.h",
"src/core/lib/gprpp/thd.h",
"src/core/lib/gprpp/time_util.h",
@ -644,6 +646,8 @@ grpc_cc_library(
language = "c++",
public_hdrs = GPR_PUBLIC_HDRS,
deps = [
"debug_location",
"google_api_upb",
"gpr_codegen",
"grpc_codegen",
],

@ -97,6 +97,28 @@ config("grpc_config") {
"include/grpc/support/sync_windows.h",
"include/grpc/support/thd_id.h",
"include/grpc/support/time.h",
"src/core/ext/upb-generated/google/api/annotations.upb.c",
"src/core/ext/upb-generated/google/api/annotations.upb.h",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h",
"src/core/ext/upb-generated/google/api/http.upb.c",
"src/core/ext/upb-generated/google/api/http.upb.h",
"src/core/ext/upb-generated/google/protobuf/any.upb.c",
"src/core/ext/upb-generated/google/protobuf/any.upb.h",
"src/core/ext/upb-generated/google/protobuf/duration.upb.c",
"src/core/ext/upb-generated/google/protobuf/duration.upb.h",
"src/core/ext/upb-generated/google/protobuf/empty.upb.c",
"src/core/ext/upb-generated/google/protobuf/empty.upb.h",
"src/core/ext/upb-generated/google/protobuf/struct.upb.c",
"src/core/ext/upb-generated/google/protobuf/struct.upb.h",
"src/core/ext/upb-generated/google/protobuf/timestamp.upb.c",
"src/core/ext/upb-generated/google/protobuf/timestamp.upb.h",
"src/core/ext/upb-generated/google/protobuf/wrappers.upb.c",
"src/core/ext/upb-generated/google/protobuf/wrappers.upb.h",
"src/core/ext/upb-generated/google/rpc/status.upb.c",
"src/core/ext/upb-generated/google/rpc/status.upb.h",
"src/core/lib/gpr/alloc.cc",
"src/core/lib/gpr/alloc.h",
"src/core/lib/gpr/arena.h",
@ -147,6 +169,7 @@ config("grpc_config") {
"src/core/lib/gprpp/arena.cc",
"src/core/lib/gprpp/arena.h",
"src/core/lib/gprpp/atomic.h",
"src/core/lib/gprpp/debug_location.h",
"src/core/lib/gprpp/examine_stack.cc",
"src/core/lib/gprpp/examine_stack.h",
"src/core/lib/gprpp/fork.cc",
@ -165,6 +188,8 @@ config("grpc_config") {
"src/core/lib/gprpp/stat.h",
"src/core/lib/gprpp/stat_posix.cc",
"src/core/lib/gprpp/stat_windows.cc",
"src/core/lib/gprpp/status_helper.cc",
"src/core/lib/gprpp/status_helper.h",
"src/core/lib/gprpp/sync.h",
"src/core/lib/gprpp/thd.h",
"src/core/lib/gprpp/thd_posix.cc",
@ -184,6 +209,7 @@ config("grpc_config") {
":absl/synchronization:synchronization",
":absl/time:time",
":absl/types:optional",
":upb",
]
public_configs = [
@ -546,28 +572,6 @@ config("grpc_config") {
"src/core/ext/upb-generated/envoy/type/v3/range.upb.h",
"src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c",
"src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h",
"src/core/ext/upb-generated/google/api/annotations.upb.c",
"src/core/ext/upb-generated/google/api/annotations.upb.h",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c",
"src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h",
"src/core/ext/upb-generated/google/api/http.upb.c",
"src/core/ext/upb-generated/google/api/http.upb.h",
"src/core/ext/upb-generated/google/protobuf/any.upb.c",
"src/core/ext/upb-generated/google/protobuf/any.upb.h",
"src/core/ext/upb-generated/google/protobuf/duration.upb.c",
"src/core/ext/upb-generated/google/protobuf/duration.upb.h",
"src/core/ext/upb-generated/google/protobuf/empty.upb.c",
"src/core/ext/upb-generated/google/protobuf/empty.upb.h",
"src/core/ext/upb-generated/google/protobuf/struct.upb.c",
"src/core/ext/upb-generated/google/protobuf/struct.upb.h",
"src/core/ext/upb-generated/google/protobuf/timestamp.upb.c",
"src/core/ext/upb-generated/google/protobuf/timestamp.upb.h",
"src/core/ext/upb-generated/google/protobuf/wrappers.upb.c",
"src/core/ext/upb-generated/google/protobuf/wrappers.upb.h",
"src/core/ext/upb-generated/google/rpc/status.upb.c",
"src/core/ext/upb-generated/google/rpc/status.upb.h",
"src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c",
"src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h",
"src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c",
@ -856,7 +860,6 @@ config("grpc_config") {
"src/core/lib/event_engine/slice_allocator.cc",
"src/core/lib/event_engine/sockaddr.cc",
"src/core/lib/gprpp/atomic.h",
"src/core/lib/gprpp/debug_location.h",
"src/core/lib/gprpp/dual_ref_counted.h",
"src/core/lib/gprpp/orphanable.h",
"src/core/lib/gprpp/ref_counted.h",
@ -1282,7 +1285,6 @@ config("grpc_config") {
":gpr",
"//third_party/boringssl",
":address_sorting",
":upb",
"//third_party/cares",
":address_sorting",
]

@ -938,6 +938,7 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx stat_test)
add_dependencies(buildtests_cxx static_metadata_test)
add_dependencies(buildtests_cxx stats_test)
add_dependencies(buildtests_cxx status_helper_test)
add_dependencies(buildtests_cxx status_metadata_test)
add_dependencies(buildtests_cxx status_util_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@ -1318,6 +1319,17 @@ target_link_libraries(end2end_tests
endif()
add_library(gpr
src/core/ext/upb-generated/google/api/annotations.upb.c
src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c
src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c
src/core/ext/upb-generated/google/api/http.upb.c
src/core/ext/upb-generated/google/protobuf/any.upb.c
src/core/ext/upb-generated/google/protobuf/duration.upb.c
src/core/ext/upb-generated/google/protobuf/empty.upb.c
src/core/ext/upb-generated/google/protobuf/struct.upb.c
src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
src/core/ext/upb-generated/google/rpc/status.upb.c
src/core/lib/gpr/alloc.cc
src/core/lib/gpr/atm.cc
src/core/lib/gpr/cpu_iphone.cc
@ -1358,6 +1370,7 @@ add_library(gpr
src/core/lib/gprpp/mpscq.cc
src/core/lib/gprpp/stat_posix.cc
src/core/lib/gprpp/stat_windows.cc
src/core/lib/gprpp/status_helper.cc
src/core/lib/gprpp/thd_posix.cc
src/core/lib/gprpp/thd_windows.cc
src/core/lib/gprpp/time_util.cc
@ -1404,6 +1417,7 @@ target_link_libraries(gpr
absl::synchronization
absl::time
absl::optional
upb
)
if(_gRPC_PLATFORM_ANDROID)
target_link_libraries(gpr
@ -1651,17 +1665,6 @@ add_library(grpc
src/core/ext/upb-generated/envoy/type/v3/percent.upb.c
src/core/ext/upb-generated/envoy/type/v3/range.upb.c
src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c
src/core/ext/upb-generated/google/api/annotations.upb.c
src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c
src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c
src/core/ext/upb-generated/google/api/http.upb.c
src/core/ext/upb-generated/google/protobuf/any.upb.c
src/core/ext/upb-generated/google/protobuf/duration.upb.c
src/core/ext/upb-generated/google/protobuf/empty.upb.c
src/core/ext/upb-generated/google/protobuf/struct.upb.c
src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
src/core/ext/upb-generated/google/rpc/status.upb.c
src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c
src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c
src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c
@ -2075,7 +2078,6 @@ target_link_libraries(grpc
gpr
${_gRPC_SSL_LIBRARIES}
address_sorting
upb
)
if(_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
target_link_libraries(grpc "-framework CoreFoundation")
@ -2399,17 +2401,6 @@ add_library(grpc_unsecure
src/core/ext/transport/chttp2/transport/writing.cc
src/core/ext/transport/inproc/inproc_plugin.cc
src/core/ext/transport/inproc/inproc_transport.cc
src/core/ext/upb-generated/google/api/annotations.upb.c
src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c
src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c
src/core/ext/upb-generated/google/api/http.upb.c
src/core/ext/upb-generated/google/protobuf/any.upb.c
src/core/ext/upb-generated/google/protobuf/duration.upb.c
src/core/ext/upb-generated/google/protobuf/empty.upb.c
src/core/ext/upb-generated/google/protobuf/struct.upb.c
src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
src/core/ext/upb-generated/google/rpc/status.upb.c
src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c
src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c
src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c
@ -2625,7 +2616,6 @@ target_link_libraries(grpc_unsecure
absl::statusor
gpr
address_sorting
upb
)
if(_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
target_link_libraries(grpc_unsecure "-framework CoreFoundation")
@ -13769,6 +13759,41 @@ target_link_libraries(stats_test
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(status_helper_test
test/core/gprpp/status_helper_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(status_helper_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(status_helper_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
if(gRPC_BUILD_TESTS)

@ -905,6 +905,17 @@ endif
# start of build recipe for library "gpr" (generated by makelib(lib) template function)
LIBGPR_SRC = \
src/core/ext/upb-generated/google/api/annotations.upb.c \
src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c \
src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c \
src/core/ext/upb-generated/google/api/http.upb.c \
src/core/ext/upb-generated/google/protobuf/any.upb.c \
src/core/ext/upb-generated/google/protobuf/duration.upb.c \
src/core/ext/upb-generated/google/protobuf/empty.upb.c \
src/core/ext/upb-generated/google/protobuf/struct.upb.c \
src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \
src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \
src/core/ext/upb-generated/google/rpc/status.upb.c \
src/core/lib/gpr/alloc.cc \
src/core/lib/gpr/atm.cc \
src/core/lib/gpr/cpu_iphone.cc \
@ -945,6 +956,7 @@ LIBGPR_SRC = \
src/core/lib/gprpp/mpscq.cc \
src/core/lib/gprpp/stat_posix.cc \
src/core/lib/gprpp/stat_windows.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/thd_posix.cc \
src/core/lib/gprpp/thd_windows.cc \
src/core/lib/gprpp/time_util.cc \
@ -1009,18 +1021,18 @@ endif
ifeq ($(SYSTEM),MINGW32)
$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP)
$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libupb.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
else
$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP)
$(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libupb.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.16 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.16 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.16
$(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so
endif
@ -1212,17 +1224,6 @@ LIBGRPC_SRC = \
src/core/ext/upb-generated/envoy/type/v3/percent.upb.c \
src/core/ext/upb-generated/envoy/type/v3/range.upb.c \
src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c \
src/core/ext/upb-generated/google/api/annotations.upb.c \
src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c \
src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c \
src/core/ext/upb-generated/google/api/http.upb.c \
src/core/ext/upb-generated/google/protobuf/any.upb.c \
src/core/ext/upb-generated/google/protobuf/duration.upb.c \
src/core/ext/upb-generated/google/protobuf/empty.upb.c \
src/core/ext/upb-generated/google/protobuf/struct.upb.c \
src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \
src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \
src/core/ext/upb-generated/google/rpc/status.upb.c \
src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \
src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \
src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \
@ -1636,18 +1637,18 @@ endif
ifeq ($(SYSTEM),MINGW32)
$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_DEP)
$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
else
$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_DEP)
$(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.16 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.16 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.16
$(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so
endif
@ -1810,17 +1811,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/transport/chttp2/transport/writing.cc \
src/core/ext/transport/inproc/inproc_plugin.cc \
src/core/ext/transport/inproc/inproc_transport.cc \
src/core/ext/upb-generated/google/api/annotations.upb.c \
src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c \
src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c \
src/core/ext/upb-generated/google/api/http.upb.c \
src/core/ext/upb-generated/google/protobuf/any.upb.c \
src/core/ext/upb-generated/google/protobuf/duration.upb.c \
src/core/ext/upb-generated/google/protobuf/empty.upb.c \
src/core/ext/upb-generated/google/protobuf/struct.upb.c \
src/core/ext/upb-generated/google/protobuf/timestamp.upb.c \
src/core/ext/upb-generated/google/protobuf/wrappers.upb.c \
src/core/ext/upb-generated/google/rpc/status.upb.c \
src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c \
src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c \
src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c \
@ -2027,18 +2017,18 @@ endif
ifeq ($(SYSTEM),MINGW32)
$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
else
$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
$(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_UNSECURE_OBJS) $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.16 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.16 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS)
$(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.16
$(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so
endif

@ -275,6 +275,17 @@ libs:
- include/grpc/support/thd_id.h
- include/grpc/support/time.h
headers:
- src/core/ext/upb-generated/google/api/annotations.upb.h
- src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h
- src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h
- src/core/ext/upb-generated/google/api/http.upb.h
- src/core/ext/upb-generated/google/protobuf/any.upb.h
- src/core/ext/upb-generated/google/protobuf/duration.upb.h
- src/core/ext/upb-generated/google/protobuf/empty.upb.h
- src/core/ext/upb-generated/google/protobuf/struct.upb.h
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.h
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.h
- src/core/ext/upb-generated/google/rpc/status.upb.h
- src/core/lib/gpr/alloc.h
- src/core/lib/gpr/arena.h
- src/core/lib/gpr/env.h
@ -292,6 +303,7 @@ libs:
- src/core/lib/gpr/useful.h
- src/core/lib/gprpp/arena.h
- src/core/lib/gprpp/atomic.h
- src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/examine_stack.h
- src/core/lib/gprpp/fork.h
- src/core/lib/gprpp/global_config.h
@ -303,11 +315,23 @@ libs:
- src/core/lib/gprpp/memory.h
- src/core/lib/gprpp/mpscq.h
- src/core/lib/gprpp/stat.h
- src/core/lib/gprpp/status_helper.h
- src/core/lib/gprpp/sync.h
- src/core/lib/gprpp/thd.h
- src/core/lib/gprpp/time_util.h
- src/core/lib/profiling/timers.h
src:
- src/core/ext/upb-generated/google/api/annotations.upb.c
- src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c
- src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c
- src/core/ext/upb-generated/google/api/http.upb.c
- src/core/ext/upb-generated/google/protobuf/any.upb.c
- src/core/ext/upb-generated/google/protobuf/duration.upb.c
- src/core/ext/upb-generated/google/protobuf/empty.upb.c
- src/core/ext/upb-generated/google/protobuf/struct.upb.c
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
- src/core/ext/upb-generated/google/rpc/status.upb.c
- src/core/lib/gpr/alloc.cc
- src/core/lib/gpr/atm.cc
- src/core/lib/gpr/cpu_iphone.cc
@ -348,6 +372,7 @@ libs:
- src/core/lib/gprpp/mpscq.cc
- src/core/lib/gprpp/stat_posix.cc
- src/core/lib/gprpp/stat_windows.cc
- src/core/lib/gprpp/status_helper.cc
- src/core/lib/gprpp/thd_posix.cc
- src/core/lib/gprpp/thd_windows.cc
- src/core/lib/gprpp/time_util.cc
@ -362,6 +387,7 @@ libs:
- absl/synchronization:synchronization
- absl/time:time
- absl/types:optional
- upb
- name: grpc
build: all
language: c
@ -540,17 +566,6 @@ libs:
- src/core/ext/upb-generated/envoy/type/v3/percent.upb.h
- src/core/ext/upb-generated/envoy/type/v3/range.upb.h
- src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h
- src/core/ext/upb-generated/google/api/annotations.upb.h
- src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h
- src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h
- src/core/ext/upb-generated/google/api/http.upb.h
- src/core/ext/upb-generated/google/protobuf/any.upb.h
- src/core/ext/upb-generated/google/protobuf/duration.upb.h
- src/core/ext/upb-generated/google/protobuf/empty.upb.h
- src/core/ext/upb-generated/google/protobuf/struct.upb.h
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.h
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.h
- src/core/ext/upb-generated/google/rpc/status.upb.h
- src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h
- src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h
- src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h
@ -696,7 +711,6 @@ libs:
- src/core/lib/debug/stats_data.h
- src/core/lib/debug/trace.h
- src/core/lib/gprpp/atomic.h
- src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/dual_ref_counted.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@ -1067,17 +1081,6 @@ libs:
- src/core/ext/upb-generated/envoy/type/v3/percent.upb.c
- src/core/ext/upb-generated/envoy/type/v3/range.upb.c
- src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c
- src/core/ext/upb-generated/google/api/annotations.upb.c
- src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c
- src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c
- src/core/ext/upb-generated/google/api/http.upb.c
- src/core/ext/upb-generated/google/protobuf/any.upb.c
- src/core/ext/upb-generated/google/protobuf/duration.upb.c
- src/core/ext/upb-generated/google/protobuf/empty.upb.c
- src/core/ext/upb-generated/google/protobuf/struct.upb.c
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
- src/core/ext/upb-generated/google/rpc/status.upb.c
- src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c
- src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c
- src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c
@ -1453,7 +1456,6 @@ libs:
- gpr
- libssl
- address_sorting
- upb
baselib: true
generate_plugin_registry: true
- name: grpc_csharp_ext
@ -1678,17 +1680,6 @@ libs:
- src/core/ext/transport/chttp2/transport/stream_map.h
- src/core/ext/transport/chttp2/transport/varint.h
- src/core/ext/transport/inproc/inproc_transport.h
- src/core/ext/upb-generated/google/api/annotations.upb.h
- src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h
- src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h
- src/core/ext/upb-generated/google/api/http.upb.h
- src/core/ext/upb-generated/google/protobuf/any.upb.h
- src/core/ext/upb-generated/google/protobuf/duration.upb.h
- src/core/ext/upb-generated/google/protobuf/empty.upb.h
- src/core/ext/upb-generated/google/protobuf/struct.upb.h
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.h
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.h
- src/core/ext/upb-generated/google/rpc/status.upb.h
- src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h
- src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h
- src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h
@ -1718,7 +1709,6 @@ libs:
- src/core/lib/debug/stats_data.h
- src/core/lib/debug/trace.h
- src/core/lib/gprpp/atomic.h
- src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/dual_ref_counted.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@ -1940,17 +1930,6 @@ libs:
- src/core/ext/transport/chttp2/transport/writing.cc
- src/core/ext/transport/inproc/inproc_plugin.cc
- src/core/ext/transport/inproc/inproc_transport.cc
- src/core/ext/upb-generated/google/api/annotations.upb.c
- src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c
- src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c
- src/core/ext/upb-generated/google/api/http.upb.c
- src/core/ext/upb-generated/google/protobuf/any.upb.c
- src/core/ext/upb-generated/google/protobuf/duration.upb.c
- src/core/ext/upb-generated/google/protobuf/empty.upb.c
- src/core/ext/upb-generated/google/protobuf/struct.upb.c
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
- src/core/ext/upb-generated/google/rpc/status.upb.c
- src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c
- src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c
- src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c
@ -2128,7 +2107,6 @@ libs:
- absl/status:statusor
- gpr
- address_sorting
- upb
baselib: true
generate_plugin_registry: true
- name: benchmark_helpers
@ -6282,6 +6260,16 @@ targets:
deps:
- grpc_test_util
uses_polling: false
- name: status_helper_test
gtest: true
build: test
language: c++
headers: []
src:
- test/core/gprpp/status_helper_test.cc
deps:
- grpc_test_util
uses_polling: false
- name: status_metadata_test
gtest: true
build: test

@ -414,6 +414,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/gprpp/mpscq.cc \
src/core/lib/gprpp/stat_posix.cc \
src/core/lib/gprpp/stat_windows.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/thd_posix.cc \
src/core/lib/gprpp/thd_windows.cc \
src/core/lib/gprpp/time_util.cc \

@ -380,6 +380,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\gprpp\\mpscq.cc " +
"src\\core\\lib\\gprpp\\stat_posix.cc " +
"src\\core\\lib\\gprpp\\stat_windows.cc " +
"src\\core\\lib\\gprpp\\status_helper.cc " +
"src\\core\\lib\\gprpp\\thd_posix.cc " +
"src\\core\\lib\\gprpp\\thd_windows.cc " +
"src\\core\\lib\\gprpp\\time_util.cc " +

@ -545,6 +545,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h',
'src/core/lib/gprpp/time_util.h',
@ -1185,6 +1186,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h',
'src/core/lib/gprpp/time_util.h',

@ -905,6 +905,8 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/stat_posix.cc',
'src/core/lib/gprpp/stat_windows.cc',
'src/core/lib/gprpp/status_helper.cc',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h',
'src/core/lib/gprpp/thd_posix.cc',
@ -1744,6 +1746,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h',
'src/core/lib/gprpp/time_util.h',

@ -827,6 +827,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/stat.h )
s.files += %w( src/core/lib/gprpp/stat_posix.cc )
s.files += %w( src/core/lib/gprpp/stat_windows.cc )
s.files += %w( src/core/lib/gprpp/status_helper.cc )
s.files += %w( src/core/lib/gprpp/status_helper.h )
s.files += %w( src/core/lib/gprpp/sync.h )
s.files += %w( src/core/lib/gprpp/thd.h )
s.files += %w( src/core/lib/gprpp/thd_posix.cc )

@ -388,8 +388,20 @@
'absl/synchronization:synchronization',
'absl/time:time',
'absl/types:optional',
'upb',
],
'sources': [
'src/core/ext/upb-generated/google/api/annotations.upb.c',
'src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c',
'src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c',
'src/core/ext/upb-generated/google/api/http.upb.c',
'src/core/ext/upb-generated/google/protobuf/any.upb.c',
'src/core/ext/upb-generated/google/protobuf/duration.upb.c',
'src/core/ext/upb-generated/google/protobuf/empty.upb.c',
'src/core/ext/upb-generated/google/protobuf/struct.upb.c',
'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c',
'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c',
'src/core/ext/upb-generated/google/rpc/status.upb.c',
'src/core/lib/gpr/alloc.cc',
'src/core/lib/gpr/atm.cc',
'src/core/lib/gpr/cpu_iphone.cc',
@ -430,6 +442,7 @@
'src/core/lib/gprpp/mpscq.cc',
'src/core/lib/gprpp/stat_posix.cc',
'src/core/lib/gprpp/stat_windows.cc',
'src/core/lib/gprpp/status_helper.cc',
'src/core/lib/gprpp/thd_posix.cc',
'src/core/lib/gprpp/thd_windows.cc',
'src/core/lib/gprpp/time_util.cc',
@ -447,7 +460,6 @@
'absl/status:statusor',
'gpr',
'address_sorting',
'upb',
],
'sources': [
'src/core/ext/filters/census/grpc_context.cc',
@ -628,17 +640,6 @@
'src/core/ext/upb-generated/envoy/type/v3/percent.upb.c',
'src/core/ext/upb-generated/envoy/type/v3/range.upb.c',
'src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c',
'src/core/ext/upb-generated/google/api/annotations.upb.c',
'src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c',
'src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c',
'src/core/ext/upb-generated/google/api/http.upb.c',
'src/core/ext/upb-generated/google/protobuf/any.upb.c',
'src/core/ext/upb-generated/google/protobuf/duration.upb.c',
'src/core/ext/upb-generated/google/protobuf/empty.upb.c',
'src/core/ext/upb-generated/google/protobuf/struct.upb.c',
'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c',
'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c',
'src/core/ext/upb-generated/google/rpc/status.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c',
@ -1094,7 +1095,6 @@
'absl/status:statusor',
'gpr',
'address_sorting',
'upb',
],
'sources': [
'src/core/ext/filters/census/grpc_context.cc',
@ -1198,17 +1198,6 @@
'src/core/ext/transport/chttp2/transport/writing.cc',
'src/core/ext/transport/inproc/inproc_plugin.cc',
'src/core/ext/transport/inproc/inproc_transport.cc',
'src/core/ext/upb-generated/google/api/annotations.upb.c',
'src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c',
'src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c',
'src/core/ext/upb-generated/google/api/http.upb.c',
'src/core/ext/upb-generated/google/protobuf/any.upb.c',
'src/core/ext/upb-generated/google/protobuf/duration.upb.c',
'src/core/ext/upb-generated/google/protobuf/empty.upb.c',
'src/core/ext/upb-generated/google/protobuf/struct.upb.c',
'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c',
'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c',
'src/core/ext/upb-generated/google/rpc/status.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c',
'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c',

@ -807,6 +807,8 @@
<file baseinstalldir="/" name="src/core/lib/gprpp/stat.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/stat_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/stat_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/status_helper.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/status_helper.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/sync.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/thd.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/thd_posix.cc" role="src" />

@ -0,0 +1,320 @@
//
//
// Copyright 2021 the 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 <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/time_util.h"
#include <grpc/support/log.h>
#include "absl/strings/cord.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "google/protobuf/any.upb.h"
#include "google/rpc/status.upb.h"
#include "upb/upb.hpp"
namespace grpc_core {
namespace {
#define TYPE_URL_PREFIX "type.googleapis.com/grpc.status."
#define TYPE_URL(name) (TYPE_URL_PREFIX name)
const absl::string_view kTypeUrlPrefix = TYPE_URL_PREFIX;
const absl::string_view kChildrenPropertyUrl = TYPE_URL("children");
const char* GetStatusIntPropertyUrl(StatusIntProperty key) {
switch (key) {
case StatusIntProperty::ERRNO:
return TYPE_URL("errno");
case StatusIntProperty::FILE_LINE:
return TYPE_URL("file_line");
case StatusIntProperty::STREAM_ID:
return TYPE_URL("stream_id");
case StatusIntProperty::GRPC_STATUS:
return TYPE_URL("grpc_status");
case StatusIntProperty::OFFSET:
return TYPE_URL("offset");
case StatusIntProperty::INDEX:
return TYPE_URL("index");
case StatusIntProperty::SIZE:
return TYPE_URL("size");
case StatusIntProperty::HTTP2_ERROR:
return TYPE_URL("http2_error");
case StatusIntProperty::TSI_CODE:
return TYPE_URL("tsi_code");
case StatusIntProperty::FD:
return TYPE_URL("fd");
case StatusIntProperty::WSA_ERROR:
return TYPE_URL("wsa_error");
case StatusIntProperty::HTTP_STATUS:
return TYPE_URL("http_status");
case StatusIntProperty::OCCURRED_DURING_WRITE:
return TYPE_URL("occurred_during_write");
case StatusIntProperty::CHANNEL_CONNECTIVITY_STATE:
return TYPE_URL("channel_connectivity_state");
case StatusIntProperty::LB_POLICY_DROP:
return TYPE_URL("lb_policy_drop");
}
GPR_UNREACHABLE_CODE(return "unknown");
}
const char* GetStatusStrPropertyUrl(StatusStrProperty key) {
switch (key) {
case StatusStrProperty::KEY:
return TYPE_URL("key");
case StatusStrProperty::VALUE:
return TYPE_URL("value");
case StatusStrProperty::DESCRIPTION:
return TYPE_URL("description");
case StatusStrProperty::OS_ERROR:
return TYPE_URL("os_error");
case StatusStrProperty::TARGET_ADDRESS:
return TYPE_URL("target_address");
case StatusStrProperty::SYSCALL:
return TYPE_URL("syscall");
case StatusStrProperty::FILE:
return TYPE_URL("file");
case StatusStrProperty::GRPC_MESSAGE:
return TYPE_URL("grpc_message");
case StatusStrProperty::RAW_BYTES:
return TYPE_URL("raw_bytes");
case StatusStrProperty::TSI_ERROR:
return TYPE_URL("tsi_error");
case StatusStrProperty::FILENAME:
return TYPE_URL("filename");
case StatusStrProperty::CREATED_TIME:
return TYPE_URL("created_time");
}
GPR_UNREACHABLE_CODE(return "unknown");
}
void EncodeUInt32ToBytes(uint32_t v, char* buf) {
buf[0] = v & 0xFF;
buf[1] = (v >> 8) & 0xFF;
buf[2] = (v >> 16) & 0xFF;
buf[3] = (v >> 24) & 0xFF;
}
uint32_t DecodeUInt32FromBytes(const char* buf) {
return buf[0] | (uint32_t(buf[1]) << 8) | (uint32_t(buf[2]) << 16) |
(uint32_t(buf[3]) << 24);
}
std::vector<absl::Status> ParseChildren(absl::Cord children) {
std::vector<absl::Status> result;
upb::Arena arena;
// Cord is flattened to iterate the buffer easily at the cost of memory copy.
// TODO(veblush): Optimize this once CordReader is introduced.
absl::string_view buf = children.Flatten();
size_t cur = 0;
while (buf.size() - cur >= sizeof(uint32_t)) {
size_t msg_size = DecodeUInt32FromBytes(buf.data() + cur);
cur += sizeof(uint32_t);
GPR_ASSERT(buf.size() - cur >= msg_size);
google_rpc_Status* msg =
google_rpc_Status_parse(buf.data() + cur, msg_size, arena.ptr());
cur += msg_size;
result.push_back(internal::StatusFromProto(msg));
}
return result;
}
} // namespace
absl::Status StatusCreate(absl::StatusCode code, absl::string_view msg,
const DebugLocation& location,
std::initializer_list<absl::Status> children) {
absl::Status s(code, msg);
if (location.file() != nullptr) {
StatusSetStr(&s, StatusStrProperty::FILE, location.file());
}
if (location.line() != -1) {
StatusSetInt(&s, StatusIntProperty::FILE_LINE, location.line());
}
absl::Time now = grpc_core::ToAbslTime(gpr_now(GPR_CLOCK_REALTIME));
StatusSetStr(&s, StatusStrProperty::CREATED_TIME, absl::FormatTime(now));
for (const absl::Status& child : children) {
if (!child.ok()) {
StatusAddChild(&s, child);
}
}
return s;
}
void StatusSetInt(absl::Status* status, StatusIntProperty key, intptr_t value) {
status->SetPayload(GetStatusIntPropertyUrl(key),
absl::Cord(std::to_string(value)));
}
absl::optional<intptr_t> StatusGetInt(const absl::Status& status,
StatusIntProperty key) {
absl::optional<absl::Cord> p =
status.GetPayload(GetStatusIntPropertyUrl(key));
if (p.has_value()) {
absl::optional<absl::string_view> sv = p->TryFlat();
intptr_t value;
if (sv.has_value()) {
if (absl::SimpleAtoi(*sv, &value)) {
return value;
}
} else {
if (absl::SimpleAtoi(std::string(*p), &value)) {
return value;
}
}
}
return {};
}
void StatusSetStr(absl::Status* status, StatusStrProperty key,
absl::string_view value) {
status->SetPayload(GetStatusStrPropertyUrl(key), absl::Cord(value));
}
absl::optional<std::string> StatusGetStr(const absl::Status& status,
StatusStrProperty key) {
absl::optional<absl::Cord> p =
status.GetPayload(GetStatusStrPropertyUrl(key));
if (p.has_value()) {
return std::string(*p);
}
return {};
}
void StatusAddChild(absl::Status* status, absl::Status child) {
upb::Arena arena;
// Serialize msg to buf
google_rpc_Status* msg = internal::StatusToProto(child, arena.ptr());
size_t buf_len = 0;
char* buf = google_rpc_Status_serialize(msg, arena.ptr(), &buf_len);
// Append (msg-length and msg) to children payload
absl::optional<absl::Cord> old_children =
status->GetPayload(kChildrenPropertyUrl);
absl::Cord children;
if (old_children.has_value()) {
children = *old_children;
}
char head_buf[sizeof(uint32_t)];
EncodeUInt32ToBytes(buf_len, head_buf);
children.Append(absl::string_view(head_buf, sizeof(uint32_t)));
children.Append(absl::string_view(buf, buf_len));
status->SetPayload(kChildrenPropertyUrl, std::move(children));
}
std::vector<absl::Status> StatusGetChildren(absl::Status status) {
absl::optional<absl::Cord> children = status.GetPayload(kChildrenPropertyUrl);
return children.has_value() ? ParseChildren(*children)
: std::vector<absl::Status>();
}
std::string StatusToString(const absl::Status& status) {
if (status.ok()) {
return "OK";
}
std::string head;
absl::StrAppend(&head, absl::StatusCodeToString(status.code()));
if (!status.message().empty()) {
absl::StrAppend(&head, ":", status.message());
}
std::vector<std::string> kvs;
absl::optional<absl::Cord> children;
status.ForEachPayload(
[&](absl::string_view type_url, const absl::Cord& payload) {
if (type_url.substr(0, kTypeUrlPrefix.size()) == kTypeUrlPrefix) {
type_url.remove_prefix(kTypeUrlPrefix.size());
}
if (type_url == kChildrenPropertyUrl.substr(kTypeUrlPrefix.size())) {
children = payload;
} else {
absl::optional<absl::string_view> payload_view = payload.TryFlat();
std::string payload_str = absl::CHexEscape(
payload_view.has_value() ? *payload_view : std::string(payload));
kvs.push_back(absl::StrCat(type_url, ":\"", payload_str, "\""));
}
});
if (children.has_value()) {
std::vector<absl::Status> children_status = ParseChildren(*children);
std::vector<std::string> children_text;
children_text.reserve(children_status.size());
for (const absl::Status& child_status : children_status) {
children_text.push_back(StatusToString(child_status));
}
kvs.push_back(
absl::StrCat("children:[", absl::StrJoin(children_text, ", "), "]"));
}
return kvs.empty() ? head
: absl::StrCat(head, " {", absl::StrJoin(kvs, ", "), "}");
}
namespace internal {
google_rpc_Status* StatusToProto(absl::Status status, upb_arena* arena) {
google_rpc_Status* msg = google_rpc_Status_new(arena);
google_rpc_Status_set_code(msg, int32_t(status.code()));
google_rpc_Status_set_message(
msg, upb_strview_make(status.message().data(), status.message().size()));
status.ForEachPayload([&](absl::string_view type_url,
const absl::Cord& payload) {
google_protobuf_Any* any = google_rpc_Status_add_details(msg, arena);
char* type_url_buf =
reinterpret_cast<char*>(upb_arena_malloc(arena, type_url.size()));
memcpy(type_url_buf, type_url.data(), type_url.size());
google_protobuf_Any_set_type_url(
any, upb_strview_make(type_url_buf, type_url.size()));
absl::optional<absl::string_view> v_view = payload.TryFlat();
if (v_view.has_value()) {
google_protobuf_Any_set_value(
any, upb_strview_make(v_view->data(), v_view->size()));
} else {
char* buf =
reinterpret_cast<char*>(upb_arena_malloc(arena, payload.size()));
char* cur = buf;
for (absl::string_view chunk : payload.Chunks()) {
memcpy(cur, chunk.data(), chunk.size());
cur += chunk.size();
}
google_protobuf_Any_set_value(any, upb_strview_make(buf, payload.size()));
}
});
return msg;
}
absl::Status StatusFromProto(google_rpc_Status* msg) {
int32_t code = google_rpc_Status_code(msg);
upb_strview message = google_rpc_Status_message(msg);
absl::Status status(static_cast<absl::StatusCode>(code),
absl::string_view(message.data, message.size));
size_t detail_len;
const google_protobuf_Any* const* details =
google_rpc_Status_details(msg, &detail_len);
for (size_t i = 0; i < detail_len; i++) {
upb_strview type_url = google_protobuf_Any_type_url(details[i]);
upb_strview value = google_protobuf_Any_value(details[i]);
status.SetPayload(absl::string_view(type_url.data, type_url.size),
absl::Cord(absl::string_view(value.data, value.size)));
}
return status;
}
} // namespace internal
} // namespace grpc_core

@ -0,0 +1,147 @@
//
//
// Copyright 2021 the 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_CORE_LIB_GPRPP_STATUS_HELPER_H
#define GRPC_CORE_LIB_GPRPP_STATUS_HELPER_H
#include <grpc/support/port_platform.h>
#include "absl/status/status.h"
#include "google/rpc/status.upb.h"
#include "src/core/lib/gprpp/debug_location.h"
namespace grpc_core {
/// This enum should have the same value of grpc_error_ints
// TODO(veblush): Use camel-case names once migration to absl::Status is done.
enum class StatusIntProperty {
/// 'errno' from the operating system
ERRNO,
/// __LINE__ from the call site creating the error
FILE_LINE,
/// stream identifier: for errors that are associated with an individual
/// wire stream
STREAM_ID,
/// grpc status code representing this error
// TODO(veblush): Remove this after grpc_error is replaced with absl::Status
GRPC_STATUS,
/// offset into some binary blob (usually represented by
/// RAW_BYTES) where the error occurred
OFFSET,
/// context sensitive index associated with the error
INDEX,
/// context sensitive size associated with the error
SIZE,
/// http2 error code associated with the error (see the HTTP2 RFC)
HTTP2_ERROR,
/// TSI status code associated with the error
TSI_CODE,
/// WSAGetLastError() reported when this error occurred
WSA_ERROR,
/// File descriptor associated with this error
FD,
/// HTTP status (i.e. 404)
HTTP_STATUS,
/// chttp2: did the error occur while a write was in progress
OCCURRED_DURING_WRITE,
/// channel connectivity state associated with the error
CHANNEL_CONNECTIVITY_STATE,
/// LB policy drop
LB_POLICY_DROP,
};
/// This enum should have the same value of grpc_error_strs
// TODO(veblush): Use camel-case names once migration to absl::Status is done.
enum class StatusStrProperty {
/// top-level textual description of this error
DESCRIPTION,
/// source file in which this error occurred
FILE,
/// operating system description of this error
OS_ERROR,
/// syscall that generated this error
SYSCALL,
/// peer that we were trying to communicate when this error occurred
TARGET_ADDRESS,
/// grpc status message associated with this error
GRPC_MESSAGE,
/// hex dump (or similar) with the data that generated this error
RAW_BYTES,
/// tsi error string associated with this error
TSI_ERROR,
/// filename that we were trying to read/write when this error occurred
FILENAME,
/// key associated with the error
KEY,
/// value associated with the error
VALUE,
/// time string to create the error
CREATED_TIME,
};
/// Creates a status with given additional information
absl::Status StatusCreate(
absl::StatusCode code, absl::string_view msg, const DebugLocation& location,
std::initializer_list<absl::Status> children) GRPC_MUST_USE_RESULT;
/// Sets the int property to the status
void StatusSetInt(absl::Status* status, StatusIntProperty key, intptr_t value);
/// Gets the int property from the status
absl::optional<intptr_t> StatusGetInt(
const absl::Status& status, StatusIntProperty key) GRPC_MUST_USE_RESULT;
/// Sets the str property to the status
void StatusSetStr(absl::Status* status, StatusStrProperty key,
absl::string_view value);
/// Gets the str property from the status
absl::optional<std::string> StatusGetStr(
const absl::Status& status, StatusStrProperty key) GRPC_MUST_USE_RESULT;
/// Adds a child status to status
void StatusAddChild(absl::Status* status, absl::Status child);
/// Returns all children status from a status
std::vector<absl::Status> StatusGetChildren(absl::Status status)
GRPC_MUST_USE_RESULT;
/// Returns a string representation from status
/// Error status will be like
/// STATUS[:MESSAGE] [{PAYLOADS[, children:[CHILDREN-STATUS-LISTS]]}]
/// e.g.
/// CANCELLATION:SampleMessage {errno:'2021', line:'54', children:[ABORTED]}
std::string StatusToString(const absl::Status& status) GRPC_MUST_USE_RESULT;
namespace internal {
/// Builds a upb message, google_rpc_Status from a status
/// This is for internal implementation & test only
google_rpc_Status* StatusToProto(absl::Status status,
upb_arena* arena) GRPC_MUST_USE_RESULT;
/// Build a status from a upb message, google_rpc_Status
/// This is for internal implementation & test only
absl::Status StatusFromProto(google_rpc_Status* msg) GRPC_MUST_USE_RESULT;
} // namespace internal
} // namespace grpc_core
#endif // GRPC_CORE_LIB_GPRPP_STATUS_HELPER_H

@ -61,16 +61,12 @@ static const char* error_int_name(grpc_error_ints key) {
return "http2_error";
case GRPC_ERROR_INT_TSI_CODE:
return "tsi_code";
case GRPC_ERROR_INT_SECURITY_STATUS:
return "security_status";
case GRPC_ERROR_INT_FD:
return "fd";
case GRPC_ERROR_INT_WSA_ERROR:
return "wsa_error";
case GRPC_ERROR_INT_HTTP_STATUS:
return "http_status";
case GRPC_ERROR_INT_LIMIT:
return "limit";
case GRPC_ERROR_INT_OCCURRED_DURING_WRITE:
return "occurred_during_write";
case GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE:
@ -107,8 +103,6 @@ static const char* error_str_name(grpc_error_strs key) {
return "tsi_error";
case GRPC_ERROR_STR_FILENAME:
return "filename";
case GRPC_ERROR_STR_QUEUED_BUFFERS:
return "queued_buffers";
case GRPC_ERROR_STR_MAX:
GPR_UNREACHABLE_CODE(return "unknown");
}

@ -60,16 +60,12 @@ typedef enum {
GRPC_ERROR_INT_HTTP2_ERROR,
/// TSI status code associated with the error
GRPC_ERROR_INT_TSI_CODE,
/// grpc_security_status associated with the error
GRPC_ERROR_INT_SECURITY_STATUS,
/// WSAGetLastError() reported when this error occurred
GRPC_ERROR_INT_WSA_ERROR,
/// File descriptor associated with this error
GRPC_ERROR_INT_FD,
/// HTTP status (i.e. 404)
GRPC_ERROR_INT_HTTP_STATUS,
/// context sensitive limit associated with the error
GRPC_ERROR_INT_LIMIT,
/// chttp2: did the error occur while a write was in progress
GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
/// channel connectivity state associated with the error
@ -100,8 +96,6 @@ typedef enum {
GRPC_ERROR_STR_TSI_ERROR,
/// filename that we were trying to read/write when this error occurred
GRPC_ERROR_STR_FILENAME,
/// which data was queued for writing when the error occurred
GRPC_ERROR_STR_QUEUED_BUFFERS,
/// key associated with the error
GRPC_ERROR_STR_KEY,
/// value associated with the error

@ -389,6 +389,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/gprpp/mpscq.cc',
'src/core/lib/gprpp/stat_posix.cc',
'src/core/lib/gprpp/stat_windows.cc',
'src/core/lib/gprpp/status_helper.cc',
'src/core/lib/gprpp/thd_posix.cc',
'src/core/lib/gprpp/thd_windows.cc',
'src/core/lib/gprpp/time_util.cc',

@ -193,6 +193,20 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "status_helper_test",
srcs = ["status_helper_test.cc"],
external_deps = [
"gtest",
],
language = "C++",
uses_polling = False,
deps = [
"//:gpr",
"//test/core/util:grpc_test_util",
],
)
grpc_cc_test(
name = "time_util_test",
srcs = ["time_util_test.cc"],

@ -0,0 +1,128 @@
//
// Copyright 2021 the 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 "src/core/lib/gprpp/status_helper.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/status/status.h"
#include "google/rpc/status.upb.h"
#include "upb/upb.hpp"
namespace grpc_core {
namespace {
TEST(StatusUtilTest, CreateStatus) {
absl::Status s =
StatusCreate(absl::StatusCode::kUnknown, "Test", DEBUG_LOCATION,
{absl::OkStatus(), absl::CancelledError()});
EXPECT_EQ(absl::StatusCode::kUnknown, s.code());
EXPECT_EQ("Test", s.message());
#ifndef NDEBUG
EXPECT_EQ(true, StatusGetStr(s, StatusStrProperty::FILE).has_value());
EXPECT_EQ(true, StatusGetInt(s, StatusIntProperty::FILE_LINE).has_value());
#endif
EXPECT_EQ(true, StatusGetStr(s, StatusStrProperty::CREATED_TIME).has_value());
EXPECT_THAT(StatusGetChildren(s),
::testing::ElementsAre(absl::CancelledError()));
}
TEST(StatusUtilTest, SetAndGetInt) {
absl::Status s = absl::CancelledError();
StatusSetInt(&s, StatusIntProperty::ERRNO, 2021);
EXPECT_EQ(2021, StatusGetInt(s, StatusIntProperty::ERRNO));
}
TEST(StatusUtilTest, GetIntNotExistent) {
absl::Status s = absl::CancelledError();
EXPECT_EQ(absl::optional<intptr_t>(),
StatusGetInt(s, StatusIntProperty::ERRNO));
}
TEST(StatusUtilTest, SetAndGetStr) {
absl::Status s = absl::CancelledError();
StatusSetStr(&s, StatusStrProperty::OS_ERROR, "value");
EXPECT_EQ("value", StatusGetStr(s, StatusStrProperty::OS_ERROR));
}
TEST(StatusUtilTest, GetStrNotExistent) {
absl::Status s = absl::CancelledError();
EXPECT_EQ(absl::optional<std::string>(),
StatusGetStr(s, StatusStrProperty::OS_ERROR));
}
TEST(StatusUtilTest, AddAndGetChildren) {
absl::Status s = absl::CancelledError();
absl::Status child1 = absl::AbortedError("Message1");
absl::Status child2 = absl::DeadlineExceededError("Message2");
StatusAddChild(&s, child1);
StatusAddChild(&s, child2);
EXPECT_THAT(StatusGetChildren(s), ::testing::ElementsAre(child1, child2));
}
TEST(StatusUtilTest, ToAndFromProto) {
absl::Status s = absl::CancelledError("Message");
StatusSetInt(&s, StatusIntProperty::ERRNO, 2021);
StatusSetStr(&s, StatusStrProperty::OS_ERROR, "value");
upb::Arena arena;
google_rpc_Status* msg = internal::StatusToProto(s, arena.ptr());
absl::Status s2 = internal::StatusFromProto(msg);
EXPECT_EQ(s, s2);
}
TEST(StatusUtilTest, OkToString) {
absl::Status s = absl::OkStatus();
std::string t = StatusToString(s);
EXPECT_EQ("OK", t);
}
TEST(StatusUtilTest, CancelledErrorToString) {
absl::Status s = absl::CancelledError();
std::string t = StatusToString(s);
EXPECT_EQ("CANCELLED", t);
}
TEST(StatusUtilTest, ComplexErrorToString) {
absl::Status s = absl::CancelledError("Message");
StatusSetInt(&s, StatusIntProperty::ERRNO, 2021);
std::string t = StatusToString(s);
EXPECT_EQ("CANCELLED:Message {errno:\"2021\"}", t);
}
TEST(StatusUtilTest, ComplexErrorWithChildrenToString) {
absl::Status s = absl::CancelledError("Message");
StatusSetInt(&s, StatusIntProperty::ERRNO, 2021);
absl::Status s1 = absl::AbortedError("Message1");
StatusAddChild(&s, s1);
absl::Status s2 = absl::AlreadyExistsError("Message2");
StatusSetStr(&s2, StatusStrProperty::OS_ERROR, "value");
StatusAddChild(&s, s2);
std::string t = StatusToString(s);
EXPECT_EQ(
"CANCELLED:Message {errno:\"2021\", children:["
"ABORTED:Message1, ALREADY_EXISTS:Message2 {os_error:\"value\"}]}",
t);
}
} // namespace
} // namespace grpc_core
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}

@ -1759,6 +1759,8 @@ src/core/lib/gprpp/ref_counted_ptr.h \
src/core/lib/gprpp/stat.h \
src/core/lib/gprpp/stat_posix.cc \
src/core/lib/gprpp/stat_windows.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/status_helper.h \
src/core/lib/gprpp/sync.h \
src/core/lib/gprpp/thd.h \
src/core/lib/gprpp/thd_posix.cc \

@ -1598,6 +1598,8 @@ src/core/lib/gprpp/ref_counted_ptr.h \
src/core/lib/gprpp/stat.h \
src/core/lib/gprpp/stat_posix.cc \
src/core/lib/gprpp/stat_windows.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/status_helper.h \
src/core/lib/gprpp/sync.h \
src/core/lib/gprpp/thd.h \
src/core/lib/gprpp/thd_posix.cc \

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

Loading…
Cancel
Save