Merge remote-tracking branch 'upstream/master' into no-sys-time-h

pull/34178/head
alto-ruby 1 year ago
commit 42c5ad0f79
  1. 2
      .bazelversion
  2. 16
      .clang-tidy
  3. 12
      .gitattributes
  4. 2
      .github/CODEOWNERS
  5. 6
      .github/labeler.yml
  6. 3
      .github/workflows/pr-auto-fix.yaml
  7. 32
      .github/workflows/pr-auto-tag-and-check-title.yaml
  8. 19
      .github/workflows/pr-auto-tag.yaml
  9. 1
      .github/workflows/psm-interop.yaml
  10. 2
      .gitignore
  11. 167
      BUILD
  12. 2906
      CMakeLists.txt
  13. 1
      MAINTAINERS.md
  14. 1522
      Makefile
  15. 3
      OWNERS
  16. 1623
      Package.swift
  17. 24
      Rakefile
  18. 14
      WORKSPACE
  19. 2
      _metadata.py
  20. 5
      bazel/OWNERS
  21. 5
      bazel/_gevent_test_main.py
  22. 180
      bazel/experiments.bzl
  23. 2
      bazel/googleapis.BUILD
  24. 20
      bazel/grpc_build_system.bzl
  25. 102
      bazel/grpc_deps.bzl
  26. 3
      bazel/grpc_extra_deps.bzl
  27. 3
      bazel/supported_versions.txt
  28. 7
      bazel/test_experiments.bzl
  29. 14
      bazel/update_mirror.sh
  30. 4172
      build_autogenerated.yaml
  31. 2
      build_config.rb
  32. 15
      build_handwritten.yaml
  33. 3
      cmake/OWNERS
  34. 2
      cmake/protobuf.cmake
  35. 2
      cmake/upb.cmake
  36. 876
      config.m4
  37. 1146
      config.w32
  38. 11
      doc/bazel_support.md
  39. 31
      doc/core/default_http_proxy_mapper.md
  40. 1
      doc/environment_variables.md
  41. 4
      doc/g_stands_for.md
  42. 16
      doc/grpc_xds_features.md
  43. 2
      doc/python/sphinx/conf.py
  44. 7
      doc/python/sphinx/glossary.rst
  45. 12
      doc/service_config.md
  46. 6
      doc/statuscodes.md
  47. 2
      doc/xds-test-descriptions.md
  48. 39
      examples/cpp/cancellation/BUILD
  49. 71
      examples/cpp/cancellation/CMakeLists.txt
  50. 37
      examples/cpp/cancellation/README.md
  51. 119
      examples/cpp/cancellation/client.cc
  52. 104
      examples/cpp/cancellation/server.cc
  53. 1
      examples/cpp/cmake/common.cmake
  54. 47
      examples/cpp/csm/BUILD
  55. 39
      examples/cpp/csm/Dockerfile.client
  56. 39
      examples/cpp/csm/Dockerfile.server
  57. 11
      examples/cpp/csm/README.md
  58. 200
      examples/cpp/csm/csm_greeter_client.cc
  59. 126
      examples/cpp/csm/csm_greeter_server.cc
  60. 42
      examples/cpp/debugging/BUILD
  61. 132
      examples/cpp/debugging/README.md
  62. 92
      examples/cpp/debugging/crashing_greeter_client.cc
  63. 86
      examples/cpp/debugging/greeter_callback_server_admin.cc
  64. 29
      examples/cpp/orca/BUILD
  65. 46
      examples/cpp/orca/README.md
  66. 101
      examples/cpp/orca/orca_server.cc
  67. 27
      examples/cpp/wait_for_ready/BUILD
  68. 70
      examples/cpp/wait_for_ready/CMakeLists.txt
  69. 32
      examples/cpp/wait_for_ready/README.md
  70. 107
      examples/cpp/wait_for_ready/greeter_callback_client.cc
  71. 0
      examples/objective_c/auth_sample/AuthSample.xcodeproj/project.pbxproj
  72. 0
      examples/objective_c/auth_sample/AuthSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  73. 0
      examples/objective_c/auth_sample/AuthSample.xcodeproj/xcshareddata/xcschemes/AuthSample.xcscheme
  74. 0
      examples/objective_c/auth_sample/AuthTestService.podspec
  75. 0
      examples/objective_c/auth_sample/MakeRPCViewController.h
  76. 0
      examples/objective_c/auth_sample/MakeRPCViewController.m
  77. 0
      examples/objective_c/auth_sample/Misc/AppDelegate.h
  78. 0
      examples/objective_c/auth_sample/Misc/AppDelegate.m
  79. 0
      examples/objective_c/auth_sample/Misc/Base.lproj/Main.storyboard
  80. 0
      examples/objective_c/auth_sample/Misc/GoogleService-Info.plist
  81. 0
      examples/objective_c/auth_sample/Misc/Images.xcassets/AppIcon.appiconset/Contents.json
  82. 0
      examples/objective_c/auth_sample/Misc/Images.xcassets/first.imageset/Contents.json
  83. 0
      examples/objective_c/auth_sample/Misc/Images.xcassets/first.imageset/first.pdf
  84. 0
      examples/objective_c/auth_sample/Misc/Images.xcassets/second.imageset/Contents.json
  85. 0
      examples/objective_c/auth_sample/Misc/Images.xcassets/second.imageset/second.pdf
  86. 0
      examples/objective_c/auth_sample/Misc/Info.plist
  87. 0
      examples/objective_c/auth_sample/Misc/main.m
  88. 0
      examples/objective_c/auth_sample/Podfile
  89. 0
      examples/objective_c/auth_sample/README.md
  90. 0
      examples/objective_c/auth_sample/SelectUserViewController.h
  91. 0
      examples/objective_c/auth_sample/SelectUserViewController.m
  92. 0
      examples/objective_c/helloworld/HelloWorld.podspec
  93. 0
      examples/objective_c/helloworld/HelloWorld.xcodeproj/project.pbxproj
  94. 0
      examples/objective_c/helloworld/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  95. 0
      examples/objective_c/helloworld/HelloWorld.xcodeproj/xcshareddata/xcschemes/HelloWorld.xcscheme
  96. 0
      examples/objective_c/helloworld/HelloWorld/AppDelegate.h
  97. 0
      examples/objective_c/helloworld/HelloWorld/AppDelegate.m
  98. 0
      examples/objective_c/helloworld/HelloWorld/Base.lproj/Main.storyboard
  99. 0
      examples/objective_c/helloworld/HelloWorld/Images.xcassets/AppIcon.appiconset/Contents.json
  100. 0
      examples/objective_c/helloworld/HelloWorld/Info.plist
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1 +1 @@
6.3.2
6.4.0

@ -1,15 +1,24 @@
---
# Note on checks are disabled on purpose
#
# - abseil-cleanup-ctad
# Requires C++17 and higher.
#
# - abseil-no-namespace
# https://bugs.llvm.org/show_bug.cgi?id=47947
#
# - bugprone-exception-escape
# https://github.com/llvm/llvm-project/issues/54668 (seems to be fixed in LLVM17)
#
# - bugprone-reserved-identifier
# Some macros need to be defined for portability purpose; e.g. _BSD_SOURCE.
#
# - modernize-redundant-void-arg
# Some source should be strictly C99 and func(void) should be used.
#
# - google-readability-casting
# https://github.com/llvm/llvm-project/issues/57959
#
# Note on checks which will be enabled in future. These are good to have but
# it's not activated yet due to the existing issues with the checks.
# Once those issues are clear, these checks can be enabled later.
@ -48,14 +57,17 @@
# - readability-else-after-return
# - readability-implicit-bool-conversion
# - readability-redundant-declaration
# - readability-redundant-string-cstr
#
Checks: '-*,
abseil-*,
-abseil-cleanup-ctad,
-abseil-no-namespace,
bugprone-*,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-infinite-loop,
-bugprone-narrowing-conversions,
@ -66,6 +78,7 @@ Checks: '-*,
-bugprone-too-small-loop-variable,
-bugprone-unchecked-optional-access,
google-*,
-google-readability-casting,
-google-runtime-int,
-google-runtime-references,
performance-*,
@ -73,6 +86,7 @@ Checks: '-*,
-performance-no-int-to-ptr,
-performance-unnecessary-copy-initialization,
-performance-unnecessary-value-param,
clang-diagnostic-deprecated-declarations,
clang-diagnostic-deprecated-register,
clang-diagnostic-expansion-to-defined,
clang-diagnostic-ignored-attributes,
@ -120,7 +134,7 @@ Checks: '-*,
readability-redundant-control-flow,
readability-redundant-function-ptr-dereference,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
-readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-static-definition-in-anonymous-namespace,

12
.gitattributes vendored

@ -1,5 +1,5 @@
src/core/ext/upb-generated/** linguist-generated=true
src/core/ext/upbdefs-generated/** linguist-generated=true
src/core/ext/upb-gen/** linguist-generated=true
src/core/ext/upbdefs-gen/** linguist-generated=true
Makefile linguist-generated=true
BUILD.gn linguist-generated=true
CMakeLists.txt linguist-generated=true
@ -31,9 +31,9 @@ tools/run_tests/tests.json linguist-generated=true
tools/run_tests/generated/tests.json linguist-generated=true
tools/run_tests/generated/sources_and_headers.json linguist-generated=true
src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h linguist-generated=true
src/core/debug/stats_data.h linguist-generated=true
src/core/debug/stats_data.cc linguist-generated=true
src/core/experiments/experiments.h linguist-generated=true
src/core/experiments/experiments.cc linguist-generated=true
src/core/lib/debug/stats_data.h linguist-generated=true
src/core/lib/debug/stats_data.cc linguist-generated=true
src/core/lib/experiments/experiments.h linguist-generated=true
src/core/lib/experiments/experiments.cc linguist-generated=true
bazel/experiments.bzl linguist-generated=true
test/cpp/microbenchmarks/huffman_geometries/** linguist-generated=true

@ -5,7 +5,9 @@
/bazel/** @jtattermusch @veblush @gnossen
/cmake/** @jtattermusch @apolcyn
/src/core/ext/filters/client_channel/** @markdroth
/src/core/ext/transport/chttp2/transport/** @ctiller
/src/core/ext/xds/** @markdroth
/src/core/lib/resolver/** @markdroth
/src/core/lib/service_config/** @markdroth
/tools/dockerfile/** @jtattermusch @apolcyn
/tools/run_tests/xds_k8s_test_driver/** @sergiitk @XuanWang-Amos @gnossen

@ -52,9 +52,3 @@ lang/ruby:
"lang/C#":
- src/compiler/csharp*
- src/csharp/**
"disposition/Needs Internal Changes":
- src/core/lib/event_engine/windows/**
- src/core/lib/gpr/windows/**
- src/core/lib/gprpp/windows/**
- test/core/event_engine/windows/**

@ -48,8 +48,9 @@ jobs:
with:
script: |
// If you'd like not to run this code on your commits, add your github user id here:
NO_AUTOFIX_USERS = []
NO_AUTOFIX_USERS = ["copybara-service[bot]"]
const { owner, repo } = context.repo
console.log("Actor: " + context.actor);
if (NO_AUTOFIX_USERS.includes(context.actor)) {
console.log('Cancelling');
const run_id = "${{ github.run_id }}";

@ -1,32 +0,0 @@
name: PR Title Check & Tag
on:
pull_request_target:
types: [opened, reopened, synchronize, edited]
permissions:
contents: read # to determine modified files (actions/labeler)
jobs:
triage:
permissions:
contents: read # to determine modified files (actions/labeler)
pull-requests: write # to add labels to PRs (actions/labeler)
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: ""
title-check:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: thehanimo/pr-title-checker@v1.3.5
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: ".github/pr_title_checker_config.json"

@ -0,0 +1,19 @@
name: PR Auto Tag
on:
pull_request_target:
types: [opened, reopened, synchronize, edited]
permissions:
contents: read # to determine modified files (actions/labeler)
jobs:
triage:
permissions:
contents: read # to determine modified files (actions/labeler)
pull-requests: write # to add labels to PRs (actions/labeler)
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: ""

@ -5,7 +5,6 @@ on:
push:
branches:
- master
- 'v1.*'
permissions:
contents: read

2
.gitignore vendored

@ -17,7 +17,7 @@ cython_debug/
dist/
htmlcov/
py3*/
python_build/
pyb/
python_pylint_venv/
src/python/grpcio_*/=*
src/python/grpcio_*/build/

167
BUILD

@ -30,8 +30,8 @@ licenses(["reciprocal"])
package(
default_visibility = ["//visibility:public"],
features = [
"layering_check",
"-parse_headers",
"layering_check",
],
)
@ -211,11 +211,11 @@ config_setting(
python_config_settings()
# This should be updated along with build_handwritten.yaml
g_stands_for = "generative" # @unused
g_stands_for = "grand" # @unused
core_version = "35.0.0" # @unused
core_version = "37.0.0" # @unused
version = "1.59.0-dev" # @unused
version = "1.61.0-dev" # @unused
GPR_PUBLIC_HDRS = [
"include/grpc/support/alloc.h",
@ -254,6 +254,7 @@ GPR_PUBLIC_HDRS = [
GRPC_PUBLIC_HDRS = [
"include/grpc/grpc_audit_logging.h",
"include/grpc/grpc_crl_provider.h",
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
@ -305,7 +306,6 @@ GRPCXX_SRCS = [
"src/cpp/client/create_channel_posix.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/channel_filter.cc",
"src/cpp/common/completion_queue_cc.cc",
"src/cpp/common/resource_quota_cc.cc",
"src/cpp/common/rpc_method.cc",
@ -332,7 +332,6 @@ GRPCXX_SRCS = [
GRPCXX_HDRS = [
"src/cpp/client/create_channel_internal.h",
"src/cpp/client/client_stats_interceptor.h",
"src/cpp/common/channel_filter.h",
"src/cpp/server/dynamic_thread_pool.h",
"src/cpp/server/external_connection_acceptor_impl.h",
"src/cpp/server/health/default_health_check_service.h",
@ -423,6 +422,7 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/sync.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/security/audit_logging.h",
"include/grpcpp/security/tls_crl_provider.h",
"include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/credentials.h",
@ -1009,6 +1009,7 @@ grpc_cc_library(
"absl/strings",
"absl/types:optional",
"absl/types:span",
"upb_base_lib",
"upb_collections_lib",
"upb_lib",
],
@ -1112,6 +1113,7 @@ grpc_cc_library(
"//src/core:default_event_engine",
"//src/core:iomgr_fwd",
"//src/core:iomgr_port",
"//src/core:notification",
"//src/core:slice",
"//src/core:slice_refcount",
"//src/core:status_helper",
@ -1143,6 +1145,7 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc++_xds_server",
srcs = [
"src/cpp/server/xds_server_builder.cc",
"src/cpp/server/xds_server_credentials.cc",
],
hdrs = [
@ -1154,9 +1157,11 @@ grpc_cc_library(
],
visibility = ["@grpc:xds"],
deps = [
"channel_arg_names",
"gpr",
"grpc",
"grpc++_base",
"//src/core:xds_enabled_server",
],
)
@ -1209,6 +1214,7 @@ grpc_cc_library(
"include/grpcpp/security/alts_util.h",
],
external_deps = [
"upb_base_lib",
"upb_collections_lib",
"upb_lib",
],
@ -1466,7 +1472,6 @@ grpc_cc_library(
"//src/core:lib/transport/status_conversion.h",
"//src/core:lib/transport/timeout_encoding.h",
"//src/core:lib/transport/transport.h",
"//src/core:lib/transport/transport_impl.h",
] +
# TODO(vigneshbabu): remove these
# These headers used to be vended by this target, but they have to be
@ -1488,14 +1493,15 @@ grpc_cc_library(
"absl/container:inlined_vector",
"absl/functional:any_invocable",
"absl/functional:function_ref",
"absl/hash",
"absl/meta:type_traits",
"absl/random",
"absl/status",
"absl/status:statusor",
"absl/strings",
"absl/strings:str_format",
"absl/time",
"absl/types:optional",
"absl/types:variant",
"absl/utility",
"madler_zlib",
],
@ -1527,6 +1533,7 @@ grpc_cc_library(
"ref_counted_ptr",
"sockaddr_utils",
"stats",
"tcp_tracer",
"uri_parser",
"work_serializer",
"//src/core:1999",
@ -1541,6 +1548,7 @@ grpc_cc_library(
"//src/core:channel_args_preconditioning",
"//src/core:channel_fwd",
"//src/core:channel_init",
"//src/core:channel_stack_trace",
"//src/core:channel_stack_type",
"//src/core:chunked_vector",
"//src/core:closure",
@ -1572,7 +1580,6 @@ grpc_cc_library(
"//src/core:latch",
"//src/core:loop",
"//src/core:map",
"//src/core:match",
"//src/core:memory_quota",
"//src/core:metadata_compression_traits",
"//src/core:no_destruct",
@ -1584,6 +1591,7 @@ grpc_cc_library(
"//src/core:posix_event_engine_base_hdrs",
"//src/core:promise_status",
"//src/core:race",
"//src/core:random_early_detection",
"//src/core:ref_counted",
"//src/core:ref_counted_string",
"//src/core:resolved_address",
@ -1596,6 +1604,7 @@ grpc_cc_library(
"//src/core:slice_refcount",
"//src/core:socket_mutator",
"//src/core:stats_data",
"//src/core:status_flag",
"//src/core:status_helper",
"//src/core:strerror",
"//src/core:thread_quota",
@ -1841,6 +1850,7 @@ grpc_cc_library(
visibility = ["@grpc:tsi_interface"],
deps = [
"gpr",
"grpc_public_hdrs",
"grpc_trace",
],
)
@ -1923,6 +1933,7 @@ grpc_cc_library(
"absl/synchronization",
"absl/memory",
"absl/types:optional",
"upb_base_lib",
"upb_lib",
"protobuf_headers",
"absl/container:inlined_vector",
@ -1965,6 +1976,7 @@ grpc_cc_library(
"//src/core:gpr_manual_constructor",
"//src/core:grpc_audit_logging",
"//src/core:grpc_backend_metric_provider",
"//src/core:grpc_crl_provider",
"//src/core:grpc_service_config",
"//src/core:grpc_transport_inproc",
"//src/core:json",
@ -1996,6 +2008,7 @@ grpc_cc_library(
"absl/synchronization",
"absl/types:optional",
"absl/memory",
"upb_base_lib",
"upb_lib",
"absl/strings:str_format",
"protobuf_headers",
@ -2041,6 +2054,7 @@ grpc_cc_library(
"//src/core:resource_quota",
"//src/core:slice",
"//src/core:socket_mutator",
"//src/core:thread_quota",
"//src/core:time",
"//src/core:useful",
],
@ -2107,6 +2121,7 @@ grpc_cc_library(
deps = [
"grpc++",
"grpc++_config_proto",
"//src/proto/grpc/reflection/v1:reflection_proto",
"//src/proto/grpc/reflection/v1alpha:reflection_proto",
],
alwayslink = 1,
@ -2163,6 +2178,7 @@ grpc_cc_library(
"absl/strings",
"absl/time",
"absl/types:optional",
"upb_base_lib",
"upb_lib",
],
language = "c++",
@ -2303,6 +2319,7 @@ grpc_cc_library(
external_deps = [
"absl/base",
"absl/base:core_headers",
"absl/base:endian",
"absl/meta:type_traits",
"absl/status",
"absl/strings",
@ -2336,9 +2353,8 @@ grpc_cc_library(
"src/cpp/ext/filters/census/server_call_tracer.h",
],
external_deps = [
"absl/base",
"absl/base:core_headers",
"absl/meta:type_traits",
"absl/base:endian",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2356,13 +2372,13 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:grpc_opencensus_plugin"],
deps = [
"channel_stack_builder",
"config",
"gpr",
"grpc++_base",
"grpc_base",
"grpc_public_hdrs",
"legacy_context",
"tcp_tracer",
"//src/core:arena",
"//src/core:arena_promise",
"//src/core:channel_args",
@ -2370,6 +2386,7 @@ grpc_cc_library(
"//src/core:channel_stack_type",
"//src/core:context",
"//src/core:error",
"//src/core:logging_filter",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:slice_refcount",
@ -2390,6 +2407,19 @@ grpc_cc_library(
],
)
# This is an EXPERIMENTAL target subject to change.
grpc_cc_library(
name = "grpcpp_csm_observability",
hdrs = [
"include/grpcpp/ext/csm_observability.h",
],
language = "c++",
tags = ["nofixdeps"],
deps = [
"//src/cpp/ext/csm:csm_observability",
],
)
grpc_cc_library(
name = "work_serializer",
srcs = [
@ -2398,14 +2428,22 @@ grpc_cc_library(
hdrs = [
"//src/core:lib/gprpp/work_serializer.h",
],
external_deps = ["absl/base:core_headers"],
external_deps = [
"absl/base:core_headers",
"absl/container:inlined_vector",
],
language = "c++",
visibility = ["@grpc:client_channel"],
deps = [
"debug_location",
"event_engine_base_hdrs",
"exec_ctx",
"gpr",
"grpc_trace",
"orphanable",
"stats",
"//src/core:experiments",
"//src/core:stats_data",
],
)
@ -2469,6 +2507,7 @@ grpc_cc_library(
srcs = [
"//src/core:lib/config/core_configuration.cc",
],
external_deps = ["absl/functional:any_invocable"],
language = "c++",
public_hdrs = [
"//src/core:lib/config/core_configuration.h",
@ -2532,6 +2571,7 @@ grpc_cc_library(
grpc_cc_library(
name = "ref_counted_ptr",
external_deps = ["absl/hash"],
language = "c++",
public_hdrs = ["//src/core:lib/gprpp/ref_counted_ptr.h"],
visibility = ["@grpc:ref_counted_ptr"],
@ -2639,6 +2679,7 @@ grpc_cc_library(
"grpc_trace",
"//src/core:closure",
"//src/core:error",
"//src/core:experiments",
"//src/core:gpr_atm",
"//src/core:gpr_spinlock",
"//src/core:time",
@ -2737,6 +2778,7 @@ grpc_cc_library(
external_deps = [
"absl/strings",
"absl/strings:str_format",
"absl/types:optional",
],
tags = ["nofixdeps"],
visibility = ["@grpc:iomgr_buffer_list"],
@ -2854,7 +2896,6 @@ grpc_cc_library(
"//src/core:channel_args",
"//src/core:channel_fwd",
"//src/core:channel_stack_type",
"//src/core:transport_fwd",
],
)
@ -2893,14 +2934,15 @@ grpc_cc_library(
)
grpc_cc_library(
name = "server_address",
name = "endpoint_addresses",
srcs = [
"//src/core:lib/resolver/server_address.cc",
"//src/core:lib/resolver/endpoint_addresses.cc",
],
hdrs = [
"//src/core:lib/resolver/server_address.h",
"//src/core:lib/resolver/endpoint_addresses.h",
],
external_deps = [
"absl/functional:function_ref",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2908,6 +2950,7 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:client_channel"],
deps = [
"gpr",
"gpr_platform",
"sockaddr_utils",
"//src/core:channel_args",
@ -2916,6 +2959,19 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "server_address",
hdrs = [
"//src/core:lib/resolver/server_address.h",
],
language = "c++",
visibility = ["@grpc:client_channel"],
deps = [
"endpoint_addresses",
"gpr_public_hdrs",
],
)
grpc_cc_library(
name = "grpc_resolver",
srcs = [
@ -2936,6 +2992,7 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:client_channel"],
deps = [
"endpoint_addresses",
"gpr",
"grpc_trace",
"orphanable",
@ -2962,7 +3019,7 @@ grpc_cc_library(
"//src/core:ext/filters/client_channel/config_selector.cc",
"//src/core:ext/filters/client_channel/dynamic_filters.cc",
"//src/core:ext/filters/client_channel/global_subchannel_pool.cc",
"//src/core:ext/filters/client_channel/http_proxy.cc",
"//src/core:ext/filters/client_channel/http_proxy_mapper.cc",
"//src/core:ext/filters/client_channel/lb_policy/child_policy_handler.cc",
"//src/core:ext/filters/client_channel/lb_policy/oob_backend_metric.cc",
"//src/core:ext/filters/client_channel/local_subchannel_pool.cc",
@ -2987,7 +3044,7 @@ grpc_cc_library(
"//src/core:ext/filters/client_channel/connector.h",
"//src/core:ext/filters/client_channel/dynamic_filters.h",
"//src/core:ext/filters/client_channel/global_subchannel_pool.h",
"//src/core:ext/filters/client_channel/http_proxy.h",
"//src/core:ext/filters/client_channel/http_proxy_mapper.h",
"//src/core:ext/filters/client_channel/lb_policy/child_policy_handler.h",
"//src/core:ext/filters/client_channel/lb_policy/oob_backend_metric.h",
"//src/core:ext/filters/client_channel/lb_policy/oob_backend_metric_internal.h",
@ -3013,6 +3070,7 @@ grpc_cc_library(
"absl/strings:cord",
"absl/types:optional",
"absl/types:variant",
"upb_base_lib",
"upb_collections_lib",
"upb_lib",
],
@ -3021,10 +3079,10 @@ grpc_cc_library(
deps = [
"backoff",
"channel_arg_names",
"channel_stack_builder",
"config",
"config_vars",
"debug_location",
"endpoint_addresses",
"exec_ctx",
"gpr",
"grpc_base",
@ -3038,17 +3096,19 @@ grpc_cc_library(
"legacy_context",
"orphanable",
"parse_address",
"promise",
"protobuf_duration_upb",
"ref_counted_ptr",
"server_address",
"sockaddr_utils",
"stats",
"uri_parser",
"work_serializer",
"xds_orca_service_upb",
"xds_orca_upb",
"//src/core:activity",
"//src/core:arena",
"//src/core:arena_promise",
"//src/core:cancel_callback",
"//src/core:channel_args",
"//src/core:channel_fwd",
"//src/core:channel_init",
@ -3060,9 +3120,12 @@ grpc_cc_library(
"//src/core:dual_ref_counted",
"//src/core:env",
"//src/core:error",
"//src/core:experiments",
"//src/core:gpr_atm",
"//src/core:gpr_manual_constructor",
"//src/core:grpc_backend_metric_data",
"//src/core:grpc_deadline_filter",
"//src/core:grpc_message_size_filter",
"//src/core:grpc_service_config",
"//src/core:init_internally",
"//src/core:iomgr_fwd",
@ -3070,15 +3133,20 @@ grpc_cc_library(
"//src/core:json_args",
"//src/core:json_channel_args",
"//src/core:json_object_loader",
"//src/core:latch",
"//src/core:lb_policy",
"//src/core:lb_policy_registry",
"//src/core:map",
"//src/core:memory_quota",
"//src/core:pipe",
"//src/core:poll",
"//src/core:pollset_set",
"//src/core:proxy_mapper",
"//src/core:proxy_mapper_registry",
"//src/core:ref_counted",
"//src/core:resolved_address",
"//src/core:resource_quota",
"//src/core:seq",
"//src/core:service_config_parser",
"//src/core:slice",
"//src/core:slice_buffer",
@ -3087,7 +3155,7 @@ grpc_cc_library(
"//src/core:status_helper",
"//src/core:subchannel_interface",
"//src/core:time",
"//src/core:transport_fwd",
"//src/core:try_seq",
"//src/core:unique_type_name",
"//src/core:useful",
"//src/core:validation_errors",
@ -3111,7 +3179,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/container:flat_hash_set",
"absl/functional:any_invocable",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3127,6 +3195,7 @@ grpc_cc_library(
"config",
"config_vars",
"debug_location",
"endpoint_addresses",
"exec_ctx",
"gpr",
"grpc_base",
@ -3138,7 +3207,6 @@ grpc_cc_library(
"orphanable",
"parse_address",
"ref_counted_ptr",
"server_address",
"sockaddr_utils",
"uri_parser",
"//src/core:channel_args",
@ -3427,6 +3495,7 @@ grpc_cc_library(
"//src/core:tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h",
],
external_deps = [
"absl/types:span",
"libcrypto",
"libssl",
],
@ -3506,6 +3575,7 @@ grpc_cc_library(
"tsi_ssl_session_cache",
"//src/core:channel_args",
"//src/core:error",
"//src/core:grpc_crl_provider",
"//src/core:grpc_transport_chttp2_alpn",
"//src/core:ref_counted",
"//src/core:slice",
@ -3520,16 +3590,17 @@ grpc_cc_library(
"//src/core:ext/filters/http/client/http_client_filter.cc",
"//src/core:ext/filters/http/http_filters_plugin.cc",
"//src/core:ext/filters/http/message_compress/compression_filter.cc",
"//src/core:ext/filters/http/message_compress/legacy_compression_filter.cc",
"//src/core:ext/filters/http/server/http_server_filter.cc",
],
hdrs = [
"//src/core:ext/filters/http/client/http_client_filter.h",
"//src/core:ext/filters/http/message_compress/compression_filter.h",
"//src/core:ext/filters/http/message_compress/legacy_compression_filter.h",
"//src/core:ext/filters/http/server/http_server_filter.h",
],
external_deps = [
"absl/base:core_headers",
"absl/meta:type_traits",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3540,7 +3611,6 @@ grpc_cc_library(
visibility = ["@grpc:http"],
deps = [
"channel_arg_names",
"channel_stack_builder",
"config",
"gpr",
"grpc_base",
@ -3553,9 +3623,9 @@ grpc_cc_library(
"//src/core:arena_promise",
"//src/core:channel_args",
"//src/core:channel_fwd",
"//src/core:channel_init",
"//src/core:channel_stack_type",
"//src/core:context",
"//src/core:experiments",
"//src/core:grpc_message_size_filter",
"//src/core:latch",
"//src/core:map",
@ -3566,7 +3636,6 @@ grpc_cc_library(
"//src/core:race",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:transport_fwd",
],
)
@ -3581,9 +3650,9 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:grpclb"],
deps = [
"endpoint_addresses",
"gpr_platform",
"grpc_public_hdrs",
"server_address",
"//src/core:channel_args",
"//src/core:useful",
],
@ -3615,7 +3684,9 @@ grpc_cc_library(
"absl/strings",
"absl/strings:str_format",
"absl/types:optional",
"upb_base_lib",
"upb_lib",
"upb_mem_lib",
"upb_textformat_lib",
"upb_json_lib",
"upb_reflection",
@ -3626,6 +3697,7 @@ grpc_cc_library(
deps = [
"backoff",
"debug_location",
"endpoint_addresses",
"envoy_admin_upb",
"envoy_config_core_upb",
"envoy_config_endpoint_upb",
@ -3689,9 +3761,9 @@ grpc_cc_library(
hdrs = ["//src/core:ext/filters/client_channel/resolver/fake/fake_resolver.h"],
external_deps = [
"absl/base:core_headers",
"absl/status",
"absl/status:statusor",
"absl/strings",
"absl/time",
"absl/types:optional",
],
language = "c++",
visibility = [
@ -3706,11 +3778,10 @@ grpc_cc_library(
"grpc_resolver",
"orphanable",
"ref_counted_ptr",
"server_address",
"uri_parser",
"work_serializer",
"//src/core:channel_args",
"//src/core:grpc_service_config",
"//src/core:notification",
"//src/core:ref_counted",
"//src/core:useful",
],
@ -3803,8 +3874,10 @@ grpc_cc_library(
deps = [
"gpr",
"grpc_base",
"ref_counted_ptr",
"//src/core:error",
"//src/core:hpack_constants",
"//src/core:ref_counted",
"//src/core:slice",
"//src/core:status_helper",
],
@ -3820,6 +3893,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/random:bit_gen_ref",
"absl/status",
"absl/strings",
"absl/types:optional",
@ -3908,6 +3982,23 @@ grpc_cc_library(
hdrs = [
"//src/core:ext/transport/chttp2/transport/context_list_entry.h",
],
deps = [
"gpr",
"tcp_tracer",
],
)
grpc_cc_library(
name = "tcp_tracer",
hdrs = [
"//src/core:lib/channel/tcp_tracer.h",
],
external_deps = [
"absl/time",
"absl/types:optional",
],
language = "c++",
visibility = ["@grpc:tcp_tracer"],
deps = ["gpr"],
)
@ -3942,11 +4033,15 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/hash",
"absl/meta:type_traits",
"absl/random",
"absl/random:bit_gen_ref",
"absl/random:distributions",
"absl/status",
"absl/strings",
"absl/strings:cord",
"absl/strings:str_format",
"absl/types:optional",
"absl/types:variant",
],
language = "c++",
visibility = ["@grpc:grpclb"],
@ -3970,6 +4065,7 @@ grpc_cc_library(
"legacy_context",
"ref_counted_ptr",
"stats",
"tcp_tracer",
"//src/core:arena",
"//src/core:bdp_estimator",
"//src/core:bitset",
@ -3984,10 +4080,13 @@ grpc_cc_library(
"//src/core:iomgr_fwd",
"//src/core:iomgr_port",
"//src/core:match",
"//src/core:max_concurrent_streams_policy",
"//src/core:memory_quota",
"//src/core:ping_abuse_policy",
"//src/core:ping_callbacks",
"//src/core:ping_rate_policy",
"//src/core:poll",
"//src/core:random_early_detection",
"//src/core:ref_counted",
"//src/core:resource_quota",
"//src/core:resource_quota_trace",
@ -3997,8 +4096,8 @@ grpc_cc_library(
"//src/core:stats_data",
"//src/core:status_helper",
"//src/core:time",
"//src/core:transport_fwd",
"//src/core:useful",
"//src/core:write_size_policy",
],
)

2906
CMakeLists.txt generated

File diff suppressed because it is too large Load Diff

@ -21,6 +21,7 @@ for general contribution guidelines.
- [guantaol](https://github.com/guantaol), Google LLC
- [hcaseyal](https://github.com/hcaseyal), Google LLC
- [jtattermusch](https://github.com/jtattermusch), Google LLC
- [kevinnilson](https://github.com/kevinnilson), Google LLC
- [LittleCVR](https://github.com/littlecvr), Google LLC
- [markdroth](https://github.com/markdroth), Google LLC
- [matthewstevenson88](https://github.com/matthewstevenson88), Google LLC

1522
Makefile generated

File diff suppressed because it is too large Load Diff

@ -1,3 +0,0 @@
# Top level ownership
@markdroth **/OWNERS
@a11r **/OWNERS

1623
Package.swift generated

File diff suppressed because it is too large Load Diff

@ -4,6 +4,7 @@ require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'bundler/gem_tasks'
require 'fileutils'
require 'tmpdir'
require_relative 'build_config.rb'
@ -31,7 +32,6 @@ Rake::ExtensionTask.new('grpc_c', spec) do |ext|
'x86-mingw32', 'x64-mingw32', 'x64-mingw-ucrt',
'x86_64-linux', 'x86-linux', 'aarch64-linux',
'x86_64-darwin', 'arm64-darwin',
'universal-darwin'
]
ext.cross_compiling do |spec|
spec.files = spec.files.select {
@ -144,7 +144,7 @@ task 'gem:native', [:plat] do |t, args|
verbose = ENV['V'] || '0'
grpc_config = ENV['GRPC_CONFIG'] || 'opt'
ruby_cc_versions = ['3.2.0', '3.1.0', '3.0.0', '2.7.0', '2.6.0'].join(':')
ruby_cc_versions = ['3.2.0', '3.1.0', '3.0.0', '2.7.0'].join(':')
selected_plat = "#{args[:plat]}"
# use env variable to set artifact build paralellism
@ -201,12 +201,25 @@ task 'gem:native', [:plat] do |t, args|
File.truncate('grpc_c.64-msvcrt.ruby', 0)
File.truncate('grpc_c.64-ucrt.ruby', 0)
`mkdir -p src/ruby/nativedebug/symbols`
# TODO(apolcyn): make debug symbols work on apple platforms.
# Currently we hit "objcopy: grpc_c.bundle: file format not recognized"
# TODO(apolcyn): make debug symbols work on aarch64 linux.
# Currently we hit "objcopy: Unable to recognise the format of the input file `grpc_c.so'"
unix_platforms_without_debug_symbols = ['x86_64-darwin', 'arm64-darwin', 'aarch64-linux']
unix_platforms.each do |plat|
if unix_platforms_without_debug_symbols.include?(plat)
debug_symbols_dir = ''
else
debug_symbols_dir = File.join(Dir.pwd, 'src/ruby/nativedebug/symbols')
end
run_rake_compiler(plat, <<~EOT)
#{prepare_ccache_cmd} && \
gem update --system --no-document && \
bundle && \
bundle exec rake clean && \
export GRPC_RUBY_DEBUG_SYMBOLS_OUTPUT_DIR=#{debug_symbols_dir} && \
bundle exec rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem pkg/#{spec.full_name}.gem \
RUBY_CC_VERSION=#{ruby_cc_versions} \
V=#{verbose} \
@ -214,6 +227,13 @@ task 'gem:native', [:plat] do |t, args|
GRPC_RUBY_BUILD_PROCS=#{nproc_override}
EOT
end
# Generate debug symbol packages to complement the native libraries we just built
unix_platforms.each do |plat|
unless unix_platforms_without_debug_symbols.include?(plat)
`bash src/ruby/nativedebug/build_package.sh #{plat}`
`cp src/ruby/nativedebug/pkg/*.gem pkg/`
end
end
end
# Define dependencies between the suites.

@ -66,7 +66,7 @@ pip_install(
requirements = "@com_github_grpc_grpc//:requirements.bazel.txt",
)
load("@upb//bazel:system_python.bzl", "system_python")
load("@com_google_protobuf//bazel:system_python.bzl", "system_python")
system_python(
name = "system_python",
@ -77,9 +77,9 @@ load("@system_python//:pip.bzl", "pip_parse")
pip_parse(
name = "pip_deps",
requirements = "@upb//python:requirements.txt",
requirements = "@com_google_protobuf//python:requirements.txt",
requirements_overrides = {
"3.11": "@upb//python:requirements_311.txt",
"3.11": "@com_google_protobuf//python:requirements_311.txt",
},
)
@ -102,6 +102,14 @@ load("@com_github_google_benchmark//:bazel/benchmark_deps.bzl", "benchmark_deps"
benchmark_deps()
load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps")
opentelemetry_cpp_deps()
load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps")
opentelemetry_extra_deps()
# TODO: Enable below once https://github.com/bazel-xcode/PodToBUILD/issues/232 is resolved
#
#http_archive(

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/_metadata.py.template`!!!
__version__ = """1.59.0.dev0"""
__version__ = """1.61.0.dev0"""

@ -1,5 +0,0 @@
set noparent
@jtattermusch
@veblush
@gnossen

@ -42,6 +42,7 @@ import unittest
import sys
import os
import pkgutil
import importlib
def trace_callback(event, args):
if event in ("switch", "throw"):
@ -73,7 +74,9 @@ class SingleLoader(object):
tests = []
for importer, module_name, is_package in pkgutil.walk_packages([os.path.dirname(os.path.relpath(__file__))]):
if pattern in module_name:
module = importer.find_module(module_name).load_module(module_name)
spec = importer.find_spec(module_name)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
tests.append(loader.loadTestsFromModule(module))
if len(tests) != 1:
raise AssertionError("Expected only 1 test module. Found {}".format(tests))

180
bazel/experiments.bzl generated

@ -16,34 +16,87 @@
"""Dictionary of tags to experiments so we know when to test different experiments."""
EXPERIMENT_ENABLES = {
"call_status_override_on_cancellation": "call_status_override_on_cancellation",
"canary_client_privacy": "canary_client_privacy",
"client_idleness": "client_idleness",
"client_privacy": "client_privacy",
"event_engine_client": "event_engine_client",
"event_engine_dns": "event_engine_dns",
"event_engine_listener": "event_engine_listener",
"free_large_allocator": "free_large_allocator",
"http2_stats_fix": "http2_stats_fix",
"keepalive_fix": "keepalive_fix",
"keepalive_server_fix": "keepalive_server_fix",
"memory_pressure_controller": "memory_pressure_controller",
"monitoring_experiment": "monitoring_experiment",
"multiping": "multiping",
"overload_protection": "overload_protection",
"peer_state_based_framing": "peer_state_based_framing",
"pending_queue_cap": "pending_queue_cap",
"pick_first_happy_eyeballs": "pick_first_happy_eyeballs",
"promise_based_client_call": "promise_based_client_call",
"promise_based_server_call": "promise_based_server_call",
"red_max_concurrent_streams": "red_max_concurrent_streams",
"registered_method_lookup_in_transport": "registered_method_lookup_in_transport",
"promise_based_inproc_transport": "promise_based_client_call,promise_based_inproc_transport,promise_based_server_call,registered_method_lookup_in_transport",
"registered_methods_map": "registered_methods_map",
"rfc_max_concurrent_streams": "rfc_max_concurrent_streams",
"round_robin_delegate_to_pick_first": "round_robin_delegate_to_pick_first",
"rstpit": "rstpit",
"schedule_cancellation_over_write": "schedule_cancellation_over_write",
"server_privacy": "server_privacy",
"tcp_frame_size_tuning": "tcp_frame_size_tuning",
"tcp_rcv_lowat": "tcp_rcv_lowat",
"trace_record_callops": "trace_record_callops",
"unconstrained_max_quota_buffer_size": "unconstrained_max_quota_buffer_size",
"v3_channel_idle_filters": "v3_channel_idle_filters",
"v3_compression_filter": "v3_compression_filter",
"work_serializer_clears_time_cache": "work_serializer_clears_time_cache",
"work_serializer_dispatch": "work_serializer_dispatch",
"write_size_policy": "write_size_policy",
"write_size_cap": "write_size_cap,write_size_policy",
"wrr_delegate_to_pick_first": "wrr_delegate_to_pick_first",
}
EXPERIMENTS = {
"windows": {
"dbg": {
},
"off": {
"bad_client_test": [
"rfc_max_concurrent_streams",
],
"compression_test": [
"v3_compression_filter",
],
"core_end2end_test": [
"event_engine_listener",
"promise_based_client_call",
"promise_based_server_call",
"work_serializer_dispatch",
],
"cpp_end2end_test": [
"promise_based_server_call",
"work_serializer_dispatch",
],
"endpoint_test": [
"tcp_frame_size_tuning",
"tcp_rcv_lowat",
],
"event_engine_listener_test": [
"event_engine_listener",
],
"flow_control_test": [
"multiping",
"peer_state_based_framing",
"red_max_concurrent_streams",
"rstpit",
"tcp_frame_size_tuning",
"tcp_rcv_lowat",
],
"lame_client_test": [
"promise_based_client_call",
],
"lb_unit_test": [
"work_serializer_dispatch",
],
"logging_test": [
"promise_based_server_call",
],
@ -54,11 +107,38 @@ EXPERIMENTS = {
],
"xds_end2end_test": [
"promise_based_server_call",
"work_serializer_dispatch",
],
},
"on": {
"core_end2end_test": [
"work_stealing",
"event_engine_listener",
],
"cpp_lb_end2end_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
"event_engine_listener_test": [
"event_engine_listener",
],
"flow_control_test": [
"overload_protection",
"write_size_cap",
"write_size_policy",
],
"lb_unit_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
"surface_registered_method_lookup": [
"registered_method_lookup_in_transport",
],
"xds_end2end_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
},
},
@ -66,29 +146,39 @@ EXPERIMENTS = {
"dbg": {
},
"off": {
"bad_client_test": [
"rfc_max_concurrent_streams",
],
"compression_test": [
"v3_compression_filter",
],
"core_end2end_test": [
"event_engine_listener",
"promise_based_client_call",
"promise_based_server_call",
"work_serializer_dispatch",
],
"cpp_end2end_test": [
"promise_based_server_call",
"work_serializer_dispatch",
],
"endpoint_test": [
"tcp_frame_size_tuning",
"tcp_rcv_lowat",
],
"event_engine_listener_test": [
"event_engine_listener",
],
"flow_control_test": [
"multiping",
"peer_state_based_framing",
"red_max_concurrent_streams",
"rstpit",
"tcp_frame_size_tuning",
"tcp_rcv_lowat",
],
"lame_client_test": [
"promise_based_client_call",
],
"lb_unit_test": [
"work_serializer_dispatch",
],
"logging_test": [
"promise_based_server_call",
],
@ -99,11 +189,32 @@ EXPERIMENTS = {
],
"xds_end2end_test": [
"promise_based_server_call",
"work_serializer_dispatch",
],
},
"on": {
"core_end2end_test": [
"work_stealing",
"cpp_lb_end2end_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
"flow_control_test": [
"overload_protection",
"write_size_cap",
"write_size_policy",
],
"lb_unit_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
"surface_registered_method_lookup": [
"registered_method_lookup_in_transport",
],
"xds_end2end_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
},
},
@ -111,17 +222,24 @@ EXPERIMENTS = {
"dbg": {
},
"off": {
"bad_client_test": [
"rfc_max_concurrent_streams",
],
"cancel_ares_query_test": [
"event_engine_dns",
],
"compression_test": [
"v3_compression_filter",
],
"core_end2end_test": [
"event_engine_client",
"event_engine_listener",
"promise_based_client_call",
"promise_based_server_call",
"work_serializer_dispatch",
],
"cpp_end2end_test": [
"promise_based_server_call",
"work_serializer_dispatch",
],
"endpoint_test": [
"tcp_frame_size_tuning",
@ -130,17 +248,20 @@ EXPERIMENTS = {
"event_engine_client_test": [
"event_engine_client",
],
"event_engine_listener_test": [
"event_engine_listener",
],
"flow_control_test": [
"multiping",
"peer_state_based_framing",
"red_max_concurrent_streams",
"rstpit",
"tcp_frame_size_tuning",
"tcp_rcv_lowat",
],
"lame_client_test": [
"promise_based_client_call",
],
"lb_unit_test": [
"work_serializer_dispatch",
],
"logging_test": [
"promise_based_server_call",
],
@ -154,11 +275,38 @@ EXPERIMENTS = {
],
"xds_end2end_test": [
"promise_based_server_call",
"work_serializer_dispatch",
],
},
"on": {
"core_end2end_test": [
"work_stealing",
"event_engine_listener",
],
"cpp_lb_end2end_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
"event_engine_listener_test": [
"event_engine_listener",
],
"flow_control_test": [
"overload_protection",
"write_size_cap",
"write_size_policy",
],
"lb_unit_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
"surface_registered_method_lookup": [
"registered_method_lookup_in_transport",
],
"xds_end2end_test": [
"pick_first_happy_eyeballs",
"round_robin_delegate_to_pick_first",
"wrr_delegate_to_pick_first",
],
},
},

@ -15,7 +15,7 @@
licenses(["notice"])
package(
default_visibility = ["//visibility:public"]
default_visibility = ["//visibility:public"],
)
# This is needed for the dependency on google_cloud_cpp to work.

@ -29,11 +29,11 @@ Contains macros used throughout the repo.
load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("//bazel:copts.bzl", "GRPC_DEFAULT_COPTS")
load("//bazel:experiments.bzl", "EXPERIMENTS")
load("//bazel:test_experiments.bzl", "TEST_EXPERIMENTS")
load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library", "upb_proto_reflection_library")
load("//bazel:experiments.bzl", "EXPERIMENTS", "EXPERIMENT_ENABLES")
load("//bazel:test_experiments.bzl", "TEST_EXPERIMENTS", "TEST_EXPERIMENT_ENABLES")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load("@build_bazel_rules_apple//apple/testing/default_runner:ios_test_runner.bzl", "ios_test_runner")
load("@com_google_protobuf//bazel:upb_proto_library.bzl", "upb_proto_library", "upb_proto_reflection_library")
# The set of pollers to test against if a test exercises polling
POLLERS = ["epoll1", "poll"]
@ -114,6 +114,7 @@ def _update_visibility(visibility):
"json_reader_legacy": PRIVATE,
"public": PUBLIC,
"ref_counted_ptr": PRIVATE,
"tcp_tracer": PRIVATE,
"trace": PRIVATE,
"tsi_interface": PRIVATE,
"tsi": PRIVATE,
@ -203,8 +204,8 @@ def grpc_cc_library(
includes = [
"api/include",
"include",
"src/core/ext/upb-generated", # Once upb code-gen issue is resolved, remove this.
"src/core/ext/upbdefs-generated", # Once upb code-gen issue is resolved, remove this.
"src/core/ext/upb-gen", # Once upb code-gen issue is resolved, remove this.
"src/core/ext/upbdefs-gen", # Once upb code-gen issue is resolved, remove this.
],
alwayslink = alwayslink,
data = data,
@ -417,6 +418,7 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us
return tags
experiment_config = list(poller_config)
experiment_enables = {k: v for k, v in EXPERIMENT_ENABLES.items() + TEST_EXPERIMENT_ENABLES.items()}
for mode, config in mode_config.items():
enabled_tags, disabled_tags = config
if enabled_tags != None:
@ -425,9 +427,10 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us
config = dict(config)
config["name"] = config["name"] + "@experiment=" + experiment
env = dict(config["env"])
env["GRPC_EXPERIMENTS"] = experiment
env["GRPC_EXPERIMENTS"] = experiment_enables[experiment]
env["GRPC_CI_EXPERIMENTS"] = "1"
config["env"] = env
tags = config["tags"]
tags = config["tags"] + ["experiment_variation"]
for tag in must_have_tags + enabled_tags:
if tag not in tags:
tags = tags + [tag]
@ -441,8 +444,9 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us
config["name"] = config["name"] + "@experiment=no_" + experiment
env = dict(config["env"])
env["GRPC_EXPERIMENTS"] = "-" + experiment
env["GRPC_CI_EXPERIMENTS"] = "1"
config["env"] = env
tags = config["tags"]
tags = config["tags"] + ["experiment_variation"]
for tag in must_have_tags + disabled_tags:
if tag not in tags:
tags = tags + [tag]

@ -22,42 +22,57 @@ def grpc_deps():
native.bind(
name = "upb_lib",
actual = "@upb//:upb",
actual = "@com_google_protobuf//upb",
)
native.bind(
name = "upb_amalgamation_lib",
actual = "@com_google_protobuf//upb:amalgamation",
)
native.bind(
name = "upb_base_lib",
actual = "@com_google_protobuf//upb/base",
)
native.bind(
name = "upb_collections_lib",
actual = "@upb//:collections",
actual = "@com_google_protobuf//upb/collections",
)
native.bind(
name = "upb_mem_lib",
actual = "@com_google_protobuf//upb/mem",
)
native.bind(
name = "upb_reflection",
actual = "@upb//:reflection",
actual = "@com_google_protobuf//upb:reflection",
)
native.bind(
name = "upb_lib_descriptor",
actual = "@upb//:descriptor_upb_proto",
actual = "@com_google_protobuf//upb:descriptor_upb_proto",
)
native.bind(
name = "upb_lib_descriptor_reflection",
actual = "@upb//:descriptor_upb_proto_reflection",
actual = "@com_google_protobuf//upb:descriptor_upb_proto_reflection",
)
native.bind(
name = "upb_textformat_lib",
actual = "@upb//:textformat",
actual = "@com_google_protobuf//upb/text",
)
native.bind(
name = "upb_json_lib",
actual = "@upb//:json",
actual = "@com_google_protobuf//upb/json",
)
native.bind(
name = "upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
actual = "@upb//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
actual = "@com_google_protobuf//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
)
native.bind(
@ -243,12 +258,12 @@ def grpc_deps():
if "com_google_protobuf" not in native.existing_rules():
http_archive(
name = "com_google_protobuf",
sha256 = "76a33e2136f23971ce46c72fd697cd94dc9f73d56ab23b753c3e16854c90ddfd",
strip_prefix = "protobuf-2c5fa078d8e86e5f4bd34e6f4c9ea9e8d7d4d44a",
sha256 = "7ed5fc41fe1614e551025f8e14b79b026a015b3ed337d38920c586f3ea35d818",
strip_prefix = "protobuf-6b5d8db01fe47478e8d400f550e797e6230d464e",
urls = [
# https://github.com/protocolbuffers/protobuf/commits/v23.4
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/2c5fa078d8e86e5f4bd34e6f4c9ea9e8d7d4d44a.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/2c5fa078d8e86e5f4bd34e6f4c9ea9e8d7d4d44a.tar.gz",
# https://github.com/protocolbuffers/protobuf/commits/v25.0
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/6b5d8db01fe47478e8d400f550e797e6230d464e.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/6b5d8db01fe47478e8d400f550e797e6230d464e.tar.gz",
],
patches = [
"@com_github_grpc_grpc//third_party:protobuf.patch",
@ -259,11 +274,11 @@ def grpc_deps():
if "com_google_googletest" not in native.existing_rules():
http_archive(
name = "com_google_googletest",
sha256 = "c8de6c60e12ad014a28225c5247ee735861d85cf906df617f6a29954ca05f547",
strip_prefix = "googletest-0e402173c97aea7a00749e825b194bfede4f2e45",
sha256 = "31bf78bd91b96dd5e24fab3bb1d7f3f7453ccbaceec9afb86d6e4816a15ab109",
strip_prefix = "googletest-2dd1c131950043a8ad5ab0d2dda0e0970596586a",
urls = [
# 2022-02-09
"https://github.com/google/googletest/archive/0e402173c97aea7a00749e825b194bfede4f2e45.tar.gz",
# 2023-10-09
"https://github.com/google/googletest/archive/2dd1c131950043a8ad5ab0d2dda0e0970596586a.tar.gz",
],
)
@ -380,26 +395,14 @@ def grpc_deps():
],
)
if "upb" not in native.existing_rules():
http_archive(
name = "upb",
sha256 = "c29fbd26eb19f388a1894099fae5ae599210be22926e1e1694c0ed1284f1c151",
strip_prefix = "upb-455cfdb8ae60a1763e6d924e36851c6897a781bb",
urls = [
# https://github.com/protocolbuffers/upb/commits/23.x
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/455cfdb8ae60a1763e6d924e36851c6897a781bb.tar.gz",
"https://github.com/protocolbuffers/upb/archive/455cfdb8ae60a1763e6d924e36851c6897a781bb.tar.gz",
],
)
if "envoy_api" not in native.existing_rules():
http_archive(
name = "envoy_api",
sha256 = "6fd3496c82919a433219733819a93b56699519a193126959e9c4fedc25e70663",
strip_prefix = "data-plane-api-e53e7bbd012f81965f2e79848ad9a58ceb67201f",
sha256 = "fff067a5d6d776fc88549b5dd4773a6f8f0187b26a859de8b29bd4226a28ee63",
strip_prefix = "data-plane-api-9d6ffa70677c4dbf23f6ed569676206c4e2edff4",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/envoyproxy/data-plane-api/archive/e53e7bbd012f81965f2e79848ad9a58ceb67201f.tar.gz",
"https://github.com/envoyproxy/data-plane-api/archive/e53e7bbd012f81965f2e79848ad9a58ceb67201f.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/envoyproxy/data-plane-api/archive/9d6ffa70677c4dbf23f6ed569676206c4e2edff4.tar.gz",
"https://github.com/envoyproxy/data-plane-api/archive/9d6ffa70677c4dbf23f6ed569676206c4e2edff4.tar.gz",
],
)
@ -489,25 +492,42 @@ def grpc_deps():
],
)
# TODO(stanleycheung): remove this when prometheus-cpp AND
# opentelemetry-cpp cut a new release
# This override is needed because this fix
# https://github.com/jupp0r/prometheus-cpp/pull/626
# has not been included in the latest prometheus-cpp release yet.
# We also need opentelemetry-cpp to update their dependency on
# prometheus-cpp after that fix is released.
# Without the fix, we cannot build the prometheus exporter with bazel 6
if "com_github_jupp0r_prometheus_cpp" not in native.existing_rules():
http_archive(
name = "com_github_jupp0r_prometheus_cpp",
strip_prefix = "prometheus-cpp-b1234816facfdda29845c46696a02998a4af115a",
urls = [
"https://github.com/jupp0r/prometheus-cpp/archive/b123481.zip",
],
)
if "io_opentelemetry_cpp" not in native.existing_rules():
http_archive(
name = "io_opentelemetry_cpp",
sha256 = "668de24f81c8d36d75092ad9dcb02a97cd41473adbe72485ece05e336db48249",
strip_prefix = "opentelemetry-cpp-1.9.1",
sha256 = "149f076cc7a79bbd3a3c34fb3ab61d3a3e8dcfe2b9596f79153e17123c32f897",
strip_prefix = "opentelemetry-cpp-064fef0d871c57ffac6739d3311659a5770a9db4",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.9.1.tar.gz",
"https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.9.1.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/open-telemetry/opentelemetry-cpp/archive/064fef0d871c57ffac6739d3311659a5770a9db4.tar.gz",
"https://github.com/open-telemetry/opentelemetry-cpp/archive/064fef0d871c57ffac6739d3311659a5770a9db4.tar.gz",
],
)
if "google_cloud_cpp" not in native.existing_rules():
http_archive(
name = "google_cloud_cpp",
sha256 = "371d01b03c7e2604d671b8fa1c86710abe3b524a78bc2705a6bb4de715696755",
strip_prefix = "google-cloud-cpp-2.14.0",
sha256 = "7ca7f583b60d2aa1274411fed3b9fb3887119b2e84244bb3fc69ea1db819e4e5",
strip_prefix = "google-cloud-cpp-2.16.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.16.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.16.0.tar.gz",
],
)

@ -22,7 +22,6 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
def grpc_extra_deps(ignore_version_differences = False):
"""Loads the extra dependencies.
@ -49,8 +48,6 @@ def grpc_extra_deps(ignore_version_differences = False):
"""
protobuf_deps()
upb_deps()
api_dependencies()
go_rules_dependencies()

@ -1,2 +1 @@
6.3.2
5.4.1
6.4.0

@ -16,6 +16,13 @@
"""Dictionary of tags to experiments so we know when to test different experiments."""
TEST_EXPERIMENT_ENABLES = {
"test_experiment_1": "test_experiment_1",
"test_experiment_2": "test_experiment_2",
"test_experiment_3": "test_experiment_3",
"test_experiment_4": "test_experiment_4",
}
TEST_EXPERIMENTS = {
"windows": {
"dbg": {

@ -57,17 +57,9 @@ function upload {
# upload "github.com/google/boringssl/archive/1c2769383f027befac5b75b6cedd25daf3bf4dcf.tar.gz"
# bazel binaries used by the tools/bazel wrapper script
upload github.com/bazelbuild/bazel/releases/download/5.4.1/bazel-5.4.1-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/5.4.1/bazel-5.4.1-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/5.4.1/bazel-5.4.1-windows-x86_64.exe
upload github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-windows-x86_64.exe
upload github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-windows-x86_64.exe
upload github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-windows-x86_64.exe
# Collect the github archives to mirror from grpc_deps.bzl
grep -o '"https://github.com/[^"]*"' bazel/grpc_deps.bzl | sed 's/^"https:\/\///' | sed 's/"$//' | while read -r line ; do

File diff suppressed because it is too large Load Diff

@ -13,5 +13,5 @@
# limitations under the License.
module GrpcBuildConfig
CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-35.dll'
CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-37.dll'
end

@ -12,11 +12,11 @@ settings:
'#08': Use "-preN" suffixes to identify pre-release versions
'#09': Per-language overrides are possible with (eg) ruby_version tag here
'#10': See the expand_version.py for all the quirks here
core_version: 35.0.0
core_version: 37.0.0
csharp_major_version: 2
g_stands_for: generative
protobuf_version: 3.23.4
version: 1.59.0-dev
g_stands_for: grand
protobuf_version: 3.25.0
version: 1.61.0-dev
configs:
asan:
CC: clang
@ -149,8 +149,8 @@ defaults:
CFLAGS: -g
COREFLAGS: -fno-exceptions
CPPFLAGS: -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/abseil-cpp -Ithird_party/re2
-Ithird_party/upb -Isrc/core/ext/upb-generated -Isrc/core/ext/upbdefs-generated
-Ithird_party/utf8_range -Ithird_party/xxhash
-Ithird_party/upb -Isrc/core/ext/upb-gen -Isrc/core/ext/upbdefs-gen -Ithird_party/utf8_range
-Ithird_party/xxhash
LDFLAGS: -g
zlib:
CFLAGS: -fvisibility=hidden
@ -208,4 +208,7 @@ swift_package:
- grpc_authorization_provider
- gpr
- upb
- upb_json_lib
- upb_textformat_lib
- utf8_range_lib
- re2

@ -1,3 +0,0 @@
set noparent
@jtattermusch
@apolcyn

@ -86,6 +86,6 @@ elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
endif()
endif()
set(_gRPC_FIND_PROTOBUF "find_dependency(Protobuf CONFIG)")
set(_gRPC_FIND_PROTOBUF "include(CMakeFindDependencyMacro)\nfind_dependency(Protobuf CONFIG)")
endif()
endif()

@ -15,6 +15,6 @@
set(UPB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/upb)
set(_gRPC_UPB_INCLUDE_DIR "${UPB_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range")
set(_gRPC_UPB_GRPC_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upb-generated" "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upbdefs-generated")
set(_gRPC_UPB_GRPC_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upb-gen" "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upbdefs-gen")
set(_gRPC_UPB_LIBRARIES upb)

876
config.m4 generated

File diff suppressed because it is too large Load Diff

1146
config.w32 generated

File diff suppressed because it is too large Load Diff

@ -34,10 +34,13 @@ grpc_extra_deps()
## Supported Versions
In general, gRPC supports building with the latest patch release of the two most
recent LTS versions of Bazel. However individual releases may have a broader
gRPC supports building with the latest stable release of Bazel,
as well as the previous major version release for at least 6 months
after it transitions into maintenance mode.
This is consistent with the supported build systems of
[the Google Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support).
However individual releases may have a broader
compatibility range. The currently supported versions are captured by the
following list:
- [`6.3.2`](https://github.com/bazelbuild/bazel/releases/tag/6.3.2)
- [`5.4.1`](https://github.com/bazelbuild/bazel/releases/tag/5.4.1)
- [`6.4.0`](https://github.com/bazelbuild/bazel/releases/tag/6.4.0)

@ -4,6 +4,10 @@
proposed how gRPC supports TCP-level proxies via the HTTP CONNECT request,
defined in [RFC-2817](https://www.rfc-editor.org/rfc/rfc2817).
This guide documents gRPC C-Core's default proxy mapper implementation.
## HTTP Proxy
**Case 1** in the proposal documents a use-case where all outbound traffic from
an environment must go through a proxy. Configurations for such environments are
usually performed using environment variables such as `http_proxy`. gRPC
@ -11,11 +15,7 @@ supports this by providing a default proxy mapper implementation that allows for
overriding the server name (provided in the channel creation hostname) to
resolve based on such configurations.
This guide documents gRPC C-Core's default proxy mapper implementation.
## Working
### Enabling HTTP Proxy
### Enabling the HTTP Proxy
C-Core checks the following places to determine the HTTP proxy to use, stopping
at the first one that is set:
@ -65,3 +65,24 @@ addresses as the host between the range `10.10.0.0` to `10.10.0.255`.
The lookup and subsequent usage of an HTTP proxy for a specific channel can also
be disabled by setting the channel arg `GRPC_ARG_ENABLE_HTTP_PROXY` to 0.
## Address Proxy
**Case 2** in the proposal documents a partially protected environment, where
access to certain addresses must go through a proxy. Name resolution
of protected servers works normally, and the proxy allows the CONNECT request
to use an IP address instead of a hostname.
Only requests for certain hosts must go through the proxy. Requests to other
servers work without the proxy. Custom logic is used to determine which hosts
the proxy will be used for.
To use the address proxy, both of the following parameters need to be specified:
1. Address of the proxy can be specified using `GRPC_ARG_ADDRESS_HTTP_PROXY`
channel argument or `GRPC_ADDRESS_HTTP_PROXY` environment variable. Value of
the channel argument is preferred if both values are specified.
1. Comma-separated list of IP addresses and/or CIDR blocks that should be
accessed through the proxy. This can be specified using
the `GRPC_ARG_ADDRESS_HTTP_PROXY_ENABLED_ADDRESSES` channel argument
or `GRPC_ADDRESS_HTTP_PROXY_ENABLED_ADDRESSES` environment variable. Value of
the channel argument is preferred if both values are specified.

@ -69,6 +69,7 @@ some configuration as environment variables that can be set.
- health_check_client - traces health checking client code
- http - traces state in the http2 transport engine
- http2_stream_state - traces all http2 stream state mutations.
- http2_ping - traces pings/ping acks/antagonist writes in http2 stack.
- http1 - traces HTTP/1.x operations performed by gRPC
- inproc - traces the in-process transport
- http_keepalive - traces gRPC keepalive pings

@ -58,4 +58,6 @@
- 1.56 'g' stands for ['galvanized'](https://github.com/grpc/grpc/tree/v1.56.x)
- 1.57 'g' stands for ['grounded'](https://github.com/grpc/grpc/tree/v1.57.x)
- 1.58 'g' stands for ['goku'](https://github.com/grpc/grpc/tree/v1.58.x)
- 1.59 'g' stands for ['generative'](https://github.com/grpc/grpc/tree/master)
- 1.59 'g' stands for ['generative'](https://github.com/grpc/grpc/tree/v1.59.x)
- 1.60 'g' stands for ['gjallarhorn'](https://github.com/grpc/grpc/tree/v1.60.x)
- 1.61 'g' stands for ['grand'](https://github.com/grpc/grpc/tree/master)

@ -58,18 +58,20 @@ Features | gRFCs | [C++, Python,<br> Ruby, PHP](https://github.com/grpc/grpc/re
Request matching based on:<ul><li>[Path](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#config-route-v3-routematch) (prefix, full path and safe regex)</li><ul><li>[case_sensitive](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-routematch) must be true else config is NACKed</li></ul><li>[Headers](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-headermatcher)</li></ul>Request routing to multiple clusters based on [weights](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#config-route-v3-weightedcluster) | [A28](https://github.com/grpc/proposal/blob/master/A28-xds-traffic-splitting-and-routing.md) | v1.31.0 | v1.31.0 | v1.31.0 | v1.3.0 |
Case insensitive prefix/full path matching:<ul><li>[case_sensitive](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-routematch) can be true or false</li></ul> | | v1.34.0 | v1.34.0 | v1.34.0 | v1.3.0 |
Support for [xDS v3 APIs](https://www.envoyproxy.io/docs/envoy/latest/api-v3/api) | [A30](https://github.com/grpc/proposal/blob/master/A30-xds-v3.md) | v1.36.0 | v1.36.0 | v1.36.0 | v1.4.0 |
Support for [xDS v2 APIs](https://www.envoyproxy.io/docs/envoy/latest/api/api_supported_versions) | [A27](https://github.com/grpc/proposal/blob/master/A30-xds-v3.md#details-of-the-v2-to-v3-transition) | < v1.51.0 | < v1.53.0 | TBA | < v1.8.0 |
Support for [xDS v2 APIs](https://www.envoyproxy.io/docs/envoy/latest/api/api_supported_versions) | [A27](https://github.com/grpc/proposal/blob/master/A30-xds-v3.md#details-of-the-v2-to-v3-transition) | < v1.51.0 | < v1.53.0 | < v1.54.0 | < v1.8.0 |
[Maximum Stream Duration](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#config-route-v3-routeaction-maxstreamduration):<ul><li>Only max_stream_duration is supported.</li></ul> | [A31](https://github.com/grpc/proposal/blob/master/A31-xds-timeout-support-and-config-selector.md) | v1.37.1 | v1.37.1 | v1.37.0 | v1.4.0 |
[Circuit Breaking](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/circuit_breaker.proto):<ul><li>Only max_requests is supported.</li></ul> | [A32](https://github.com/grpc/proposal/blob/master/A32-xds-circuit-breaking.md) | v1.37.1 (N/A for PHP) | v1.37.1 | v1.37.0 | v1.4.0 |
[Fault Injection](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/fault/v3/fault.proto):<br> Only the following fields are supported:<ul><li>delay</li><li>abort</li><li>max_active_faults</li><li>headers</li></ul> | [A33](https://github.com/grpc/proposal/blob/master/A33-Fault-Injection.md) | v1.37.1 | v1.37.1 | v1.37.0 | v1.4.0 |
[Client Status Discovery Service](https://github.com/envoyproxy/envoy/blob/main/api/envoy/service/status/v3/csds.proto) | [A40](https://github.com/grpc/proposal/blob/master/A40-csds-support.md) | v1.37.1 (C++)<br>v1.38.0 (Python) | v1.37.1 | v1.37.0 | v1.5.0 |
[Aggregate Clusters](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/aggregate_cluster.html) and [Logical DNS Clusters](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/service_discovery.html#logical-dns) | [A37](https://github.com/grpc/proposal/blob/master/A37-xds-aggregate-and-logical-dns-clusters.md) | v1.47.0 | v1.39.0 | v1.52.2 | v1.9.0 |
[Ring hash](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#ring-hash) load balancing policy:<br> Only the following [policy specifiers](https://github.com/envoyproxy/envoy/blob/2443032526cf6e50d63d35770df9473dd0460fc0/api/envoy/config/route/v3/route_components.proto#L706) are supported:<ul><li>header</li><li>filter_state with key `io.grpc.channel_id`</li></ul>Only [`XX_HASH`](https://github.com/envoyproxy/envoy/blob/2443032526cf6e50d63d35770df9473dd0460fc0/api/envoy/config/cluster/v3/cluster.proto#L383) function is supported. | [A42](https://github.com/grpc/proposal/blob/master/A42-xds-ring-hash-lb-policy.md) | v1.40.0<br>(C++ and Python) | v1.40.1 | 1.41.0 | |
[Retry](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-retrypolicy):<br>Only the following fields are supported:<ul><li>retry_on for the following conditions: cancelled, deadline-exceeded, internal, resource-exhausted, and unavailable.</li><li>num_retries</li><li>retry_back_off</li></ul> | [A44](https://github.com/grpc/proposal/blob/master/A44-xds-retry.md) | v1.40.0<br>(C++ and Python) | v1.40.1 | 1.41.0 | |
[Retry](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-retrypolicy):<br>Only the following fields are supported:<ul><li>retry_on for the following conditions: cancelled, deadline-exceeded, internal, resource-exhausted, and unavailable.</li><li>num_retries</li><li>retry_back_off</li></ul> | [A44](https://github.com/grpc/proposal/blob/master/A44-xds-retry.md) | v1.40.0<br>(C++ and Python) | v1.40.1 | 1.41.0 | v1.8.0 |
[Security](https://www.envoyproxy.io/docs/envoy/latest/configuration/security/security):<br>Uses [certificate providers](https://github.com/grpc/proposal/blob/master/A29-xds-tls-security.md#certificate-provider-plugin-framework) instead of SDS | [A29](https://github.com/grpc/proposal/blob/master/A29-xds-tls-security.md) | v1.41.0<br>(C++ and Python) | v1.41.0 | 1.41.0 | |
[Authorization (RBAC)](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/rbac/v3/rbac.proto):<br><ul><li>`LOG` action has no effect<li>CEL unsupported and rejected</ul> | [A41](https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md) | v1.51.0<br>(C++ and Python) | v1.42.0 | 1.42.0 | |
[Outlier Detection](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/outlier):<br>Only the following detection types are supported:<ul><li>Success Rate</li><li>Failure Percentage</li></ul> | [A50](https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md) | v1.51.0 | v1.49.0 | v1.50.0 | v1.7.0 | |
[Custom Load Balancer Configuration](https://github.com/envoyproxy/envoy/blob/57be3189ffa3372b34e9480d1f02b2d165e49077/api/envoy/config/cluster/v3/cluster.proto#L1208) | [A52](https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md) | v1.55.0 | v1.47.0 | | |
[xDS Federation](https://github.com/cncf/xds/blob/main/proposals/TP1-xds-transport-next.md) | [A47](https://github.com/grpc/proposal/blob/master/A47-xds-federation.md) | v1.55.0 | | | |
[Client-Side Weighted Round Robin LB Policy](https://github.com/envoyproxy/envoy/blob/a6d46b6ac4750720eec9a49abe701f0df9bf8e0a/api/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.proto#L36) | [A58](https://github.com/grpc/proposal/blob/master/A58-client-side-weighted-round-robin-lb-policy.md) | v1.55.0 | | | |
[StringMatcher for Header Matching](https://github.com/envoyproxy/envoy/blob/3fe4b8d335fa339ef6f17325c8d31f87ade7bb1a/api/envoy/config/route/v3/route_components.proto#L2280) | [A63](https://github.com/grpc/proposal/blob/master/A63-xds-string-matcher-in-header-matching.md) | v1.56.0 | | | |
[Least Request LB Policy](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers.html#weighted-least-request) | [A48](https://github.com/grpc/proposal/blob/master/A48-xds-least-request-lb-policy.md) | | v1.48.0 | | |
[Outlier Detection](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/outlier):<br>Only the following detection types are supported:<ul><li>Success Rate</li><li>Failure Percentage</li></ul> | [A50](https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md) | v1.51.0 | v1.49.0 | v1.50.0 | v1.7.0 |
[Custom Load Balancer Configuration](https://github.com/envoyproxy/envoy/blob/57be3189ffa3372b34e9480d1f02b2d165e49077/api/envoy/config/cluster/v3/cluster.proto#L1208) | [A52](https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md) | v1.55.0 | v1.47.0 | v1.56.0 | |
[xDS Federation](https://github.com/cncf/xds/blob/main/proposals/TP1-xds-transport-next.md) | [A47](https://github.com/grpc/proposal/blob/master/A47-xds-federation.md) | v1.55.0 | v1.55.0 | v1.55.0 | |
[Client-Side Weighted Round Robin LB Policy](https://github.com/envoyproxy/envoy/blob/a6d46b6ac4750720eec9a49abe701f0df9bf8e0a/api/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.proto#L36) | [A58](https://github.com/grpc/proposal/blob/master/A58-client-side-weighted-round-robin-lb-policy.md) | v1.55.0 | v1.54.0 | v1.56.0 | |
[StringMatcher for Header Matching](https://github.com/envoyproxy/envoy/blob/3fe4b8d335fa339ef6f17325c8d31f87ade7bb1a/api/envoy/config/route/v3/route_components.proto#L2280) | [A63](https://github.com/grpc/proposal/blob/master/A63-xds-string-matcher-in-header-matching.md) | v1.56.0 | v1.53.0 | v1.56.0 | v1.9.0 |
mTLS Credentials in xDS Bootstrap File | [A65](https://github.com/grpc/proposal/blob/master/A65-xds-mtls-creds-in-bootstrap.md) | v1.57.0 | | | |

@ -107,4 +107,4 @@ todo_include_todos = True
# -- Options for substitutions -----------------------------------------------
rst_epilog = '.. |grpc_types_link| replace:: https://github.com/grpc/grpc/blob/%s/include/grpc/impl/codegen/grpc_types.h' % branch
rst_epilog = '.. |channel_arg_names_link| replace:: https://github.com/grpc/grpc/blob/%s/include/grpc/impl/channel_arg_names.h' % branch

@ -45,6 +45,7 @@ Glossary
server object. Channel arguments are meant for advanced usages and contain
experimental API (some may not labeled as experimental). Full list of
available channel arguments and documentation can be found under the
"grpc_arg_keys" section of "grpc_types.h" header file (|grpc_types_link|).
For example, if you want to disable TCP port reuse, you may construct
channel arguments like: ``options = (('grpc.so_reuseport', 0),)``.
"grpc_arg_keys" section of "channel_arg_names.h" header file
(|channel_arg_names_link|). For example, if you want to disable TCP port
reuse, you may construct channel arguments like:
``options = (('grpc.so_reuseport', 0),)``.

@ -62,12 +62,12 @@ DNS](https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md).
Here is an example service config in protobuf form:
```
```textproto
{
// Use round_robin LB policy.
# Use round_robin LB policy.
load_balancing_config: { round_robin: {} }
// This method config applies to method "foo/bar" and to all methods
// of service "baz".
# This method config applies to method "foo/bar" and to all methods
# of service "baz".
method_config: {
name: {
service: "foo"
@ -76,7 +76,7 @@ Here is an example service config in protobuf form:
name: {
service: "baz"
}
// Default timeout for matching methods.
# Default timeout for matching methods.
timeout: {
seconds: 1
nanos: 1
@ -87,7 +87,7 @@ Here is an example service config in protobuf form:
Here is the same example service config in JSON form:
```
```json
{
"loadBalancingConfig": [ { "round_robin": {} } ],
"methodConfig": [

@ -24,8 +24,10 @@ statuses are defined as such:
| UNAUTHENTICATED | 16 | The request does not have valid authentication credentials for the operation. |
All RPCs started at a client return a `status` object composed of an integer
`code` and a string `message`. The server-side can choose the status it
returns for a given RPC.
`code` and a string `message`. The server-side can choose the status it returns
for a given RPC. Applications should only use values defined above. gRPC libraries
that encounter values outside this range must either propagate them directly or
convert them to UNKNOWN.
The gRPC client and server-side implementations may also generate and
return `status` on their own when errors happen. Only a subset of

@ -22,7 +22,7 @@ In addition, when handling requests, if the initial request metadata contains th
- If the value matches `sleep-<int>`, the server should wait the specified number of seconds before resuming behavior matching and RPC processing.
- If the value matches `keep-open`, the server should never respond to the request and behavior matching ends.
- If the value matches `error-code-<int>`, the server should respond with the specified status code and behavior matching ends.
- If the value matches `success-on-retry-attempt-<int>`, and the value of the `grpc-previous-rpc-attempts` metadata field is equal to the specified number, the normal RPC processing should resume and behavior matching ends.
- If the value matches `succeed-on-retry-attempt-<int>`, and the value of the `grpc-previous-rpc-attempts` metadata field is equal to the specified number, the normal RPC processing should resume and behavior matching ends.
- A value can have a prefix `hostname=<string>` followed by a space. In that case, the rest of the value should only be applied if the specified hostname matches the server's hostname.
The `rpc-behavior` header value can have multiple options separated by commas. In that case, the value should be split by commas and the options should be applied in the order specified. If a request has multiple `rpc-behavior` metadata values, each one should be processed that way in order.

@ -0,0 +1,39 @@
# Copyright 2023 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.
licenses(["notice"])
cc_binary(
name = "client",
srcs = ["client.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)
cc_binary(
name = "server",
srcs = ["server.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)

@ -0,0 +1,71 @@
# Copyright 2023 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.
#
# cmake build file for C++ keyvaluestore example.
# Assumes protobuf and gRPC have been installed using cmake.
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building keyvaluestore.
cmake_minimum_required(VERSION 3.8)
project(Cancellation C CXX)
include(../cmake/common.cmake)
# Proto files
get_filename_component(hw_proto "../../protos/helloworld.proto" ABSOLUTE)
get_filename_component(hw_proto_path "${hw_proto}" PATH)
# Generated sources
set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc")
set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h")
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
add_custom_command(
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
DEPENDS "${hw_proto}")
# Include generated *.pb.h files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
# hw_grpc_proto
add_library(hw_grpc_proto
${hw_grpc_srcs}
${hw_grpc_hdrs}
${hw_proto_srcs}
${hw_proto_hdrs})
target_link_libraries(hw_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
# Targets greeter_(client|server)
foreach(_target
client server)
add_executable(${_target} "${_target}.cc")
target_link_libraries(${_target}
hw_grpc_proto
absl::flags
absl::flags_parse
absl::strings
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
endforeach()

@ -0,0 +1,37 @@
# Cancellation Example
## Overview
This example shows you how to cancel from the client and how to get informed on the server and the client.
### Try it!
Once you have working gRPC, you can build this example using either bazel or cmake.
Run the server, which will listen on port 50051:
```sh
$ ./server
```
Run the client (in a different terminal):
```sh
$ ./client
```
If things go smoothly, you will see the client output:
```
Begin : Begin Ack
Count 1 : Count 1 Ack
Count 2 : Count 2 Ack
Count 3 : Count 3 Ack
Count 4 : Count 4 Ack
Count 5 : Count 5 Ack
Count 6 : Count 6 Ack
Count 7 : Count 7 Ack
Count 8 : Count 8 Ack
Count 9 : Count 9 Ack
RPC Cancelled!
```

@ -0,0 +1,119 @@
// Copyright 2023 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 <condition_variable>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_cat.h"
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(std::string, target, "localhost:50051", "Server address");
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using grpc::StatusCode;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
// Requests each key in the vector and displays the key and its corresponding
// value as a pair.
class KeyValueStoreClient
: public grpc::ClientBidiReactor<HelloRequest, HelloReply> {
public:
KeyValueStoreClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {
stub_->async()->SayHelloBidiStream(&context_, this);
request_.set_name("Begin");
StartWrite(&request_);
StartCall();
}
void OnReadDone(bool ok) override {
if (ok) {
std::cout << request_.name() << " : " << response_.message() << std::endl;
if (++counter_ < 10) {
request_.set_name(absl::StrCat("Count ", counter_));
StartWrite(&request_);
} else {
// Cancel after sending 10 messages
context_.TryCancel();
}
}
}
void OnWriteDone(bool ok) override {
if (ok) {
StartRead(&response_);
}
}
void OnDone(const grpc::Status& status) override {
if (!status.ok()) {
if (status.error_code() == StatusCode::CANCELLED) {
// Eventually client will know here that call is cancelled.
std::cout << "RPC Cancelled!" << std::endl;
} else {
std::cout << "RPC Failed: " << status.error_code() << ": "
<< status.error_message() << std::endl;
}
}
std::unique_lock<std::mutex> l(mu_);
done_ = true;
cv_.notify_all();
}
void Await() {
std::unique_lock<std::mutex> l(mu_);
while (!done_) {
cv_.wait(l);
}
}
private:
std::unique_ptr<Greeter::Stub> stub_;
size_t counter_ = 0;
ClientContext context_;
bool done_ = false;
HelloRequest request_;
HelloReply response_;
std::mutex mu_;
std::condition_variable cv_;
};
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint specified by
// the argument "--target=" which is the only expected argument.
std::string target_str = absl::GetFlag(FLAGS_target);
KeyValueStoreClient client(
grpc::CreateChannel(target_str, grpc::InsecureChannelCredentials()));
client.Await();
return 0;
}

@ -0,0 +1,104 @@
// Copyright 2023 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 <iostream>
#include <memory>
#include <string>
#include <vector>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_format.h"
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(uint16_t, port, 50051, "Server port for the service");
using grpc::CallbackServerContext;
using grpc::Server;
using grpc::ServerBidiReactor;
using grpc::ServerBuilder;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
// Logic behind the server's behavior.
class KeyValueStoreServiceImpl final : public Greeter::CallbackService {
ServerBidiReactor<HelloRequest, HelloReply>* SayHelloBidiStream(
CallbackServerContext* context) override {
class Reactor : public ServerBidiReactor<HelloRequest, HelloReply> {
public:
explicit Reactor() { StartRead(&request_); }
void OnReadDone(bool ok) override {
if (!ok) {
// Client cancelled it
std::cout << "OnReadDone Cancelled!" << std::endl;
return Finish(grpc::Status::CANCELLED);
}
response_.set_message(absl::StrCat(request_.name(), " Ack"));
StartWrite(&response_);
}
void OnWriteDone(bool ok) override {
if (!ok) {
// Client cancelled it
std::cout << "OnWriteDone Cancelled!" << std::endl;
return Finish(grpc::Status::CANCELLED);
}
StartRead(&request_);
}
void OnDone() override { delete this; }
private:
HelloRequest request_;
HelloReply response_;
};
return new Reactor();
}
};
void RunServer(uint16_t port) {
std::string server_address = absl::StrFormat("0.0.0.0:%d", port);
KeyValueStoreServiceImpl service;
ServerBuilder builder;
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&service);
// Finally assemble the server.
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
// Wait for the server to shutdown. Note that some other thread must be
// responsible for shutting down the server for this call to ever return.
server->Wait();
}
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
RunServer(absl::GetFlag(FLAGS_port));
return 0;
}

@ -51,6 +51,7 @@ if(GRPC_AS_SUBMODULE)
# this build.
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
set(_REFLECTION grpc++_reflection)
set(_ORCA_SERVICE grpcpp_orca_service)
if(CMAKE_CROSSCOMPILING)
find_program(_PROTOBUF_PROTOC protoc)
else()

@ -0,0 +1,47 @@
# Copyright 2023 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.
licenses(["notice"])
cc_binary(
name = "csm_greeter_client",
srcs = ["csm_greeter_client.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//:grpcpp_csm_observability",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@io_opentelemetry_cpp//exporters/prometheus:prometheus_exporter",
"@io_opentelemetry_cpp//sdk/src/metrics",
],
)
cc_binary(
name = "csm_greeter_server",
srcs = ["csm_greeter_server.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//:grpc++_reflection",
"//:grpcpp_admin",
"//:grpcpp_csm_observability",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@io_opentelemetry_cpp//exporters/prometheus:prometheus_exporter",
"@io_opentelemetry_cpp//sdk/src/metrics",
],
)

@ -0,0 +1,39 @@
# Copyright 2023 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.
FROM python:3.9-slim-bookworm
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y build-essential clang curl
WORKDIR /workdir
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN mkdir /artifacts
COPY . .
RUN OVERRIDE_BAZEL_VERSION=5.4.0 tools/bazel build //examples/cpp/csm:csm_greeter_client
RUN cp -rL /workdir/bazel-bin/examples/cpp/csm/csm_greeter_client /artifacts/
FROM python:3.9-slim-bookworm
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y autoremove \
&& apt-get install -y curl
COPY --from=0 /artifacts ./
ENV GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST=true
ENTRYPOINT ["/csm_greeter_client"]

@ -0,0 +1,39 @@
# Copyright 2023 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.
FROM python:3.9-slim-bookworm
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y build-essential clang curl
WORKDIR /workdir
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN mkdir /artifacts
COPY . .
RUN OVERRIDE_BAZEL_VERSION=5.4.0 tools/bazel build //examples/cpp/csm:csm_greeter_server
RUN cp -rL /workdir/bazel-bin/examples/cpp/csm/csm_greeter_server /artifacts/
FROM python:3.9-slim-bookworm
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y autoremove \
&& apt-get install -y curl
COPY --from=0 /artifacts ./
ENV GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST=true
ENTRYPOINT ["/csm_greeter_server"]

@ -0,0 +1,11 @@
# gRPC C++ CSM Hello World Example
This CSM example builds on the [Hello World Example](https://github.com/grpc/grpc/tree/master/examples/cpp/helloworld) and changes the gRPC client and server to accept configuration from an xDS control plane and test SSA and CSM observability
## Configuration
The client takes the following command-line arguments -
* target - By default, the client tries to connect to the xDS "xds:///helloworld:50051" and gRPC would use xDS to resolve this target and connect to the server backend. This can be overriden to change the target.
The server takes the following command-line arguments -
* port - Port on which the Hello World service is run. Defaults to 50051.

@ -0,0 +1,200 @@
/*
*
* Copyright 2023 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 <condition_variable>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_split.h"
#include "opentelemetry/exporters/prometheus/exporter_factory.h"
#include "opentelemetry/exporters/prometheus/exporter_options.h"
#include "opentelemetry/sdk/metrics/meter_provider.h"
#include <grpcpp/ext/csm_observability.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/support/string_ref.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(std::string, target, "xds:///helloworld:50051", "Target string");
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
struct Cookie {
std::string name;
std::string value;
std::set<std::string> attributes;
std::pair<std::string, std::string> Header() const {
return std::make_pair("cookie", absl::StrFormat("%s=%s", name, value));
}
template <typename Sink>
friend void AbslStringify(Sink& sink, const Cookie& cookie) {
absl::Format(&sink, "(Cookie: %s, value: %s, attributes: {%s})",
cookie.name, cookie.value,
absl::StrJoin(cookie.attributes, ", "));
}
};
class GreeterClient {
protected:
static Cookie ParseCookie(absl::string_view header) {
Cookie cookie;
std::pair<absl::string_view, absl::string_view> name_value =
absl::StrSplit(header, absl::MaxSplits('=', 1));
cookie.name = std::string(name_value.first);
std::pair<absl::string_view, absl::string_view> value_attrs =
absl::StrSplit(name_value.second, absl::MaxSplits(';', 1));
cookie.value = std::string(value_attrs.first);
for (absl::string_view segment : absl::StrSplit(value_attrs.second, ';')) {
cookie.attributes.emplace(absl::StripAsciiWhitespace(segment));
}
return cookie;
}
static std::vector<Cookie> GetCookies(
const std::multimap<grpc::string_ref, grpc::string_ref>&
server_initial_metadata,
absl::string_view cookie_name) {
std::vector<Cookie> values;
auto pair = server_initial_metadata.equal_range("set-cookie");
for (auto it = pair.first; it != pair.second; ++it) {
gpr_log(GPR_INFO, "set-cookie header: %s", it->second.data());
const auto cookie = ParseCookie(it->second.data());
if (cookie.name == cookie_name) {
values.emplace_back(cookie);
}
}
return values;
}
public:
GreeterClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
// Assembles the client's payload, sends it and presents the response back
// from the server.
std::string SayHello(const std::string& user, Cookie* cookieFromServer,
const Cookie* cookieToServer) {
// Data we are sending to the server.
HelloRequest request;
request.set_name(user);
// Container for the data we expect from the server.
HelloReply reply;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext context;
// The actual RPC.
std::mutex mu;
std::condition_variable cv;
bool done = false;
Status status;
if (cookieToServer != NULL) {
std::pair<std::string, std::string> cookieHeader =
cookieToServer->Header();
context.AddMetadata(cookieHeader.first, cookieHeader.second);
}
stub_->async()->SayHello(&context, &request, &reply,
[&mu, &cv, &done, &status](Status s) {
status = std::move(s);
std::lock_guard<std::mutex> lock(mu);
done = true;
cv.notify_one();
});
std::unique_lock<std::mutex> lock(mu);
while (!done) {
cv.wait(lock);
}
// Act upon its status.
if (status.ok()) {
if (cookieFromServer != NULL) {
const std::multimap<grpc::string_ref, grpc::string_ref>&
server_initial_metadata = context.GetServerInitialMetadata();
std::vector<Cookie> cookies =
GetCookies(server_initial_metadata, "GSSA");
if (!cookies.empty()) {
*cookieFromServer = cookies.front();
}
}
return reply.message();
} else {
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
return "RPC failed";
}
}
private:
std::unique_ptr<Greeter::Stub> stub_;
};
static void sayHello(GreeterClient& greeter, Cookie* cookieFromServer,
const Cookie* cookieToServer) {
std::string user("world");
std::string reply = greeter.SayHello(user, cookieFromServer, cookieToServer);
std::cout << "Greeter received: " << reply << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(5));
}
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
opentelemetry::exporter::metrics::PrometheusExporterOptions opts;
// default was "localhost:9464" which causes connection issue across GKE pods
opts.url = "0.0.0.0:9464";
auto prometheus_exporter =
opentelemetry::exporter::metrics::PrometheusExporterFactory::Create(opts);
auto meter_provider =
std::make_shared<opentelemetry::sdk::metrics::MeterProvider>();
meter_provider->AddMetricReader(std::move(prometheus_exporter));
auto observability = grpc::experimental::CsmObservabilityBuilder()
.SetMeterProvider(std::move(meter_provider))
.BuildAndRegister();
if (!observability.ok()) {
std::cerr << "CsmObservability::Init() failed: "
<< observability.status().ToString() << std::endl;
return static_cast<int>(observability.status().code());
}
GreeterClient greeter(grpc::CreateChannel(
absl::GetFlag(FLAGS_target), grpc::InsecureChannelCredentials()));
Cookie session_cookie;
sayHello(greeter, &session_cookie, NULL);
while (true) {
sayHello(greeter, NULL, &session_cookie);
}
return 0;
}

@ -0,0 +1,126 @@
/*
*
* Copyright 2023 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 <iostream>
#include <memory>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_cat.h"
#include "opentelemetry/exporters/prometheus/exporter_factory.h"
#include "opentelemetry/exporters/prometheus/exporter_options.h"
#include "opentelemetry/sdk/metrics/meter_provider.h"
#include <grpcpp/ext/admin_services.h>
#include <grpcpp/ext/csm_observability.h>
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/health_check_service_interface.h>
#include <grpcpp/xds_server_builder.h>
#include "src/core/lib/iomgr/gethostname.h"
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(int32_t, port, 50051, "Server port for service.");
using grpc::CallbackServerContext;
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerUnaryReactor;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
// Logic and data behind the server's behavior.
class GreeterServiceImpl final : public Greeter::CallbackService {
ServerUnaryReactor* SayHello(CallbackServerContext* context,
const HelloRequest* request,
HelloReply* reply) override {
std::string prefix("Hello from ");
prefix += my_name + " ";
reply->set_message(prefix + request->name());
ServerUnaryReactor* reactor = context->DefaultReactor();
reactor->Finish(Status::OK);
return reactor;
}
public:
GreeterServiceImpl(const std::string& my_hostname) : my_name(my_hostname) {}
private:
const std::string my_name;
};
void RunServer(const char* hostname) {
grpc::EnableDefaultHealthCheckService(true);
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
int port = absl::GetFlag(FLAGS_port);
grpc::XdsServerBuilder xds_builder;
std::unique_ptr<Server> xds_enabled_server;
std::string my_hostname(hostname);
GreeterServiceImpl service(my_hostname);
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
xds_builder.RegisterService(&service);
// Listen on the given address with XdsServerCredentials and a fallback of
// InsecureServerCredentials
xds_builder.AddListeningPort(absl::StrCat("0.0.0.0:", port),
grpc::InsecureServerCredentials());
xds_enabled_server = xds_builder.BuildAndStart();
gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port);
// Wait for the server to shutdown. Note that some other thread must be
// responsible for shutting down the server for this call to ever return.
xds_enabled_server->Wait();
}
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
opentelemetry::exporter::metrics::PrometheusExporterOptions opts;
// default was "localhost:9464" which causes connection issue across GKE pods
opts.url = "0.0.0.0:9464";
auto prometheus_exporter =
opentelemetry::exporter::metrics::PrometheusExporterFactory::Create(opts);
auto meter_provider =
std::make_shared<opentelemetry::sdk::metrics::MeterProvider>();
meter_provider->AddMetricReader(std::move(prometheus_exporter));
auto observability = grpc::experimental::CsmObservabilityBuilder()
.SetMeterProvider(std::move(meter_provider))
.BuildAndRegister();
if (!observability.ok()) {
std::cerr << "CsmObservability::Init() failed: "
<< observability.status().ToString() << std::endl;
return static_cast<int>(observability.status().code());
}
const char* hostname = grpc_gethostname();
if (hostname == nullptr) {
std::cout << "Failed to get hostname, terminating" << std::endl;
return 1;
}
RunServer(hostname);
return 0;
}

@ -0,0 +1,42 @@
# Copyright 2023 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.
licenses(["notice"])
cc_binary(
name = "crashing_greeter_client",
srcs = ["crashing_greeter_client.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)
cc_binary(
name = "greeter_callback_server_admin",
srcs = ["greeter_callback_server_admin.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//:grpc++_reflection",
"//:grpcpp_admin",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/strings:str_format",
],
)

@ -0,0 +1,132 @@
# gRPC C++ Debugging Example
This example demonstrates a handful of ways you can debug your gRPC C++ applications.
## Enabling Trace Logs
gRPC allows you to configure more detailed log output for various aspects of gRPC behavior. The tracing log generation might have a large overhead and result in significantly larger log file sizes, especially when you try to trace transport or timer_check. But it is a powerful tool in your debugging toolkit.
### The Most Verbose Logging
Specify environment variables, then run your application:
```
GRPC_VERBOSITY=debug
GRPC_TRACE=all
```
For more granularity, please see
[environment_variables](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md).
### Debug Transport Protocol
```
GRPC_VERBOSITY=debug
GRPC_TRACE=tcp,http,secure_endpoint,transport_security
```
### Debug Connection Behavior
```
GRPC_VERBOSITY=debug
GRPC_TRACE=call_error,connectivity_state,pick_first,round_robin,glb
```
## GDB and other debuggers
`gdb` (and the like) are tools that lets you inspect your application while it is running, view stack traces on exceptions, pause and step through code at specified points or under certain conditions, etc. See https://www.sourceware.org/gdb/
### Inspecting errors
```
bazel build --config=dbg examples/cpp/debugging:crashing_greeter_client
gdb -ex run \
--args ./bazel-bin/examples/cpp/debugging/crashing_greeter_client \
--crash_on_errors=true \
--target=localhork:50051
```
Once the exception is thrown, you can use `bt` to see the stack trace and examine the crash, `info threads` to get the set of threads, etc. See the [GDB documentation](https://sourceware.org/gdb/current/onlinedocs/gdb.html/) for a more complete list of available features and commands.
### Breaking inside a function
After building the application above, this will break inside gRPC generated stub code:
```
gdb -ex 'b helloworld::Greeter::Stub::SayHello' \
-ex run \
--args ./bazel-bin/examples/cpp/debugging/crashing_greeter_client \
--crash_on_errors=true \
--target=localhork:50051
```
## gRPC Admin Interface: Live Channel Tracing
The [gRPC Admin Service](https://github.com/grpc/proposal/blob/master/A38-admin-interface-api.md)
provides a convenient API in each gRPC language to improve the usability of
creating a gRPC server with admin services to expose states in the gRPC library.
This includes channelz, which is a channel tracing feature; it tracks statistics
like how many messages have been sent, how many of them failed, what are the
connected sockets. See the [Channelz design doc](https://github.com/grpc/proposal/blob/master/A14-channelz.md).
### Integrating the gRPC Admin Service Into Your Server
As seen in the `greeter_callback_admin_server` target, you canenable admin services by using the `AddAdminServices` method.
```
grpc::ServerBuilder builder;
grpc::AddAdminServices(&builder);
builder.AddListeningPort(":50051", grpc::ServerCredentials(...));
std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
```
### Using grpcdebug
grpcdebug is a tool created to access the metrics from channelz and health services.
#### Installing the grpcdebug tool
The source code is located in a github project
[grpc-ecosystem/grpcdebug](https://github.com/grpc-ecosystem/grpcdebug). You
can either download [the latest built version]
(https://github.com/grpc-ecosystem/grpcdebug/releases/latest) (recommended) or
follow the README.md to build it yourself.
#### Running the grpcdebug tool
##### Usage
`grpcdebug <target address> [flags] channelz <command> [argument]`
| Command | Argument | Description |
| :--------- | :------------------: | :------------------------------------------------ |
| channel | \<channel id or URL> | Display channel states in a human readable way. |
| channels | | Lists client channels for the target application. |
| server | \<server ID> | Displays server state in a human readable way. |
| servers | | Lists servers in a human readable way. |
| socket | \<socket ID> | Displays socket states in a human readable way. |
| subchannel | \<id> | Display subchannel states in human readable way. |
Generally, you will start with either `servers` or `channels` and then work down
to the details
##### Getting overall server info
To begin with, build and run the server binary in the background
```
bazel build --config=dbg examples/cpp/debugging:all
./bazel-bin/examples/cpp/debugging/greeter_callback_server_admin&
```
You can then inspect the server
```bash
grpcdebug localhost:50051 channelz servers
```
This will show you the server ids with their activity
```text
Server ID Listen Addresses Calls(Started/Succeeded/Failed) Last Call Started
1 [[::]:50051] 38/34/3 now
```
For more information about `grpcdebug` features, please see [the grpcdebug documentation](https://github.com/grpc-ecosystem/grpcdebug)

@ -0,0 +1,92 @@
// Copyright 2023 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 <iostream>
#include <memory>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(bool, crash_on_errors, false,
"Crash the application on client errors");
ABSL_FLAG(std::string, target, "localhost:50051", "Server address");
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
class GreeterClient {
public:
GreeterClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
// Assembles the client's payload, sends it and presents the response back
// from the server.
std::string SayHello(const std::string& user) {
// Data we are sending to the server.
HelloRequest request;
request.set_name(user);
// Container for the data we expect from the server.
HelloReply reply;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext context;
// The actual RPC.
Status status = stub_->SayHello(&context, request, &reply);
// Act upon the status of the actual RPC.
if (absl::GetFlag(FLAGS_crash_on_errors)) {
assert(status.ok());
}
if (status.ok()) {
return reply.message();
} else {
return "RPC failed";
}
}
private:
std::unique_ptr<Greeter::Stub> stub_;
};
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint specified by
// the argument "--target=" which is the only expected argument.
// We indicate that the channel isn't authenticated (use of
// InsecureChannelCredentials()).
GreeterClient greeter(grpc::CreateChannel(
absl::GetFlag(FLAGS_target), grpc::InsecureChannelCredentials()));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;
return 0;
}

@ -0,0 +1,86 @@
// Copyright 2023 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 <iostream>
#include <memory>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_format.h"
#include <grpcpp/ext/admin_services.h>
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/health_check_service_interface.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(uint16_t, port, 50051, "Server port for the service");
using grpc::CallbackServerContext;
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerUnaryReactor;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
// Logic and data behind the server's behavior.
class GreeterServiceImpl final : public Greeter::CallbackService {
ServerUnaryReactor* SayHello(CallbackServerContext* context,
const HelloRequest* request,
HelloReply* reply) override {
std::string prefix("Hello ");
reply->set_message(prefix + request->name());
ServerUnaryReactor* reactor = context->DefaultReactor();
reactor->Finish(Status::OK);
return reactor;
}
};
void RunServer(uint16_t port) {
std::string server_address = absl::StrFormat("0.0.0.0:%d", port);
GreeterServiceImpl service;
grpc::EnableDefaultHealthCheckService(true);
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
ServerBuilder builder;
// Enable gRPC Admin Services
grpc::AddAdminServices(&builder);
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&service);
// Finally assemble the server.
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
// Wait for the server to shutdown. Note that some other thread must be
// responsible for shutting down the server for this call to ever return.
server->Wait();
}
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
RunServer(absl::GetFlag(FLAGS_port));
return 0;
}

@ -0,0 +1,29 @@
# Copyright 2023 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.
licenses(["notice"])
cc_binary(
name = "orca_server",
srcs = ["orca_server.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//:grpcpp_orca_service",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/strings:str_format",
],
)

@ -0,0 +1,46 @@
# gRPC Custom Metrics Example
You can find a complete set of instructions for building gRPC and running the
examples in the [C++ Quick Start][].
This example shows how to implement a server that provides custom metrics usable
by custom load balancing policies.
Server needs to be setup with metrics recorder and Orca service for sending
these metrics to a client:
```c++
GreeterServiceImpl service;
// Setup custom metrics recording
auto server_metric_recorder =
grpc::experimental::ServerMetricRecorder::Create();
grpc::experimental::OrcaService orca_service(
server_metric_recorder.get(),
grpc::experimental::OrcaService::Options().set_min_report_duration(
absl::Seconds(0.1)));
builder.RegisterService(&orca_service);
grpc::ServerBuilder::experimental_type(&builder).EnableCallMetricRecording(
nullptr);
```
Afterwards per-request metrics can be reported from the gRPC service
implementation using the metric recorder from the request context:
```c++
auto recorder = context->ExperimentalGetCallMetricRecorder();
if (recorder == nullptr) {
return Status(grpc::StatusCode::INTERNAL,
"Unable to access metrics recorder. Make sure "
"EnableCallMetricRecording had been called.");
}
recorder->RecordCpuUtilizationMetric(0.5);
```
Out of band metrics can be reported using the `server_metric_recorder`
directly:
```c++
server_metric_recorder->SetCpuUtilization(0.75);
```
[C++ Quick Start]: https://grpc.io/docs/languages/cpp/quickstart

@ -0,0 +1,101 @@
/*
*
* Copyright 2023 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 <cstddef>
#include <iostream>
#include <memory>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_format.h"
#include "examples/protos/helloworld.grpc.pb.h"
#include <grpcpp/ext/call_metric_recorder.h>
#include <grpcpp/ext/orca_service.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/health_check_service_interface.h>
#include <grpcpp/support/status.h>
using grpc::CallbackServerContext;
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerUnaryReactor;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
ABSL_FLAG(uint16_t, port, 50051, "Server port for the service");
// Logic and data behind the server's behavior.
class GreeterServiceImpl final : public Greeter::CallbackService {
ServerUnaryReactor* SayHello(CallbackServerContext* context,
const HelloRequest* request,
HelloReply* reply) override {
ServerUnaryReactor* reactor = context->DefaultReactor();
// Obtain the call metric recorder and use it to report the number of
// DB queries (custom cost metric) and CPU utilization.
auto recorder = context->ExperimentalGetCallMetricRecorder();
if (recorder == nullptr) {
reactor->Finish({grpc::StatusCode::INTERNAL,
"Unable to access metrics recorder. Make sure "
"EnableCallMetricRecording had been called."});
return reactor;
}
recorder->RecordRequestCostMetric("db_queries", 10);
recorder->RecordCpuUtilizationMetric(0.5);
std::string prefix("Hello ");
reply->set_message(prefix + request->name());
reactor->Finish(Status::OK);
return reactor;
}
};
void RunServer(uint16_t port) {
std::string server_address = absl::StrFormat("0.0.0.0:%d", port);
ServerBuilder builder;
GreeterServiceImpl service;
// Setup custom metrics recording. Note that this recorder may be use to send
// the out-of-band metrics to the client.
auto server_metric_recorder =
grpc::experimental::ServerMetricRecorder::Create();
grpc::experimental::OrcaService orca_service(
server_metric_recorder.get(),
grpc::experimental::OrcaService::Options().set_min_report_duration(
absl::Seconds(0.1)));
builder.RegisterService(&orca_service);
grpc::ServerBuilder::experimental_type(&builder).EnableCallMetricRecording(
server_metric_recorder.get());
// Resume setting up gRPC server as usual
grpc::EnableDefaultHealthCheckService(true);
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&service);
// Finally assemble the server.
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
server->Wait();
}
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
RunServer(absl::GetFlag(FLAGS_port));
return 0;
}

@ -0,0 +1,27 @@
# Copyright 2023 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.
licenses(["notice"])
cc_binary(
name = "greeter_callback_client",
srcs = ["greeter_callback_client.cc"],
defines = ["BAZEL_BUILD"],
deps = [
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)

@ -0,0 +1,70 @@
# 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.
# 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.
#
# cmake build file for C++ helloworld example.
# Assumes protobuf and gRPC have been installed using cmake.
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building helloworld.
cmake_minimum_required(VERSION 3.8)
project(HelloWorld C CXX)
include(../cmake/common.cmake)
# Proto file
get_filename_component(hw_proto "../../protos/helloworld.proto" ABSOLUTE)
get_filename_component(hw_proto_path "${hw_proto}" PATH)
# Generated sources
set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc")
set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h")
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
add_custom_command(
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
DEPENDS "${hw_proto}")
# Include generated *.pb.h files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
# hw_grpc_proto
add_library(hw_grpc_proto
${hw_grpc_srcs}
${hw_grpc_hdrs}
${hw_proto_srcs}
${hw_proto_hdrs})
target_link_libraries(hw_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
# Targets greeter_[async_](client|server)
foreach(_target
greeter_callback_client greeter_callback_server
add_executable(${_target} "${_target}.cc")
target_link_libraries(${_target}
hw_grpc_proto
absl::flags
absl::flags_parse
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
endforeach()

@ -0,0 +1,32 @@
# gRPC C++ Wait-For-Ready Example
The Wait-For-Ready example builds on the
[Hello World Example](https://github.com/grpc/grpc/tree/master/examples/cpp/helloworld)
and changes the gRPC client and server to show how to set wait-for-ready.
For more information on wait-for-ready in gRPC, please refer to
[gRPC Wait For Ready Semantics](https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md).
## Running the example
First run the client -
```
$ tools/bazel run examples/cpp/wait_for_ready:greeter_callback_client
```
On running this, we'll see 10 RPCs failed due to "Connection refused" errors.
These RPCs did not have WAIT_FOR_READY set, resulting in the RPCs not waiting
for the channel to be connected.
The next 10 RPCs have WAIT_FOR_READY set, so the client will be waiting for the
channel to be ready before progressing.
Now, on a separate terminal, run the server -
```
$ tools/bazel run examples/cpp/helloworld:greeter_callback_server
```
The client channel should now be able to connect to the server, and the RPCs
should succeed.

@ -0,0 +1,107 @@
//
//
// Copyright 2023 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 <condition_variable>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(std::string, target, "localhost:50051", "Server address");
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
class GreeterClient {
public:
GreeterClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
// Assembles the client's payload, sends it and presents the response back
// from the server.
std::string SayHello(const std::string& user, bool wait_for_ready) {
HelloRequest request;
request.set_name(user);
HelloReply reply;
ClientContext context;
context.set_wait_for_ready(wait_for_ready);
std::mutex mu;
std::condition_variable cv;
bool done = false;
Status status;
stub_->async()->SayHello(&context, &request, &reply,
[&mu, &cv, &done, &status](Status s) {
status = std::move(s);
std::lock_guard<std::mutex> lock(mu);
done = true;
cv.notify_one();
});
std::unique_lock<std::mutex> lock(mu);
while (!done) {
cv.wait(lock);
}
if (status.ok()) {
return reply.message();
} else {
std::cout << status.error_code() << ": " << status.error_message()
<< "\n";
return "RPC failed";
}
}
private:
std::unique_ptr<Greeter::Stub> stub_;
};
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
std::string target_str = absl::GetFlag(FLAGS_target);
GreeterClient greeter(
grpc::CreateChannel(target_str, grpc::InsecureChannelCredentials()));
std::string user("world");
// First send an RPC without wait_for_ready. If the server is not running,
// this RPC will fail immediately.
std::cout << "Greeter received: "
<< greeter.SayHello(user, /*wait_for_ready=*/false) << "\n";
std::cout << "\nWe will now send RPCs with wait_for_ready set. If the "
"server is not running already, please start it now.\n";
// Now send RPC with wait_for_ready for set. Even if the server is not
// running, the RPC will still wait for the deadline to expire before
// failing.
std::cout << "Greeter received: "
<< greeter.SayHello(user, /*wait_for_ready=*/true) << "\n";
return 0;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save