0

Roll third_party/grpc to ff8d12a129eed

Note to reviewers: don't review third_party/grpc/sources/, review
the rest and verify that update.sh is a no-op locally.

- third_party/grpc/generate_gn.sh doesn't work properly for upb
  dependencies, so this CL updates those targets manually based on the
  upstream Bazel files. The issue is documented in
  third_party/grpc/README.chromium.
- RegisterBuiltins() for plugin support is no longer exposed in a
  public header so the call is removed from grpc_plugin_registry.cc.
- test/core/json/corpus/ was moved [1] then deleted [2]. So
  corresponding fuzzing tests in Chromium are deleted too.

[1] https://github.com/grpc/grpc/pull/38120/files#diff-e5771683b0b08cc7db59fc5dbba5f666187945fd62ab5ee76c6935d590e84b48
[2] https://github.com/grpc/grpc/pull/38534/files

NO_IFTTT=False positives inside the forked repo.

Bug: 40285204
Change-Id: I7c3eafdf4e3cac9626d5d81a2c847014a4a849bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6276328
Auto-Submit: Victor Vianna <victorvianna@google.com>
Reviewed-by: Vigen Issahhanjan <vigeni@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1429336}
This commit is contained in:
Victor Hugo Vianna Silva
2025-03-06 22:56:37 -08:00
committed by Chromium LUCI CQ
parent a7ba40b933
commit c86846c054
3856 changed files with 443337 additions and 258446 deletions
PRESUBMIT.py
third_party/grpc
BUILD.gnREADME.chromium
patches
plugin_registry
source
include
grpc
grpcpp
alarm.hchannel.hclient_context.hcompletion_queue.hcreate_channel.hcreate_channel_binder.hcreate_channel_posix.h
ext
generic
impl
passive_listener.h
security
server.hserver_builder.hserver_context.hserver_interface.hserver_posix.h
support
test
version_info.hxds_server_builder.h
src
android
test
interop
app
src
boringssl
compiler
core
call
channelz
client_channel
config
ext
filters
backend_metrics
census
channel_idle
client_channel
deadline
fault_injection
gcp_authentication
http
load_reporting
logging
message_size
rbac
server_config_selector
stateful_session
gcp
transport
binder
chaotic_good
chttp2
cronet
inproc
upb-gen
envoy
admin
annotations
config
accesslog
bootstrap
cluster
common
core
endpoint
listener
metrics
overload
rbac
route
tap
trace
data
extensions
clusters
filters
http
load_balancing_policies
transport_sockets
upstreams
service
type
http
matcher
metadata
tracing
v3
google
src
udpa
validate
xds
annotations
core
data
service
type
upb-generated
envoy
admin
annotations
config
accesslog
bootstrap
cluster
common
core
endpoint
listener
metrics
overload
rbac
route
tap
trace
extensions
service
type
google
opencensus
src
udpa
validate
xds
upbdefs-gen
envoy
admin
annotations
config
accesslog
bootstrap
cluster
common
core
endpoint
listener
metrics
overload
rbac
route
tap
trace
data
extensions
service
type
google
src
udpa
validate
xds
upbdefs-generated
envoy
admin
annotations
config
accesslog
bootstrap
cluster
common
core
endpoint
listener
metrics
overload
rbac
route
tap
trace
extensions
service
type
google
opencensus
udpa
xds
xds
filter
handshaker
lib
address_utils
avl
backoff
channel
compression
debug
event_engine
ares_resolver.ccares_resolver.h
cf_engine
channel_args_endpoint_config.ccchannel_args_endpoint_config.hcommon_closures.hdefault_event_engine.ccdefault_event_engine.hdefault_event_engine_factory.ccdefault_event_engine_factory.hevent_engine.ccevent_engine_context.h
executor
extensions
forkable.ccforkable.hgrpc_polled_fd.hhandle_containers.hmemory_allocator.ccmemory_allocator_factory.hnameser.hpoller.hposix.h
posix_engine
query_extensions.href_counted_dns_resolver_interface.hresolved_address.ccresolved_address_internal.hshim.ccshim.hslice.ccslice_buffer.cctcp_socket_utils.cctcp_socket_utils.hthread_local.ccthread_local.hthread_pool.ccthread_pool.h
thread_pool
thready_event_engine
time_util.cctime_util.htrace.cctrace.hutils.ccutils.h
windows
work_queue.ccwork_queue.h
work_queue
experiments
gpr
gprpp
http
iomgr
buffer_list.ccbuffer_list.hcall_combiner.cccall_combiner.hcfstream_handle.cccfstream_handle.hclosure.ccclosure.hcombiner.cccombiner.hendpoint.ccendpoint.hendpoint_cfstream.ccendpoint_pair_posix.ccendpoint_pair_windows.ccerror.ccerror.herror_cfstream.ccev_apple.ccev_epoll1_linux.ccev_poll_posix.ccev_posix.ccev_posix.hev_windows.cc
event_engine_shims
exec_ctx.ccexec_ctx.hexecutor.ccexecutor.hfork_posix.ccfork_windows.ccgrpc_if_nametoindex_posix.ccgrpc_if_nametoindex_unsupported.ccinternal_errqueue.cciocp_windows.cciocp_windows.hiomgr.cciomgr.hiomgr_internal.cciomgr_internal.hiomgr_posix.cciomgr_posix_cfstream.cciomgr_windows.ccload_file.ccload_file.hlockfree_event.cclockfree_event.hnameser.hpolling_entity.ccpolling_entity.hpollset.ccpollset.hpollset_set.ccpollset_set_windows.ccpollset_windows.ccpollset_windows.hport.hpython_util.hresolve_address.ccresolve_address.hresolve_address_impl.hresolve_address_posix.ccresolve_address_windows.ccresolved_address.hsockaddr_posix.hsockaddr_utils_posix.ccsocket_factory_posix.ccsocket_factory_posix.hsocket_mutator.ccsocket_mutator.hsocket_utils.hsocket_utils_common_posix.ccsocket_utils_linux.ccsocket_utils_posix.ccsocket_utils_posix.hsocket_utils_windows.ccsocket_windows.ccsocket_windows.htcp_client.cctcp_client.htcp_client_cfstream.cctcp_client_posix.cctcp_client_windows.cctcp_posix.cctcp_posix.htcp_server.cctcp_server.htcp_server_posix.cctcp_server_utils_posix.htcp_server_utils_posix_common.cctcp_server_utils_posix_ifaddrs.cctcp_server_windows.cctcp_windows.cctimer.cctimer.htimer_generic.cctimer_generic.htimer_heap.cctimer_manager.cctimer_manager.hunix_sockets_posix.ccunix_sockets_posix.hunix_sockets_posix_noop.ccvsock.ccvsock.hwakeup_fd_eventfd.ccwakeup_fd_pipe.ccwakeup_fd_posix.h
json
load_balancing
promise
resolver
resource_quota
security
authorization
certificate_provider
context
credentials
alts
call_creds_util.cccall_creds_util.hchannel_creds_registry.hchannel_creds_registry_init.cc
composite
credentials.cccredentials.h
external
fake
gcp_service_account_identity
google_default
iam
insecure
jwt
local
oauth2
plugin
ssl
tls
token_fetcher
xds
security_connector
transport
util
service_config
slice
surface
transport
uri
load_balancing
plugin_registry
resolver
server
service_config
telemetry
tsi
util
alloc.ccalloc.hatomic_utils.havl.hbackoff.ccbackoff.hbitset.hchunked_vector.hconstruct_destruct.hcpp_impl_of.hcrash.cccrash.hdebug_location.hdirectory_reader.hdown_cast.hdual_ref_counted.hdump_args.ccdump_args.henv.hevent_log.ccevent_log.hexamine_stack.ccexamine_stack.hfork.ccfork.hgcp_metadata_query.ccgcp_metadata_query.hgethostname.hgethostname_fallback.ccgethostname_host_name_max.ccgethostname_sysconf.ccglob.ccglob.hgpr_time.ccgrpc_if_nametoindex.hgrpc_if_nametoindex_posix.ccgrpc_if_nametoindex_unsupported.cchost_port.cchost_port.h
http_client
if_list.h
iphone
json
latent_see.cclatent_see.h
linux
load_file.ccload_file.hlog.cclru_cache.hmanual_constructor.hmatch.hmatchers.ccmatchers.hmemory.hmpscq.ccmpscq.h
msys
no_destruct.hnotification.horphanable.hoverload.hpacked_table.hper_cpu.ccper_cpu.h
posix
random_early_detection.ccrandom_early_detection.href_counted.href_counted_ptr.href_counted_string.ccref_counted_string.hring_buffer.hsingle_set_ptr.hsorted_pack.hspinlock.hstat.hstatus_helper.ccstatus_helper.hstrerror.ccstrerror.hstring.ccstring.hsubprocess.hsubprocess_posix.ccsubprocess_windows.ccsync.ccsync.hsync_abseil.cctable.htchar.cctchar.htdigest.cctdigest.hthd.htime.cctime.htime_averaged_stats.cctime_averaged_stats.htime_precise.cctime_precise.htime_util.cctime_util.htmpfile.htype_list.hunique_ptr_with_bitset.hunique_type_name.hupb_utils.huri.ccuri.huseful.huuid_v4.ccuuid_v4.hvalidation_errors.ccvalidation_errors.hwait_for_single_owner.h
windows
work_serializer.ccwork_serializer.hxxhash_inline.h
xds
grpc
xds_client
cpp
client
common
ext
server
thread_manager
util
objective-c
php
python
ruby
test
core
json
corpus
006d552e952c42b5340baaeb85c2cb80c81e78dd007eb985c44b6089a34995a7d9ebf349f1c2bf1803b74a08f23734691512cb12d0b38d189a8df9050495693af07325fb0d52eafd2d4c4d802c6457c605454ab015cf74e9c3e8574d995517e05dd567510716d9708d321ffb6a00818614779e779925365c0a9b3522a8e711e3bd53e2c2eb9d28b34a003acc0ade7c2cf97f75d009975f4d720d1fa6c19f48970b1fcf0ac07e1e50cfe27316c7e1c8cc997f13180bc13548356d08009703d35e9c8d74397367bdfb0ea9a160c57f2c705dce037196e360bf9be739c50f20d9c46991c0e97419e2cca07c7389f1d6bdf80f2e2e6346f70c419300b661251754d50f7ca8ea108b310facc1a193833fc2971fd83081f775ea0c108e5bcd69b19ad0df743641085163b84f376fe810e3ecd5624465020fdf0662a67e0f0885536cae113c8c97cbb0a2b6176d75eaa9ac9baaa7ccddcc11479d936dd006410a5946b6081a94d573bf8efd11aa091189b78d1cc35c7ff4907ac16a73aba5471227907b2ee5a9492a890beed55332e4560834c8134d65130947ec69cf8df8483424b45e99cf04e313584505caa892d94982a968bbc4391ebcfe0d06137f554ee0f6b903acb81ab4e1f98c11fe92b0081401ea03ec78b8f20dc7be952555004d7147f0f5141d45a59b073aeec4443cd7bcf20f7833ddbc9515a8f2e7f94aa00b46f1b991416aa015dd63358015c9c1284c27c8893559e15c9b2a50cbd5bbb56f15d1a6cda48ef569b368a0c4627435bc2c80a98817a29f2ac6df774585d7713091b299729738030c17b815f1f72cb64481bc40263e91ce063040f739182d57403d2c973a394055017d35b7621aa0aa05190fbe2da448f6bdec0706c5301ad13363ae3ad91b045a24b8f1f1fd6e8234d5019952ee7713a8b71b6453892473a467d07372d45eb05abc2031647a1c6463aa2dabcb4fadc8e5441d8b418535e768af1dea95b5050b766274ef80847505c0e4f47f3ebb1df0754d3e7970b3afe549b11ca128dcd0d4832b1dfe267b623b20cd97c6e8969d8b9148af9f4a2c1e5c2f367f02e47a8c160cda1cd9d91decbac44120efdba13ca7a3657d071b3d56997aa3b083068a215a956168f77421253e947c2436371d56aa7ea12174b9ab6bf4f7c21fe1ed56957f1776ef611959232f4bced4075545bb1469d5c2360f083ec7ec6526aca41ee8f199e7c0c7cf31d979952571c53fc927d84210636e9e83786be9e9b96b69f70b743b8627da426a5883662d19ea78f306d7a992be52f827296dcda6f7e6979e68ddef7cbc1206a355084ad329b08c03ca5a6851fa4604a984cb7ff44433a5a52a3d964ec4527ad9f02129fcbf087b67a6ea64442b04974149815b143afb17af4388d751217e54ec2b3b1ad952e3acb566e32a84e2d503acde13eb532cc301a6ed7f01e2cd339f02bd0fda20c227a17e2d3d5b9275553430b4cfa68114099120ad7809ee2d5dbf403e0c12e2fe21b04ca3daff171c028ab72d7c769bed62004270034b976b1d940a5686106b2db120231eea12d9cdc6a00f30839b3cef2046be2db610e1a230409a205cf22fbad3348a54cbe7032df1dd2e2f5d57e7d9d4e60a756a86e6035732252e32faacd3ea4461ec7aace297b4be6904d9a3892e756d91759d7e74f5b776c0d2a1935292f576d12f09b24f9f5fa0af2c29b604b4b0f97fa61638953027d901361162b38fcaf17f97ba7d9646e3249530d4467ecb771ece9ed6c78a46adc299072d9db9311048bbf4c4bbabcde73607d7e76915cee9312e323b48969d7bf9a50aacf0912f1b5cb02119e2ab33400a242baeb5c46ddb1578c28b10d32a9c3cd3356a192b7913b04c54574d18c28d46e6395428ab35e995c107a71caeb833bb3b79f9f54781b33fa1373769c15c145472c8ec3bdde8fc84e85ec792113795d911970a1fd8416b93649051b418948e3edf37d3333e1e2a384c3ba14a52682ca29f061d1ac738cd33bb390445e35b6514024b1317902cb7ba1b3a90c688f44447a78efc111872b061a001f04d2b3b1e7b56ad4465d126ea994d34d20dcecbb3a50a3c0a8d6c31edaca124714624eb64cb8ec0cbab133cc0c9adcf3882f01409c70391c3cd30588ef34c3d0d9878b812ce4634962ba3dd755c09535502003d4d5887a2fcdc5dd360b8a6f89dbce6500d85803efb5b7ff94c5b9d411c93da9a70e1cc547f4c59421b7e8ea86e3c07474af16ab3ccef55d1857205428d051e437dd260f2a2f7ed920d9734ca34dc9042adc281578ffb1b8684b78b47aa40a16d10b6e743620ecd2e2fd58fe5650da2e9783f980f29ec0743b1ffcda49477adb1632822202631990ed3a26945279f85bf2f533a629073caf89403006279fab2455d9bb597f08bf698454157ecd86647b5dec4e04561eb5c7e43cae048c06aaaad3d5f5218b376e946417b001eeb87c32b642499fd5e1690d5d88c7f468af040024e96e9878ef33cc52755c5e7f5cbd5469e5ed2547e9e55a96e96eb832c615631e3b576472b07b9fcf2c2451e8781e944bf5f77cd8457c8486da8aff04083c5e0fe112e733f2ae510e312a1488a5ed641e340ae51992e04ce6590bdec5872184a0a19218e082a343a1b17e5333409af9d98f0f54a6644a1a3d5218f4bbd60220cab79c0b7bef45e4b39d4b8a9a04b9469e8fe4016322327fe5408824bb0294e14946fb1f64213384097a676d3ef94f04cd66dfabbd964f8c6c4414b07cdb45dae692e194d134bc072212ace2df385dae143139da74ec0ef4efa35221b2088e785048d0ff8fd99b03d5316fc4fa2a4a5a2f7dc4ddbdecae3ee85c787817b4cf84fed4bf2dc6259d9de54e9fa7db4fd5a61f2535e4ff800de0863adb5851fa26935159aa53b11cba74ff99a030518a132748c44bc1d836018e5b82cd0531c87b9772e54e3e183ef729f0a7d5a0d584f46534d66e7b0709d1e7692faae9e7f7299c92bba4b548775f9d7d13339dba3001f8238b84e9a45753354ec3b2d8a9b7a6d8204712eb1b90da703cf8a79552cfe1d8958e6d003ec8e883c4983dd67ef255e55f0c61d096a08506076489ded3b868db408677056cd60743c2cee939f5f357905bd36ec9363f44156e5f35e3d08b4e17e3558cacddf9e5ed13a0159580b03c49fba02bb8e399500eb66f2ff0482b22a5852643fbbcf92b0181327b69b4874c6ba6fa9f458f497e5efaf9f69080f9eef63b0b9dabcfdbc0d59129aacfb6cebbe2c52f30ef3424209f7252e82598a287a3e56caae23ed63abc95d5f3457165eef5a37a26dd2482226f534f79d321d28e7a615ab725a710dcd4c78ca1a74ceb9fbfb011f7ac86a5f7b5ae7b87f5377d5ffc16fd3f69b4a4aa7be8b11845b3fe86d5a309a6ba745881bd220fe1100b271ce5c38b7da113ab4535dbc22777ce8a1480c1c9d1e5ca6c45a8d2e11c782806df43e7668beb4aba8f55da7b543313339f84fd52e96bacf3a73368a1d2c5e12ae9117668bcc22832640cc626315940aeba85e397439a2680ed827c46704969c6711dabbda845e629dfb8b7533c7c2d173d4c3d587c88112cc295e785c7c26813577f3e30ef8f7e37ab2a9ffe39c5f3394f5058822cc044b926548376258971764805fb9bcbbb30a377209eab0541d144e44e71508d76008213a61d06b4382b223768530c3452968b7b360ba4b2daa4ed4d070fec06687e249e0e6f9ee45625ed64c30c8ab2f0b3bc75690f9faa4270f00416314c2b304d04dc0108a95d29a93515e85e2b0b06462d8079d2ea921617e7d073b85cfab706800d36474383282788e556aa86f57fc8650137ad264d0648c3f58ecc8fb4b8c779e6b11006ab5b1986dad66328e03a2ccd5e54dab23b816182786e6f518b6683e9045bc95e0cb5fc16ec64b118433475ba559689f13680f4682303c8aa6828b67955959dc966968c6ba7f0602a5410d1fa3c5de24fe264436b993699cafde80b1e1777306f781186d1253f018ab2369ab053b59e235fd6af246c5180f15bd9529511369afa12510b2e653b0af7c7030832647b2d63c376b75857f86be5c51b21a97f4a61e69e8bb6cd6986c75e71ecde9f073a7bad89f4831c8cde0bc18306ce5170dc4f2eee3b31a875b6a41f2444959f3dd6d2859436fbbee637f0a5981ca82e8f88a1d0d286d63e39f56d1d537bab9c2830303cabab3cd90356e05a0a240fe2974e14527bbe390d294564156e26e6c9d301adb0f0ddffd79cdf3426a2de99bad486e989edf725ec64849377681ce02641c3d1870e870142f66475ae2fb33722d8d4750f386ecfefe7b719edbe667ce2729ac78a22dac29263c9114402971f99ca2bda6ef2e15b965479a79587f9d794be0743e89b768af4bd591ea7228118550b1bfb8e7d17714a1a32872442a2eaff472685f3ea69451a7327719a1c782a1ba91c031a682a0a2f8658209adbf775e8ffda1f5d340dba472d06dc7c8bf8159e37977de68daecd823babbb58edb1c8e14d7106e83bb7957dc9aac31e6a6783fb3a6ee073688fed6cf9d7ae893cbbf9b11ff411640b80985ce618907559c7b20ac50954063e3ad00813acab4a98b2bfdb8587b6273145fb090de1c6163586f884a1da4b5cfbf7cf84b5a78281e6c6b5a9884110f3dbc6a40e3107ef13b83e6bde582d9000be043e729cd3221c15082059e250904b478f65daa0e647c1647ba6d6a3d8207fdf4bd302d6b6b1894990b353944a8716aa7831a49ad81b59025c241ac9e58bd88463fd798eb84582c1dbe026475319df14c19967d1dd0bf751f860d4ad0b7c026d1fcf51932b5e46500be7860a6865c7cf36a4f4499a6242e51b77b58b868a7447b87a2b80f9272583517c0207af176fc40ea55022c887309d048beef83ad3eabf2a79a64a389ab1c9f88d89860ccaf21e5f0f002303a2cd853ecbb2acb88f658400b1870ddf081fb03020c3098b0b1e08388f8b0984bb2f081918ad883c8f0ffacb5a8ff0a89304953495f060c7abd3584d83cb1c8e6d6653b8a5f6dc6873e3fd51fd866854d85258f8aa83a028a87261277c15667e2957dd52c5db6757ebc8e888aa61d8bd260942521bb1ba82cd4cce2324fdbee8d8874439569824e371a0284460440175cdb8a278d952ec2e33b2a6a1c7876898719a610f55463888e6fec8a05b24f221b6e94fdfe205e5bf7709a2c8e7fda77644ff91578d25243fad51a3cd6d608608ea6295ff82bb119acd44a91b463b19fedafb2268ee51caaa2c2f4ee2e5b4b7ef5a89db7df1068d78ef4dd9f2d0f9d770c937d9a43413d24df83f09b8efd86fb78a56a5145ed7739dcb00c78581c53758f0ba762c2fed0fc993feb91948902ac397b09198fe81e450694cac1eb4c4a5c966ffbc56ade3513902ba3cda1883801594b6e1b452790cc53948fda910a1528b28ebc6ff2f2a4fedb013c86de4103e292049bf3d8a0ec93c2d1633631c0082e66ca69e7920a3c318f3127b9c30ab02a077555c7dfbb6edb925fc05dd661aeb4a776dcbc5df3dcb2cefaf0a69367ba65affd5bf7aabf79c28e783cc5d93518e8939f5049b1eefb91ccbd3fcecaed8cb21ea6b2859405c2b00eaa5526f71cc78914dbd3ecaf093b6e94d3598751569d2a5be258e59665cbbf0692dfbe94f96d95d01e98fd2f04ce26c0913e5f9a882fb495b54a84db75abab401d282fdb04440a879a970896189202e587ec951d5795da3e03062f2fb5d7089711703428704ce2827a719eddb9d54be23a0cb79734597e96eebe99b2243121a51d178a338ec46f9747c85a9510011bf87c23a80b029b9f2d04c37d97d170e1550eee4afc0af065b78cda302a97674c98e02e7fc96479e8d10ff2cc7610be772e2d6fba996156b191b619eff79b2fcbb7598518a09b06bc99667fcfa6d583a742fb5450527fc86dfb78ebbf9b1ead2dbeeb1a3e9a7bebcf6964c3cfbc7e88679b7669e201574bfb979d56110539a90da5aca2c09c24b456af3cb51a1ff2780c2d9cbdd7d93f6c769d0441f23ae7d5a3a5b1140497868ee6eeab656b9d890bd3139a8f9a44d435ff8edfbeb5b072ded09e6a55b6b4563e652a23be9d623ca5055c3569409ec88420ef0408642f6930996e35f5b9f18ec88c9edd067c569315d5e93b0d14c7eac9fa6d81d3cd9fbda4f714043d975389b536b4497c6d713452e59fc8cb8ab3b05e306e5e81d9d949e69f931244eaa02b857f2eff73e8e188f35529dd91f8144b23b9a060d5bfd1235cbbe4bcecf332fa3b03bc2282e3a0931fae1d43e7887c1cabde83fdfc52eaeedba8a0d4af29c6c223b48fe34d6a09b3a7466242f33ca1abe8a785030d475a7350438fd23a05c382c110a1fb86293eac950c2b4f5182d9e4b5d9e0982ef6a2d4e3d6f5ba43c9199d5d2011678f82cfd55afca39653cb3d97c58c44013197f4d7557577700177a4c74ad56ae0e94e96101a8f2ce9b1e588df5e44a6b34b06b00e9226f2bd961483f9da81d8de99a8a72c3b9cc71eb7f0e0e4dabcd2dcd2b997f21c07a749d24bac55bc19465acc92b12244c56ca0f20da78009ff8b3f4d722ee0eb84795e857e74a58aeaa7ae4b16677806d78d0016c276b6722eba8eef3ca806f43dd48e35e75c27814c13a2a96c12449bd1a90a858013f90d2a94e0d62a7156ffd6848bf238a94bfbfe16d026b52d7f73cf78fdf7d6a6c5c58ba9718f029d11a9335ef596cbd42794de5b0b18b5aa6e08a488d1ed00aa51f20c2477fc89e7b0a852aaa038513c192fec501e4e7302156872ce2fde37ac2686c095a5a1c92a1d4209a6c287778720c86dac3478d69a3c81fa62e60f5c3696165a4e5e6ac4ac9231da4082430afe8f4d40127814c613648d8eadc83b19e793491b1c6ea0fd8b46cd9f32e592fcaff25e569bd8c93157e08cd18ebcd896438e34c9affced8168ec801de89deac663f708f0c96cf1a4b015dfc2f62b640d7c25adab7b38c5fcb5cb64c8b021dd7cd98b63092685ea092df0dc01c8f63334b17485b8bdec8809b3819a83753ca893871df403b32ef51eca9c6c658e6fb75fdf96bbba066404e7b3f0c7f6bb763af1be91d9e74eabfeb199dc1f1fb45a1635ec526bcc890f9d735976704e516c5f19b50ce51a7baa28cd298ebd05b4a3b9b70f9d4370b5126721812b925426b30d283d2bb8b6969f230ab57af943a3ee411bffeaa3872eec9c6fb01569a4b5abf6fd22ed0f852781de35d043059d0f86f3cdb6589fc6ab0dc82cf12099d1c2d40ab994e8410cb6f19238d2b04c5b86a17369093dafda34f332e7b858cb282617fb0956d960215c8e84d1ccf909c6b9c38fad09c80db7781fefbe51039752de575eccbb407c8992800444201dccfe744dac49c0295fdebc335734f73502b92d2bd3587259ce915985f0eebd113c2c8a2328e3674c680c7cff829a6c8ab924be051d58015d4af1977a5dfd14ef3fd070ecc9d2be461a0cd1fda052a69c3fd94f8cf5f6f86afa34bef524502f8dbbc45af717ece01ec88edd7f903bbf21a9e8fbc5a3846fb05b4fa0859e0917b2202fc0b6a90832b78ed5f6d129d3640c612540527c85c18d315f0d35849b2aae4a47cab4608204b85d76c257fd6bc9e5254a733378ab4ddd39629c4a3069c2bf7f49d8f2e13a60af4473b3b3451b65b3aa9ac308517acf6f7088634d491a1608240f83a3ac95c3badd71ef8a51b97ce93cbfe99f6778048f2128c482a632702ae7f532d126e70149dda4fadc3cd7c541bb86e55b98e083b141114066f9c17d853374c5b50b9015b6aaedd7eb1077b1204858f837b53cc62ef0dbd1350da9ea5a32e56672d385837643e7c7a34d6d49e1da1ccd490350c2df3a168ed09ae8c88c4bec8d440c56d3ea7abce39276f0927dbe0ac92f147bfc034003ac42ed9e62a16c84102ab417c96b0fe6034668edf37ef0f5f391d5107953dc06cac74aa5d7aab7fce0253f00c1a025980c1f9b7acaea0a0e6d8708cf682eaa446c344da56a7d5515cc8a3dd2678d4b400ad630f402012b894e841b05cd851bec7adad52f79777fb9347d5fd2f9486aa7ce3899b62ba3efe00eb31ddad2861ffe16a30d06ce8b76fdcdbf1c951afc2b115be9acc8a6358b32cec87b67871fc7a59652bc3546fbbb68e4d31e28cf32406111908544e504c84731147f072cdf2fbdcf35dc76bf9a2052636c1ecc92942161830dcdc3cf6a5e6bfe4f15b43e411dd2782e10f1670c9767cfc45616f5f0e7c25df91f6984ff5f6f1648beabcff891e5858ae68d08ecc8470ca6a68c9438bfa3cfff4e9d08cba81b663dd1999710008342851e19crash-f21867fe8b6df0b54c13e2e6e613dce871ecf0f0d1db03c626fb16c3b9cd44cc38cf40ebd355a194d85ca051da784c0441898c5affbf11a2ae8f56bcda03f536ceaf609972aa2a699687cc6f73ac0dcdda4b9237bacccdf19c0760cab7aec4a8359010b0dcc45e405208d7a2db33d0b5b9da2a2f1b034957dcc60d3aaa1fc4d00201a3512284fcb79b5b68efdd0567ae57bf3cc85891a1ca988c2945d9186678dd890a5a32e9f0489c6c77695f2155041f00fc9adf88e2baf7b76ffb2e94b9da57fd8d137f44b1efe00ee378c3f6e0b3cd89bd6e7517478d093f73dde0c124e90d068e2a70a3e148052869033453ec58e0d87b1f3e54e5adc5c2205f9e14772822a25766e1199df649697c570db5d6b2ea09d755eddd32b7e235f6f2a8b6a22117f1baa932fb6c69799e1136e3a654055a867ae62d8e68fa2c410228ac55cb6de3c680aac46b9c46392e3b2c43ecdcc1547f2023e3d134b35cc25a4861d90023c95988ec6103ddd5e3ff65de4b1622315c3b34b7a5e39bffb275489de4a4085cc31476f5de9047422851d8ccf86339dfe4e3c69da200af932c8a79fa055d7aeea28eb1d1e6c3dd630428fd54834172b8fd2735fed9416da4e71eb37fca2070521e1e07c503c2bcd6445b35eae760e6e22ae8cd1ea78fe28b5eb1f3d7b5fdc536e95ff1142118a2ca5b84935612a8a64d55360e64e9c5e2c67930513941753c2d54591c7098c82f6ceb26070d17ffa908204912e75cb4313835042038ebc6aee49e5ae57722df86e7fa33c420f045a449ed1dc11d713e7487de18ce8317b62916959206d0ede3f66106acd7796da8b3942d029fe213058286eed7bd220cd511b6d42ce6553019266a22a3d56af090932162756b798b1a050b05e3d36a3437c4fcf1905eaa84ba6a3593ec6ac0486a5b42893c01f1f4635fbbf765ead81a261ca152df02622e182d2cf46eeb1020c7c4153e742a50bc24c2c6939dab1ef473451610783521d51bc08cdd920ddd97f8a71ff63aa599600f6e7d648c4287905e16e8e6e479fdf667dcf1c06e87db2dc49d86ea1c285e796f8f8cf8d0f85975e49b959799cc52847110cc940b9db1f92c47e35da42d79a48beff54b93cd28f55f05fbf9a33bb8bd78d869fbafa402d9be58940ce2c318fbf6f3156c1bd4bb701839bc0e26533bdccd1c9afe2ef495a1152561572949784c16bf23abb28057fe5dbbcea5ce7e2988b8c69bcfdfde8904aabc1fff8fb34603c7f772768d61504954553e6bed173ctest1.jsontest2.jsontest3.jsontest4.jsontest5.jsontest6.jsontest7.jsontest8.jsontest9.jsontestcase-4743649675313152testcase-4778708900904960testcase-5115340413861888
third_party
cares
config_android
config_linux
toolchains
rbe_ubuntu2004_bazel7
cc
tools
upb
benchmarks
python
third_party
utf8_range
upb
arena.carena.harray.carray.h
base
bindings
cmake
collections.h
conformance
decode.cdecode.hdecode_fast.hdecode_internal.hdef.cdef.hdef.hppencode.cencode.hextension_registry.cextension_registry.h
fuzz
generated_code_support.h
hash
internal
io
json
json_decode.cjson_decode.hjson_encode.cjson_encode.hjson_test.cc
lex
map.cmap.h
mem
message
message_value.hmini_descriptor.cmini_descriptor.h
mini_descriptor
mini_table.cmini_table.hmini_table.hpp
mini_table
mini_table_accessors.cmini_table_accessors.hmini_table_accessors_internal.hmini_table_accessors_test.ccmini_table_test.ccmsg.cmsg.hmsg_internal.hmsg_test.cc
port
port_def.incport_undef.increflection.creflection.hreflection.hpp
reflection
status.cstatus.htable.ctable_internal.h
test
test_cpp.cctest_table.cc
text
text_encode.ctext_encode.hupb.cupb.hupb.hppupb_internal.h
util
wire
upbc
utf8_range
template
update.sh

@ -617,6 +617,7 @@ _BANNED_CPP_FUNCTIONS: Sequence[BanRule] = (
(
r'^base/third_party/symbolize/.*',
r'^third_party/abseil-cpp/.*',
r'^third_party/grpc/source/.*',
),
),
BanRule(

File diff suppressed because it is too large Load Diff

@ -2,8 +2,8 @@ Name: grpc
URL: https://github.com/grpc/grpc
License: BSD-3-Clause, Apache-2.0, MPL-2.0
License File: source/LICENSE
Version: v1.54.0-dev
Revision: a363b6c001139b9c8ffb7cd63f60a72f15349c3b
Version: v1.71.0-dev
Revision: ff8d12a129eedc58f9602c9fa9d1c01a2a270d62
Security Critical: yes
Shipped: yes
CPEPrefix: cpe:/a:grpc:grpc:1.49
@ -16,9 +16,11 @@ Steps to upgrade to a new version of GRPC, all relative to //third_party/grpc:
1. Update revision and version information in this file. Version file can be
found in the root BUILD file in gRPC repo.
2. Run third_party/grpc/update.sh.
3. Update the BUILD.gn file with ./generate_gn.sh. To use the script,
make sure the mako_templates python module is installed ("apt-get
install python3-mako").
3. Update the BUILD.gn file. ./generate_gn.sh is a script that tries to
do it but it's half-broken (it gets third_party targets wrong). It
might still be useful as a baseline. To run it, make sure the
mako_templates python module is installed ("apt-get install
python3-mako").
Note: Please also remember to check if `plugin_registry/grpc_plugin_registry.cc`
needs update! Upstream sometimes introduces new plugins in

@ -0,0 +1,217 @@
From 042ae2dd3af073a26bbca88e747a741a4d160bc3 Mon Sep 17 00:00:00 2001
From: Victor Hugo Vianna Silva <victorvianna@google.com>
Date: Mon, 17 Feb 2025 13:40:47 +0000
Subject: [PATCH] Replace absl::Flag with default flag value
Chromium cannot use absl::Flag as it has impact on binary size.
Wherever it is used, replace with the default flag value.
---
.../source/src/core/config/config_vars.cc | 72 ++++---------------
.../source/src/core/config/load_config.cc | 15 +---
.../grpc/source/src/core/config/load_config.h | 10 ++-
3 files changed, 21 insertions(+), 76 deletions(-)
diff --git a/third_party/grpc/source/src/core/config/config_vars.cc b/third_party/grpc/source/src/core/config/config_vars.cc
index a163b919859f7..963b4030df4d2 100644
--- a/third_party/grpc/source/src/core/config/config_vars.cc
+++ b/third_party/grpc/source/src/core/config/config_vars.cc
@@ -20,9 +20,9 @@
#include <grpc/support/port_platform.h>
-#include "absl/flags/flag.h"
+#include <optional>
+
#include "absl/strings/escaping.h"
-#include "absl/types/optional.h"
#include "src/core/config/load_config.h"
#ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING
@@ -35,96 +35,54 @@
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false
#endif // GRPC_ENABLE_FORK_SUPPORT
-ABSL_FLAG(std::vector<std::string>, grpc_experiments, {},
- "A comma separated list of currently active experiments. Experiments "
- "may be prefixed with a '-' to disable them.");
-ABSL_FLAG(absl::optional<int32_t>, grpc_client_channel_backup_poll_interval_ms,
- {},
- "Declares the interval in ms between two backup polls on client "
- "channels. These polls are run in the timer thread so that gRPC can "
- "process connection failures while there is no active polling "
- "thread. They help reconnect disconnected client channels (mostly "
- "due to idleness), so that the next RPC on this channel won't fail. "
- "Set to 0 to turn off the backup polls.");
-ABSL_FLAG(absl::optional<std::string>, grpc_dns_resolver, {},
- "Declares which DNS resolver to use. The default is ares if gRPC is "
- "built with c-ares support. Otherwise, the value of this environment "
- "variable is ignored.");
-ABSL_FLAG(std::vector<std::string>, grpc_trace, {},
- "A comma separated list of tracers that provide additional insight "
- "into how gRPC C core is processing requests via debug logs.");
-ABSL_FLAG(absl::optional<std::string>, grpc_verbosity, {},
- "Logging verbosity.");
-ABSL_FLAG(absl::optional<bool>, grpc_enable_fork_support, {},
- "Enable fork support");
-ABSL_FLAG(absl::optional<std::string>, grpc_poll_strategy, {},
- "Declares which polling engines to try when starting gRPC. This is a "
- "comma-separated list of engines, which are tried in priority order "
- "first -> last.");
-ABSL_FLAG(absl::optional<bool>, grpc_abort_on_leaks, {},
- "A debugging aid to cause a call to abort() when gRPC objects are "
- "leaked past grpc_shutdown()");
-ABSL_FLAG(absl::optional<std::string>, grpc_system_ssl_roots_dir, {},
- "Custom directory to SSL Roots");
-ABSL_FLAG(absl::optional<std::string>, grpc_default_ssl_roots_file_path, {},
- "Path to the default SSL roots file.");
-ABSL_FLAG(absl::optional<bool>, grpc_not_use_system_ssl_roots, {},
- "Disable loading system root certificates.");
-ABSL_FLAG(absl::optional<std::string>, grpc_ssl_cipher_suites, {},
- "A colon separated list of cipher suites to use with OpenSSL");
-ABSL_FLAG(absl::optional<bool>, grpc_cpp_experimental_disable_reflection, {},
- "EXPERIMENTAL. Only respected when there is a dependency on "
- ":grpc++_reflection. If true, no reflection server will be "
- "automatically added.");
-
namespace grpc_core {
ConfigVars::ConfigVars(const Overrides& overrides)
: client_channel_backup_poll_interval_ms_(
- LoadConfig(FLAGS_grpc_client_channel_backup_poll_interval_ms,
+ LoadConfig(std::optional<int32_t>{},
"GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS",
overrides.client_channel_backup_poll_interval_ms, 5000)),
enable_fork_support_(LoadConfig(
- FLAGS_grpc_enable_fork_support, "GRPC_ENABLE_FORK_SUPPORT",
+ std::optional<bool>{}, "GRPC_ENABLE_FORK_SUPPORT",
overrides.enable_fork_support, GRPC_ENABLE_FORK_SUPPORT_DEFAULT)),
- abort_on_leaks_(LoadConfig(FLAGS_grpc_abort_on_leaks,
+ abort_on_leaks_(LoadConfig(std::optional<bool>{},
"GRPC_ABORT_ON_LEAKS",
overrides.abort_on_leaks, false)),
not_use_system_ssl_roots_(LoadConfig(
- FLAGS_grpc_not_use_system_ssl_roots, "GRPC_NOT_USE_SYSTEM_SSL_ROOTS",
+ std::optional<bool>{}, "GRPC_NOT_USE_SYSTEM_SSL_ROOTS",
overrides.not_use_system_ssl_roots, false)),
cpp_experimental_disable_reflection_(
- LoadConfig(FLAGS_grpc_cpp_experimental_disable_reflection,
+ LoadConfig(std::optional<bool>{},
"GRPC_CPP_EXPERIMENTAL_DISABLE_REFLECTION",
overrides.cpp_experimental_disable_reflection, false)),
- dns_resolver_(LoadConfig(FLAGS_grpc_dns_resolver, "GRPC_DNS_RESOLVER",
+ dns_resolver_(LoadConfig(std::optional<std::string>{}, "GRPC_DNS_RESOLVER",
overrides.dns_resolver, "")),
- verbosity_(LoadConfig(FLAGS_grpc_verbosity, "GRPC_VERBOSITY",
+ verbosity_(LoadConfig(std::optional<std::string>{}, "GRPC_VERBOSITY",
overrides.verbosity,
GPR_DEFAULT_LOG_VERBOSITY_STRING)),
- poll_strategy_(LoadConfig(FLAGS_grpc_poll_strategy, "GRPC_POLL_STRATEGY",
+ poll_strategy_(LoadConfig(std::optional<std::string>{}, "GRPC_POLL_STRATEGY",
overrides.poll_strategy, "all")),
ssl_cipher_suites_(LoadConfig(
- FLAGS_grpc_ssl_cipher_suites, "GRPC_SSL_CIPHER_SUITES",
+ std::optional<std::string>{}, "GRPC_SSL_CIPHER_SUITES",
overrides.ssl_cipher_suites,
"TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_"
"SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:"
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384")),
- experiments_(LoadConfig(FLAGS_grpc_experiments, "GRPC_EXPERIMENTS",
+ experiments_(LoadConfig(std::vector<std::string>{}, "GRPC_EXPERIMENTS",
overrides.experiments, "")),
- trace_(LoadConfig(FLAGS_grpc_trace, "GRPC_TRACE", overrides.trace, "")),
+ trace_(LoadConfig(std::vector<std::string>{}, "GRPC_TRACE", overrides.trace, "")),
override_system_ssl_roots_dir_(overrides.system_ssl_roots_dir),
override_default_ssl_roots_file_path_(
overrides.default_ssl_roots_file_path) {}
std::string ConfigVars::SystemSslRootsDir() const {
- return LoadConfig(FLAGS_grpc_system_ssl_roots_dir,
+ return LoadConfig(std::optional<std::string>{},
"GRPC_SYSTEM_SSL_ROOTS_DIR", override_system_ssl_roots_dir_,
"");
}
std::string ConfigVars::DefaultSslRootsFilePath() const {
- return LoadConfig(FLAGS_grpc_default_ssl_roots_file_path,
+ return LoadConfig(std::optional<std::string>{},
"GRPC_DEFAULT_SSL_ROOTS_FILE_PATH",
override_default_ssl_roots_file_path_, "");
}
diff --git a/third_party/grpc/source/src/core/config/load_config.cc b/third_party/grpc/source/src/core/config/load_config.cc
index f78c0ccdc212b..e1ddf301d8f76 100644
--- a/third_party/grpc/source/src/core/config/load_config.cc
+++ b/third_party/grpc/source/src/core/config/load_config.cc
@@ -19,7 +19,6 @@
#include <optional>
-#include "absl/flags/marshalling.h"
#include "absl/log/check.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_join.h"
@@ -53,24 +52,14 @@ int32_t LoadConfigFromEnv(absl::string_view environment_variable,
bool LoadConfigFromEnv(absl::string_view environment_variable,
bool default_value) {
- auto env = LoadEnv(environment_variable);
- if (env.has_value()) {
- bool out;
- std::string error;
- if (absl::ParseFlag(env->c_str(), &out, &error)) return out;
- fprintf(stderr, "Error reading bool from %s: '%s' is not a bool: %s",
- std::string(environment_variable).c_str(), env->c_str(),
- error.c_str());
- }
return default_value;
}
-std::string LoadConfig(const absl::Flag<std::vector<std::string>>& flag,
+std::string LoadConfig(const std::vector<std::string>& from_flag,
absl::string_view environment_variable,
- const absl::optional<std::string>& override,
+ const std::optional<std::string>& override,
const char* default_value) {
if (override.has_value()) return *override;
- auto from_flag = absl::GetFlag(flag);
if (!from_flag.empty()) return absl::StrJoin(from_flag, ",");
return LoadConfigFromEnv(environment_variable, default_value);
}
diff --git a/third_party/grpc/source/src/core/config/load_config.h b/third_party/grpc/source/src/core/config/load_config.h
index 03a9e4bc283e4..e0ee9dd154909 100644
--- a/third_party/grpc/source/src/core/config/load_config.h
+++ b/third_party/grpc/source/src/core/config/load_config.h
@@ -22,7 +22,6 @@
#include <string>
#include <vector>
-#include "absl/flags/flag.h"
#include "absl/strings/string_view.h"
namespace grpc_core {
@@ -35,18 +34,17 @@ bool LoadConfigFromEnv(absl::string_view environment_variable,
bool default_value);
template <typename T, typename D>
-T LoadConfig(const absl::Flag<absl::optional<T>>& flag,
+T LoadConfig(const std::optional<T>& from_flag,
absl::string_view environment_variable,
- const absl::optional<T>& override, D default_value) {
+ const std::optional<T>& override, D default_value) {
if (override.has_value()) return *override;
- auto from_flag = absl::GetFlag(flag);
if (from_flag.has_value()) return std::move(*from_flag);
return LoadConfigFromEnv(environment_variable, default_value);
}
-std::string LoadConfig(const absl::Flag<std::vector<std::string>>& flag,
+std::string LoadConfig(const std::vector<std::string>& from_flag,
absl::string_view environment_variable,
- const absl::optional<std::string>& override,
+ const std::optional<std::string>& override,
const char* default_value);
} // namespace grpc_core
--
2.48.1.601.g30ceb7b040-goog

File diff suppressed because it is too large Load Diff

@ -0,0 +1,129 @@
From d5b3fa3438738a44a9caaaf6f2420b1817744868 Mon Sep 17 00:00:00 2001
From: Victor Hugo Vianna Silva <victorvianna@google.com>
Date: Mon, 17 Feb 2025 13:56:18 +0000
Subject: [PATCH] fucshia: Drop CreateDirectoryReloaderCrlProvider()
The API depends on MakeDirectoryReader(), which is currently
implemented for Windows and Posix but not Fuchsia. #ifdef it
out in Fuchsia.
---
.../grpc/source/include/grpc/grpc_crl_provider.h | 2 ++
.../security/credentials/tls/grpc_tls_crl_provider.cc | 10 +++++++++-
.../security/credentials/tls/grpc_tls_crl_provider.h | 10 ++++++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/third_party/grpc/source/include/grpc/grpc_crl_provider.h b/third_party/grpc/source/include/grpc/grpc_crl_provider.h
index e9a6db95cd9f0..83c7dcf38743f 100644
--- a/third_party/grpc/source/include/grpc/grpc_crl_provider.h
+++ b/third_party/grpc/source/include/grpc/grpc_crl_provider.h
@@ -68,6 +68,7 @@ class CrlProvider {
absl::StatusOr<std::shared_ptr<CrlProvider>> CreateStaticCrlProvider(
absl::Span<const std::string> crls);
+#if !defined(__Fuchsia__)
// Creates a CRL Provider that periodically and asynchronously reloads a
// directory. The refresh_duration minimum is 60 seconds. The
// reload_error_callback provides a way for the user to specifically log or
@@ -78,6 +79,7 @@ absl::StatusOr<std::shared_ptr<CrlProvider>> CreateStaticCrlProvider(
absl::StatusOr<std::shared_ptr<CrlProvider>> CreateDirectoryReloaderCrlProvider(
absl::string_view directory, std::chrono::seconds refresh_duration,
std::function<void(absl::Status)> reload_error_callback);
+#endif // !defined(__Fuchsia__)
} // namespace experimental
} // namespace grpc_core
diff --git a/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc b/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc
index 4fec5db6fbd5a..b3bff3eeb3cd9 100644
--- a/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc
+++ b/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc
@@ -43,9 +43,12 @@
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice.h"
-#include "src/core/util/directory_reader.h"
#include "src/core/util/load_file.h"
+#if !defined(__Fuchsia__)
+#include "src/core/util/directory_reader.h"
+#endif // !defined(__Fuchsia__)
+
namespace grpc_core {
namespace experimental {
@@ -70,6 +73,7 @@ absl::StatusOr<std::string> IssuerFromCrl(X509_CRL* crl) {
return ret;
}
+#if !defined(__Fuchsia__)
absl::StatusOr<std::shared_ptr<Crl>> ReadCrlFromFile(
const std::string& crl_path) {
absl::StatusOr<Slice> crl_slice = LoadFile(crl_path, false);
@@ -83,6 +87,7 @@ absl::StatusOr<std::shared_ptr<Crl>> ReadCrlFromFile(
}
return crl;
}
+#endif // !defined(__Fuchsia__)
} // namespace
@@ -144,6 +149,7 @@ std::shared_ptr<Crl> StaticCrlProvider::GetCrl(
return it->second;
}
+#if !defined(__Fuchsia__)
absl::StatusOr<std::shared_ptr<CrlProvider>> CreateDirectoryReloaderCrlProvider(
absl::string_view directory, std::chrono::seconds refresh_duration,
std::function<void(absl::Status)> reload_error_callback) {
@@ -253,6 +259,8 @@ std::shared_ptr<Crl> DirectoryReloaderCrlProvider::GetCrl(
}
return it->second;
}
+#endif // !defined(__Fuchsia__)
+
} // namespace experimental
} // namespace grpc_core
diff --git a/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h b/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h
index cd89301de81a9..a6382507cacbb 100644
--- a/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h
+++ b/third_party/grpc/source/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h
@@ -36,10 +36,14 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
-#include "src/core/util/directory_reader.h"
#include "src/core/util/sync.h"
#include "src/core/util/time.h"
+#if !defined(__Fuchsia__)
+#include "src/core/util/directory_reader.h"
+#endif // !defined(__Fuchsia__)
+
+
namespace grpc_core {
namespace experimental {
@@ -88,6 +92,7 @@ class CertificateInfoImpl : public CertificateInfo {
const std::string authority_key_identifier_;
};
+#if !defined(__Fuchsia__)
// Defining this here lets us hide implementation details (and includes) from
// the header in include
class DirectoryReloaderCrlProvider
@@ -122,8 +127,9 @@ class DirectoryReloaderCrlProvider
std::optional<grpc_event_engine::experimental::EventEngine::TaskHandle>
refresh_handle_;
};
+#endif // !defined(__Fuchsia__)
} // namespace experimental
} // namespace grpc_core
-#endif // GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CRL_PROVIDER_H
\ No newline at end of file
+#endif // GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_GRPC_TLS_CRL_PROVIDER_H
--
2.48.1.601.g30ceb7b040-goog

@ -20,14 +20,12 @@
// gRPC repo's src/core/plugin_registry/grpc_plugin_registry.cc then comment out
// several lb plugins that have been stripped out by BUILD.chromium.gn.template
#include <grpc/grpc.h>
#include <grpc/support/port_platform.h>
#include <grpc/grpc.h>
#include "third_party/grpc/source/src/core/lib/config/core_configuration.h"
#include "third_party/grpc/source/src/core/lib/surface/builtins.h"
#include "third_party/grpc/source/src/core/lib/transport/http_connect_handshaker.h"
#include "third_party/grpc/source/src/core/lib/transport/tcp_connect_handshaker.h"
#include "third_party/grpc/source/src/core/config/core_configuration.h"
#include "third_party/grpc/source/src/core/handshaker/http_connect/http_connect_handshaker.h"
#include "third_party/grpc/source/src/core/handshaker/tcp_connect/tcp_connect_handshaker.h"
namespace grpc_event_engine {
namespace experimental {
@ -118,7 +116,6 @@ void BuildCoreConfiguration(CoreConfiguration::Builder* builder) {
RegisterBackendMetricFilter(builder);
RegisterSecurityFilters(builder);
RegisterExtraFilters(builder);
RegisterBuiltins(builder);
}
} // namespace grpc_core

@ -19,10 +19,9 @@
#ifndef GRPC_BYTE_BUFFER_H
#define GRPC_BYTE_BUFFER_H
#include <grpc/support/port_platform.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/port_platform.h>
#ifdef __cplusplus
extern "C" {

@ -19,9 +19,8 @@
#ifndef GRPC_CENSUS_H
#define GRPC_CENSUS_H
#include <grpc/support/port_platform.h>
#include <grpc/grpc.h>
#include <grpc/support/port_platform.h>
#ifdef __cplusplus
extern "C" {

@ -19,12 +19,10 @@
#ifndef GRPC_COMPRESSION_H
#define GRPC_COMPRESSION_H
#include <grpc/support/port_platform.h>
#include <stdlib.h>
#include <grpc/impl/compression_types.h> // IWYU pragma: export
#include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {

File diff suppressed because it is too large Load Diff

@ -16,10 +16,10 @@
#include <grpc/support/port_platform.h>
#include <optional>
#include <string>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
namespace grpc_event_engine {
namespace experimental {
@ -32,11 +32,11 @@ class EndpointConfig {
public:
virtual ~EndpointConfig() = default;
// If the key points to an integer config, an integer value gets returned.
// Otherwise it returns an absl::nullopt_t
virtual absl::optional<int> GetInt(absl::string_view key) const = 0;
// Otherwise it returns an std::nullopt_t
virtual std::optional<int> GetInt(absl::string_view key) const = 0;
// If the key points to an string config, an string value gets returned.
// Otherwise it returns an absl::nullopt_t
virtual absl::optional<absl::string_view> GetString(
// Otherwise it returns an std::nullopt_t
virtual std::optional<absl::string_view> GetString(
absl::string_view key) const = 0;
// If the key points to an void* config, a void* pointer value gets returned.
// Otherwise it returns nullptr

@ -14,21 +14,21 @@
#ifndef GRPC_EVENT_ENGINE_EVENT_ENGINE_H
#define GRPC_EVENT_ENGINE_EVENT_ENGINE_H
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/event_engine/extensible.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/event_engine/port.h>
#include <grpc/event_engine/slice_buffer.h>
#include <grpc/support/port_platform.h>
#include <functional>
#include <vector>
#include "absl/functional/any_invocable.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/event_engine/port.h>
#include <grpc/event_engine/slice_buffer.h>
// TODO(vigneshbabu): Define the Endpoint::Write metrics collection system
// TODO(hork): remove all references to the factory methods.
namespace grpc_event_engine {
namespace experimental {
@ -79,7 +79,7 @@ namespace experimental {
///
///
/// Blocking EventEngine Callbacks
/// -----------------------------
/// ------------------------------
///
/// Doing blocking work in EventEngine callbacks is generally not advisable.
/// While gRPC's default EventEngine implementations have some capacity to scale
@ -90,8 +90,18 @@ namespace experimental {
/// *Best Practice* : Occasional blocking work may be fine, but we do not
/// recommend running a mostly blocking workload in EventEngine threads.
///
///
/// Thread-safety guarantees
/// ------------------------
///
/// All EventEngine methods are guaranteed to be thread-safe, no external
/// synchronization is required to call any EventEngine method. Please note that
/// this does not apply to application callbacks, which may be run concurrently;
/// application state synchronization must be managed by the application.
///
////////////////////////////////////////////////////////////////////////////////
class EventEngine : public std::enable_shared_from_this<EventEngine> {
class EventEngine : public std::enable_shared_from_this<EventEngine>,
public Extensible {
public:
/// A duration between two events.
///
@ -122,20 +132,14 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// \a Cancel method.
struct TaskHandle {
intptr_t keys[2];
static const TaskHandle kInvalid;
friend bool operator==(const TaskHandle& lhs, const TaskHandle& rhs);
friend bool operator!=(const TaskHandle& lhs, const TaskHandle& rhs);
static const GRPC_DLL TaskHandle kInvalid;
};
/// A handle to a cancellable connection attempt.
///
/// Returned by \a Connect, and can be passed to \a CancelConnect.
struct ConnectionHandle {
intptr_t keys[2];
static const ConnectionHandle kInvalid;
friend bool operator==(const ConnectionHandle& lhs,
const ConnectionHandle& rhs);
friend bool operator!=(const ConnectionHandle& lhs,
const ConnectionHandle& rhs);
static const GRPC_DLL ConnectionHandle kInvalid;
};
/// Thin wrapper around a platform-specific sockaddr type. A sockaddr struct
/// exists on all platforms that gRPC supports.
@ -167,7 +171,7 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// allocations. gRPC allows applications to set memory constraints per
/// Channel or Server, and the implementation depends on all dynamic memory
/// allocation being handled by the quota system.
class Endpoint {
class Endpoint : public Extensible {
public:
/// Shuts down all connections and invokes all pending read or write
/// callbacks with an error status.
@ -191,9 +195,12 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// on_read callback is not executed. Otherwise it returns false and the \a
/// on_read callback executes asynchronously when the read completes. The
/// caller must ensure that the callback has access to the buffer when it
/// executes. Ownership of the buffer is not transferred. Valid slices *may*
/// be placed into the buffer even if the callback is invoked with a non-OK
/// Status.
/// executes. Ownership of the buffer is not transferred. Either an error is
/// passed to the callback (like socket closed), or valid data is available
/// in the buffer, but never both at the same time. Implementations that
/// receive valid data must not throw that data away - that is, if valid
/// data is received on the underlying endpoint, a callback will be made
/// with that data available and an ok status.
///
/// There can be at most one outstanding read per Endpoint at any given
/// time. An outstanding read is one in which the \a on_read callback has
@ -259,7 +266,7 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// Listens for incoming connection requests from gRPC clients and initiates
/// request processing once connections are established.
class Listener {
class Listener : public Extensible {
public:
/// Called when the listener has accepted a new client connection.
using AcceptCallback = absl::AnyInvocable<void(
@ -283,8 +290,9 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// \a on_shutdown will never be called.
///
/// If this method returns a Listener, then \a on_shutdown will be invoked
/// exactly once, when the Listener is shut down. The status passed to it will
/// indicate if there was a problem during shutdown.
/// exactly once when the Listener is shut down, and only after all
/// \a on_accept callbacks have finished executing. The status passed to it
/// will indicate if there was a problem during shutdown.
///
/// The provided \a MemoryAllocatorFactory is used to create \a
/// MemoryAllocators for Endpoint construction.
@ -317,20 +325,17 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
///
/// If the associated connection has not been completed, it will be cancelled,
/// and this method will return true. The \a OnConnectCallback will not be
/// called.
/// called, and \a on_connect will be destroyed before this method returns.
virtual bool CancelConnect(ConnectionHandle handle) = 0;
/// Provides asynchronous resolution.
///
/// This object has a destruction-is-cancellation semantic.
/// Implementations should make sure that all pending requests are cancelled
/// when the object is destroyed and all pending callbacks will be called
/// shortly. If cancellation races with request completion, implementations
/// may choose to either cancel or satisfy the request.
class DNSResolver {
public:
/// Task handle for DNS Resolution requests.
struct LookupTaskHandle {
intptr_t keys[2];
static const LookupTaskHandle kInvalid;
friend bool operator==(const LookupTaskHandle& lhs,
const LookupTaskHandle& rhs);
friend bool operator!=(const LookupTaskHandle& lhs,
const LookupTaskHandle& rhs);
};
/// Optional configuration for DNSResolvers.
struct ResolverOptions {
/// If empty, default DNS servers will be used.
@ -353,7 +358,7 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
absl::AnyInvocable<void(absl::StatusOr<std::vector<SRVRecord>>)>;
/// Called with the result of a TXT record lookup
using LookupTXTCallback =
absl::AnyInvocable<void(absl::StatusOr<std::string>)>;
absl::AnyInvocable<void(absl::StatusOr<std::vector<std::string>>)>;
virtual ~DNSResolver() = default;
@ -362,37 +367,26 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// \a default_port may be a non-numeric named service port, and will only
/// be used if \a address does not already contain a port component.
///
/// When the lookup is complete, the \a on_resolve callback will be invoked
/// with a status indicating the success or failure of the lookup.
/// Implementations should pass the appropriate statuses to the callback.
/// For example, callbacks might expect to receive DEADLINE_EXCEEDED or
/// When the lookup is complete or cancelled, the \a on_resolve callback
/// will be invoked with a status indicating the success or failure of the
/// lookup. Implementations should pass the appropriate statuses to the
/// callback. For example, callbacks might expect to receive CANCELLED or
/// NOT_FOUND.
///
/// If cancelled, \a on_resolve will not be executed.
virtual LookupTaskHandle LookupHostname(LookupHostnameCallback on_resolve,
absl::string_view name,
absl::string_view default_port,
Duration timeout) = 0;
virtual void LookupHostname(LookupHostnameCallback on_resolve,
absl::string_view name,
absl::string_view default_port) = 0;
/// Asynchronously perform an SRV record lookup.
///
/// \a on_resolve has the same meaning and expectations as \a
/// LookupHostname's \a on_resolve callback.
virtual LookupTaskHandle LookupSRV(LookupSRVCallback on_resolve,
absl::string_view name,
Duration timeout) = 0;
virtual void LookupSRV(LookupSRVCallback on_resolve,
absl::string_view name) = 0;
/// Asynchronously perform a TXT record lookup.
///
/// \a on_resolve has the same meaning and expectations as \a
/// LookupHostname's \a on_resolve callback.
virtual LookupTaskHandle LookupTXT(LookupTXTCallback on_resolve,
absl::string_view name,
Duration timeout) = 0;
/// Cancel an asynchronous lookup operation.
///
/// This shares the same semantics with \a EventEngine::Cancel: successfully
/// cancelled lookups will not have their callbacks executed, and this
/// method returns true.
virtual bool CancelLookup(LookupTaskHandle handle) = 0;
virtual void LookupTXT(LookupTXTCallback on_resolve,
absl::string_view name) = 0;
};
/// At time of destruction, the EventEngine must have no active
@ -409,14 +403,17 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
virtual bool IsWorkerThread() = 0;
/// Creates and returns an instance of a DNSResolver, optionally configured by
/// the \a options struct.
virtual std::unique_ptr<DNSResolver> GetDNSResolver(
/// the \a options struct. This method may return a non-OK status if an error
/// occurred when creating the DNSResolver. If the caller requests a custom
/// DNS server, and the EventEngine implementation does not support it, this
/// must return an error.
virtual absl::StatusOr<std::unique_ptr<DNSResolver>> GetDNSResolver(
const DNSResolver::ResolverOptions& options) = 0;
/// Asynchronously executes a task as soon as possible.
///
/// \a Closures scheduled with \a Run cannot be cancelled. The \a closure will
/// not be deleted after it has been run, ownership remains with the caller.
/// \a Closures passed to \a Run cannot be cancelled. The \a closure will not
/// be deleted after it has been run, ownership remains with the caller.
///
/// Implementations must not execute the closure in the calling thread before
/// \a Run returns. For example, if the caller must release a lock before the
@ -425,9 +422,9 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
virtual void Run(Closure* closure) = 0;
/// Asynchronously executes a task as soon as possible.
///
/// \a Closures scheduled with \a Run cannot be cancelled. Unlike the
/// overloaded \a Closure alternative, the absl::AnyInvocable version's \a
/// closure will be deleted by the EventEngine after the closure has been run.
/// \a Closures passed to \a Run cannot be cancelled. Unlike the overloaded \a
/// Closure alternative, the absl::AnyInvocable version's \a closure will be
/// deleted by the EventEngine after the closure has been run.
///
/// This version of \a Run may be less performant than the \a Closure version
/// in some scenarios. This overload is useful in situations where performance
@ -444,6 +441,9 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
///
/// Implementations must not execute the closure in the calling thread before
/// \a RunAfter returns.
///
/// Implementations may return a \a kInvalid handle if the callback can be
/// immediately executed, and is therefore not cancellable.
virtual TaskHandle RunAfter(Duration when, Closure* closure) = 0;
/// Synonymous with scheduling an alarm to run after duration \a when.
///
@ -463,21 +463,16 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
absl::AnyInvocable<void()> closure) = 0;
/// Request cancellation of a task.
///
/// If the associated closure has already been scheduled to run, it will not
/// be cancelled, and this function will return false.
/// If the associated closure cannot be cancelled for any reason, this
/// function will return false.
///
/// If the associated closure has not been scheduled to run, it will be
/// cancelled, and the associated absl::AnyInvocable or \a Closure* will not
/// be executed. In this case, Cancel will return true.
///
/// Implementation note: closures should be destroyed in a timely manner after
/// execution or cancellation (milliseconds), since any state bound to the
/// closure may need to be destroyed for things to progress (e.g., if a
/// closure holds a ref to some ref-counted object).
/// If the associated closure can be cancelled, the associated callback will
/// never be run, and this method will return true. If the callback type was
/// an absl::AnyInvocable, it will be destroyed before the method returns.
virtual bool Cancel(TaskHandle handle) = 0;
};
/// Replace gRPC's default EventEngine factory.
/// [DEPRECATED] Replace gRPC's default EventEngine factory.
///
/// Applications may call \a SetEventEngineFactory at any time to replace the
/// default factory used within gRPC. EventEngines will be created when
@ -486,18 +481,83 @@ class EventEngine : public std::enable_shared_from_this<EventEngine> {
/// To be certain that none of the gRPC-provided built-in EventEngines are
/// created, applications must set a custom EventEngine factory method *before*
/// grpc is initialized.
// TODO(hork): delete once all known users have migrated away
void SetEventEngineFactory(
absl::AnyInvocable<std::unique_ptr<EventEngine>()> factory);
absl::AnyInvocable<std::shared_ptr<EventEngine>()> factory);
/// Reset gRPC's EventEngine factory to the built-in default.
/// [DEPRECATED] Reset gRPC's EventEngine factory to the built-in default.
///
/// Applications that have called \a SetEventEngineFactory can remove their
/// custom factory using this method. The built-in EventEngine factories will be
/// used going forward. This has no affect on any EventEngines that were created
/// using the previous factories.
//
// TODO(hork): delete once all known users have migrated away
void EventEngineFactoryReset();
/// Create an EventEngine using the default factory.
std::unique_ptr<EventEngine> CreateEventEngine();
/// Create a new EventEngine instance.
std::shared_ptr<EventEngine> CreateEventEngine();
/// Set the default EventEngine instance, which will be used throughout gRPC
///
/// gRPC will hold a ref to this engine until either
/// \a ShutdownDefaultEventEngine() is called or \a SetDefaultEventEngine() is
/// called again with a different value. Passing a value of nullptr will cause
/// gRPC to drop the ref it was holding without setting it to a new one.
///
/// Earlier calls to \a GetDefaultEventEngine will still hold a ref to the
/// previous default engine instance, if any.
void SetDefaultEventEngine(std::shared_ptr<EventEngine> engine);
/// Returns the default EventEngine instance.
///
/// Note that if SetDefaultEventEngine() has not been called, then the default
/// EventEngine may be created and destroyed as needed, meaning that multiple
/// calls to GetDefaultEventEngine() over a process's lifetime may return
/// different instances. Callers are expected to call GetDefaultEventEngine()
/// once and hold the returned reference for as long as they need the
/// EventEngine instance.
std::shared_ptr<EventEngine> GetDefaultEventEngine();
/// Resets gRPC to use one of the default internal EventEngines for all *new*
/// \a GetDefaultEventEngine requests and blocks until all refs on the active
/// default engine have been released (destroying that engine).
///
/// If you called \a SetDefaultEventEngine, you must call either
/// \a ShutdownDefaultEventEngine or \a SetDefaultEventEngine(nullptr) at the
/// end of your program. If you don't, the engine will never be destroyed.
///
/// If you want to reset the default engine to one of gRPC's internal versions
/// without waiting for all references to be released on the current default
/// engine, call \a SetDefaultEventEngine(nullptr) instead.
void ShutdownDefaultEventEngine();
bool operator==(const EventEngine::TaskHandle& lhs,
const EventEngine::TaskHandle& rhs);
bool operator!=(const EventEngine::TaskHandle& lhs,
const EventEngine::TaskHandle& rhs);
std::ostream& operator<<(std::ostream& out,
const EventEngine::TaskHandle& handle);
bool operator==(const EventEngine::ConnectionHandle& lhs,
const EventEngine::ConnectionHandle& rhs);
bool operator!=(const EventEngine::ConnectionHandle& lhs,
const EventEngine::ConnectionHandle& rhs);
std::ostream& operator<<(std::ostream& out,
const EventEngine::ConnectionHandle& handle);
namespace detail {
std::string FormatHandleString(uint64_t key1, uint64_t key2);
}
template <typename Sink>
void AbslStringify(Sink& out, const EventEngine::ConnectionHandle& handle) {
out.Append(detail::FormatHandleString(handle.keys[0], handle.keys[1]));
}
template <typename Sink>
void AbslStringify(Sink& out, const EventEngine::TaskHandle& handle) {
out.Append(detail::FormatHandleString(handle.keys[0], handle.keys[1]));
}
} // namespace experimental
} // namespace grpc_event_engine

@ -0,0 +1,71 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_EVENT_ENGINE_EXTENSIBLE_H
#define GRPC_EVENT_ENGINE_EXTENSIBLE_H
#include <grpc/support/port_platform.h>
#include "absl/strings/string_view.h"
namespace grpc_event_engine {
namespace experimental {
class Extensible {
public:
/// A method which allows users to query whether an implementation supports a
/// specified extension. The name of the extension is provided as an input.
///
/// An extension could be any type with a unique string id. Each extension may
/// support additional capabilities and if the implementation supports the
/// queried extension, it should return a valid pointer to the extension type.
///
/// E.g., use case of an EventEngine::Endpoint supporting a custom extension.
///
/// class CustomEndpointExtension {
/// public:
/// static std::string EndpointExtensionName() {
/// return "my.namespace.extension_name";
/// }
/// virtual void Process() = 0;
/// }
///
/// class CustomEndpoint :
/// public EventEngine::Endpoint, public CustomEndpointExtension {
/// public:
/// void* QueryExtension(absl::string_view id) override {
/// if (id == CustomEndpointExtension::EndpointExtensionName()) {
/// return static_cast<CustomEndpointExtension*>(this);
/// }
/// return nullptr;
/// }
/// void Process() override { ... }
/// ...
/// }
///
/// auto endpoint =
/// static_cast<CustomEndpointExtension*>(endpoint->QueryExtension(
/// CustomEndpointExtension::EndpointExtensionName()));
/// if (endpoint != nullptr) endpoint->Process();
///
virtual void* QueryExtension(absl::string_view /*id*/) { return nullptr; }
protected:
~Extensible() = default;
};
} // namespace experimental
} // namespace grpc_event_engine
#endif // GRPC_EVENT_ENGINE_EXTENSIBLE_H

@ -14,6 +14,8 @@
#ifndef GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
#define GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
#include <grpc/event_engine/memory_request.h>
#include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#include <algorithm>
@ -21,9 +23,6 @@
#include <type_traits>
#include <vector>
#include <grpc/event_engine/memory_request.h>
#include <grpc/slice.h>
namespace grpc_event_engine {
namespace experimental {
@ -50,6 +49,12 @@ class MemoryAllocatorImpl
/// request.max() inclusively.
virtual size_t Reserve(MemoryRequest request) = 0;
/// Allocate a slice, using MemoryRequest to size the number of returned
/// bytes. For a variable length request, check the returned slice length to
/// verify how much memory was allocated. Takes care of reserving memory for
/// any relevant control structures also.
virtual grpc_slice MakeSlice(MemoryRequest request) = 0;
/// Release some bytes that were previously reserved.
/// If more bytes are released than were reserved, we will have undefined
/// behavior.

@ -24,7 +24,7 @@ namespace internal {
// with `SliceCast`. Both ways need to be declared (i.e. if
// SliceCastable<A,B> exists, you should declare
// SliceCastable<B,A> too).
// The type has no members, it's just the existance of the specialization that
// The type has no members, it's just the existence of the specialization that
// unlocks SliceCast usage for a type pair.
template <typename Result, typename T>
struct SliceCastable;
@ -60,6 +60,18 @@ Result& SliceCast(T& value, SliceCastable<Result, T> = {}) {
return reinterpret_cast<Result&>(value);
}
// Cast to `Result&&` from `T&&` without any runtime checks.
// This is only valid if `sizeof(Result) == sizeof(T)`, and if `Result`, `T` are
// opted in as compatible via `SliceCastable`.
template <typename Result, typename T>
Result&& SliceCast(T&& value, SliceCastable<Result, T> = {}) {
// Insist upon sizes being equal to catch mismatches.
// We assume if sizes are opted in and sizes are equal then yes, these two
// types are expected to be layout compatible and actually appear to be.
static_assert(sizeof(Result) == sizeof(T), "size mismatch");
return reinterpret_cast<Result&&>(value);
}
} // namespace internal
} // namespace experimental
} // namespace grpc_event_engine

@ -14,8 +14,9 @@
#ifndef GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
#define GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
#include <grpc/event_engine/internal/memory_allocator_impl.h>
#include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#include <stdlib.h> // for abort()
#include <algorithm>
@ -23,9 +24,6 @@
#include <type_traits>
#include <vector>
#include <grpc/event_engine/internal/memory_allocator_impl.h>
#include <grpc/slice.h>
namespace grpc_event_engine {
namespace experimental {
@ -56,8 +54,8 @@ class MemoryAllocator {
/// The object will not be usable after this call unless it's a valid
/// allocator is moved into it.
void Reset() {
if (allocator_ != nullptr) allocator_->Shutdown();
allocator_.reset();
auto a = std::move(allocator_);
if (a != nullptr) a->Shutdown();
}
/// Reserve bytes from the quota.
@ -134,7 +132,9 @@ class MemoryAllocator {
/// bytes. For a variable length request, check the returned slice length to
/// verify how much memory was allocated. Takes care of reserving memory for
/// any relevant control structures also.
grpc_slice MakeSlice(MemoryRequest request);
grpc_slice MakeSlice(MemoryRequest request) {
return allocator_->MakeSlice(request);
}
/// A C++ allocator for containers of T.
template <typename T>

@ -15,7 +15,6 @@
#define GRPC_EVENT_ENGINE_MEMORY_REQUEST_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include "absl/strings/string_view.h"
@ -46,6 +45,24 @@ class MemoryRequest {
size_t min() const { return min_; }
size_t max() const { return max_; }
bool operator==(const MemoryRequest& other) const {
return min_ == other.min_ && max_ == other.max_;
}
bool operator!=(const MemoryRequest& other) const {
return !(*this == other);
}
template <typename Sink>
friend void AbslStringify(Sink& s, const MemoryRequest& r) {
if (r.min_ == r.max_) {
s.Append(r.min_);
} else {
s.Append(r.min_);
s.Append("..");
s.Append(r.max_);
}
}
private:
size_t min_;
size_t max_;

@ -15,8 +15,9 @@
#ifndef GRPC_EVENT_ENGINE_SLICE_H
#define GRPC_EVENT_ENGINE_SLICE_H
#include <grpc/event_engine/internal/slice_cast.h>
#include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#include <string.h>
#include <cstdint>
@ -25,10 +26,6 @@
#include "absl/strings/string_view.h"
#include <grpc/event_engine/internal/slice_cast.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
// This public slice definition largely based of the internal grpc_core::Slice
// implementation. Changes to this implementation might warrant changes to the
// internal grpc_core::Slice type as well.
@ -169,6 +166,11 @@ struct CopyConstructors {
return Out(grpc_slice_from_copied_buffer(p, len));
}
static Out FromCopiedBuffer(const uint8_t* p, size_t len) {
return Out(
grpc_slice_from_copied_buffer(reinterpret_cast<const char*>(p), len));
}
template <typename Buffer>
static Out FromCopiedBuffer(const Buffer& buffer) {
return FromCopiedBuffer(reinterpret_cast<const char*>(buffer.data()),

@ -15,8 +15,12 @@
#ifndef GRPC_EVENT_ENGINE_SLICE_BUFFER_H
#define GRPC_EVENT_ENGINE_SLICE_BUFFER_H
#include <grpc/event_engine/internal/slice_cast.h>
#include <grpc/event_engine/slice.h>
#include <grpc/impl/codegen/slice.h>
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/port_platform.h>
#include <string.h>
#include <cstdint>
@ -25,13 +29,6 @@
#include "absl/strings/string_view.h"
#include "absl/utility/utility.h"
#include <grpc/event_engine/internal/slice_cast.h>
#include <grpc/event_engine/slice.h>
#include <grpc/impl/codegen/slice.h>
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
namespace grpc_event_engine {
namespace experimental {

@ -19,17 +19,15 @@
#ifndef GRPC_GRPC_H
#define GRPC_GRPC_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <grpc/byte_buffer.h>
#include <grpc/impl/connectivity_state.h> // IWYU pragma: export
#include <grpc/impl/grpc_types.h> // IWYU pragma: export
#include <grpc/impl/propagation_bits.h>
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
@ -177,12 +175,6 @@ GRPCAPI int grpc_completion_queue_thread_local_cache_flush(
GRPCAPI grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_channel* channel, int try_to_connect);
/** Number of active "external connectivity state watchers" attached to a
* channel.
* Useful for testing. **/
GRPCAPI int grpc_channel_num_external_connectivity_watchers(
grpc_channel* channel);
/** Watch for a change in connectivity state.
Once the channel connectivity state is different from last_observed_state,
tag will be enqueued on cq with success=1.
@ -368,6 +360,13 @@ GRPCAPI void grpc_call_ref(grpc_call* call);
THREAD SAFETY: grpc_call_unref is thread-compatible */
GRPCAPI void grpc_call_unref(grpc_call* call);
typedef struct grpc_call_credentials grpc_call_credentials;
/** Sets a credentials to a call. Can only be called on the client side before
grpc_call_start_batch. */
GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_credentials* creds);
/** Request notification of a new call.
Once a call is received, a notification tagged with \a tag_new is added to
\a cq_for_notification. \a call, \a details and \a request_metadata are

@ -0,0 +1,95 @@
//
//
// 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.
//
//
#ifndef GRPC_GRPC_AUDIT_LOGGING_H
#define GRPC_GRPC_AUDIT_LOGGING_H
#include <grpc/support/json.h>
#include <grpc/support/port_platform.h>
#include <memory>
#include <string>
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
namespace grpc_core {
namespace experimental {
// The class containing the context for an audited RPC.
class AuditContext {
public:
AuditContext(absl::string_view rpc_method, absl::string_view principal,
absl::string_view policy_name, absl::string_view matched_rule,
bool authorized)
: rpc_method_(rpc_method),
principal_(principal),
policy_name_(policy_name),
matched_rule_(matched_rule),
authorized_(authorized) {}
absl::string_view rpc_method() const { return rpc_method_; }
absl::string_view principal() const { return principal_; }
absl::string_view policy_name() const { return policy_name_; }
absl::string_view matched_rule() const { return matched_rule_; }
bool authorized() const { return authorized_; }
private:
absl::string_view rpc_method_;
absl::string_view principal_;
absl::string_view policy_name_;
absl::string_view matched_rule_;
bool authorized_;
};
// This base class for audit logger implementations.
class AuditLogger {
public:
virtual ~AuditLogger() = default;
virtual absl::string_view name() const = 0;
virtual void Log(const AuditContext& audit_context) = 0;
};
// This is the base class for audit logger factory implementations.
class AuditLoggerFactory {
public:
class Config {
public:
virtual ~Config() = default;
virtual absl::string_view name() const = 0;
virtual std::string ToString() const = 0;
};
virtual ~AuditLoggerFactory() = default;
virtual absl::string_view name() const = 0;
virtual absl::StatusOr<std::unique_ptr<Config>> ParseAuditLoggerConfig(
const Json& json) = 0;
virtual std::unique_ptr<AuditLogger> CreateAuditLogger(
std::unique_ptr<AuditLoggerFactory::Config>) = 0;
};
// Registers an audit logger factory. This should only be called during
// initialization.
void RegisterAuditLoggerFactory(std::unique_ptr<AuditLoggerFactory> factory);
} // namespace experimental
} // namespace grpc_core
#endif // GRPC_GRPC_AUDIT_LOGGING_H

@ -0,0 +1,97 @@
//
//
// 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.
//
//
#ifndef GRPC_GRPC_CRL_PROVIDER_H
#define GRPC_GRPC_CRL_PROVIDER_H
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/port_platform.h>
#include <memory>
#include <string>
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
namespace grpc_core {
namespace experimental {
// Opaque representation of a CRL. Must be thread safe.
class Crl {
public:
static absl::StatusOr<std::unique_ptr<Crl>> Parse(
absl::string_view crl_string);
virtual ~Crl() = default;
virtual absl::string_view Issuer() = 0;
};
// Information about a certificate to be used to fetch its associated CRL. Must
// be thread safe.
class CertificateInfo {
public:
virtual ~CertificateInfo() = default;
virtual absl::string_view Issuer() const = 0;
virtual absl::string_view AuthorityKeyIdentifier() const = 0;
};
// The base class for CRL Provider implementations.
// CrlProviders can be passed in as a way to supply CRLs during handshakes.
// CrlProviders must be thread safe. They are on the critical path of gRPC
// creating a connection and doing a handshake, so the implementation of
// `GetCrl` should be very fast. It is suggested to have an in-memory map of
// CRLs for quick lookup and return, and doing expensive updates to this map
// asynchronously.
class CrlProvider {
public:
virtual ~CrlProvider() = default;
// Get the CRL associated with a certificate. Read-only.
virtual std::shared_ptr<Crl> GetCrl(
const CertificateInfo& certificate_info) = 0;
};
absl::StatusOr<std::shared_ptr<CrlProvider>> CreateStaticCrlProvider(
absl::Span<const std::string> crls);
#if !defined(__Fuchsia__)
// Creates a CRL Provider that periodically and asynchronously reloads a
// directory. The refresh_duration minimum is 60 seconds. The
// reload_error_callback provides a way for the user to specifically log or
// otherwise notify of errors during reloading. Since reloading is asynchronous
// and not on the main codepath, the grpc process will continue to run through
// reloading errors, so this mechanism is an important way to provide signals to
// your monitoring and alerting setup.
absl::StatusOr<std::shared_ptr<CrlProvider>> CreateDirectoryReloaderCrlProvider(
absl::string_view directory, std::chrono::seconds refresh_duration,
std::function<void(absl::Status)> reload_error_callback);
#endif // !defined(__Fuchsia__)
} // namespace experimental
} // namespace grpc_core
// TODO(gtcooke94) - Mark with api macro when all wrapped languages support C++
// in core APIs
/**
* EXPERIMENTAL API - Subject to change
*
* Sets the crl provider in the options.
*/
void grpc_tls_credentials_options_set_crl_provider(
grpc_tls_credentials_options* options,
std::shared_ptr<grpc_core::experimental::CrlProvider> provider);
#endif /* GRPC_GRPC_CRL_PROVIDER_H */

@ -19,9 +19,8 @@
#ifndef GRPC_GRPC_CRONET_H
#define GRPC_GRPC_CRONET_H
#include <grpc/support/port_platform.h>
#include <grpc/grpc.h>
#include <grpc/support/port_platform.h>
#ifdef __cplusplus
extern "C" {

@ -19,12 +19,10 @@
#ifndef GRPC_GRPC_POSIX_H
#define GRPC_GRPC_POSIX_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <grpc/grpc.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/support/port_platform.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {

File diff suppressed because it is too large Load Diff

@ -0,0 +1,28 @@
// 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.
#ifndef GRPC_IMPL_CALL_H
#define GRPC_IMPL_CALL_H
#include <grpc/grpc.h>
#include <grpc/support/port_platform.h>
#include "absl/functional/any_invocable.h"
// Run a callback in the call's EventEngine.
// Internal-only
void grpc_call_run_in_event_engine(const grpc_call* call,
absl::AnyInvocable<void()> cb);
#endif /* GRPC_IMPL_CALL_H */

@ -0,0 +1,407 @@
// 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.
#ifndef GRPC_IMPL_CHANNEL_ARG_NAMES_H
#define GRPC_IMPL_CHANNEL_ARG_NAMES_H
// IWYU pragma: private, include <grpc/grpc.h>
// IWYU pragma: friend "src/.*"
// IWYU pragma: friend "test/.*"
/** \defgroup grpc_arg_keys
* Channel argument keys.
* \{
*/
/** If non-zero, enable census for tracing and stats collection. */
#define GRPC_ARG_ENABLE_CENSUS "grpc.census"
/** If non-zero, enable load reporting. */
#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting"
/** If non-zero, call metric recording is enabled. */
#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \
"grpc.server_call_metric_recording"
/** Request that optional features default to off (regardless of what they
usually default to) - to enable tight control over what gets enabled */
#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack"
/** Maximum number of concurrent incoming streams to allow on a http2
connection. Int valued. */
#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams"
/** Maximum message length that the channel can receive. Int valued, bytes.
-1 means unlimited. */
#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length"
/** \deprecated For backward compatibility.
* Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */
#define GRPC_ARG_MAX_MESSAGE_LENGTH GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
/** Maximum message length that the channel can send. Int valued, bytes.
-1 means unlimited. */
#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length"
/** Maximum time that a channel may have no outstanding rpcs, after which the
* server will close the connection. Int valued, milliseconds. INT_MAX means
* unlimited. */
#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms"
/** Maximum time that a channel may exist. Int valued, milliseconds.
* INT_MAX means unlimited. */
#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms"
/** Grace period after the channel reaches its max age. Int valued,
milliseconds. INT_MAX means unlimited. */
#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms"
/** Timeout after the last RPC finishes on the client channel at which the
* channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means
* unlimited. The default value is 30 minutes and the min value is 1 second. */
#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms"
/** Enable/disable support for per-message compression. Defaults to 1, unless
GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */
#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression"
/** Experimental Arg. Enable/disable support for per-message decompression.
Defaults to 1. If disabled, decompression will not be performed and the
application will see the compressed message in the byte buffer. */
#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \
"grpc.per_message_decompression"
/** Initial stream ID for http2 transports. Int valued. */
#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \
"grpc.http2.initial_sequence_number"
/** Amount to read ahead on individual streams. Defaults to 64kb, larger
values can help throughput on high-latency connections.
NOTE: at some point we'd like to auto-tune this, and this parameter
will become a no-op. Int valued, bytes. */
#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes"
/** How much memory to use for hpack decoding. Int valued, bytes. */
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \
"grpc.http2.hpack_table_size.decoder"
/** How much memory to use for hpack encoding. Int valued, bytes. */
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \
"grpc.http2.hpack_table_size.encoder"
/** How big a frame are we willing to receive via HTTP2.
Min 16384, max 16777215. Larger values give lower CPU usage for large
messages, but more head of line blocking for small messages. */
#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size"
/** Should BDP probing be performed? */
#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe"
/** (DEPRECATED) Does not have any effect.
Earlier, this arg configured the minimum time between successive ping frames
without receiving any data/header frame, Int valued, milliseconds. This put
unnecessary constraints on the configuration of keepalive pings,
requiring users to set this channel arg along with
GRPC_ARG_KEEPALIVE_TIME_MS. This arg also limited the activity of the other
source of pings in gRPC Core - BDP pings, but BDP pings are only sent when
there is receive-side data activity, making this arg unuseful for BDP pings
too. */
#define GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS \
"grpc.http2.min_time_between_pings_ms"
/** Minimum allowed time between a server receiving successive ping frames
without sending any data/header frame. Int valued, milliseconds
*/
#define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \
"grpc.http2.min_ping_interval_without_data_ms"
/** Maximum time to allow a request to be:
(1) received by the server, but
(2) not requested by a RequestCall (in the completion queue based API)
before the request is cancelled */
#define GRPC_ARG_SERVER_MAX_UNREQUESTED_TIME_IN_SERVER_SECONDS \
"grpc.server_max_unrequested_time_in_server"
/** Channel arg to override the http2 :scheme header */
#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
/** How many pings can the client send before needing to send a data/header
frame? (0 indicates that an infinite number of pings can be sent without
sending a data frame or header frame).
If experiment "max_pings_wo_data_throttle" is enabled, instead of pings being
completely blocked, they are throttled. */
#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \
"grpc.http2.max_pings_without_data"
/** How many misbehaving pings the server can bear before sending goaway and
closing the transport? (0 indicates that the server can bear an infinite
number of misbehaving pings) */
#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes"
/** How much data are we willing to queue up per stream if
GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */
#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
/** Should we allow receipt of true-binary data on http2 connections?
Defaults to on (1) */
#define GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY "grpc.http2.true_binary"
/** An experimental channel arg which determines whether the preferred crypto
* frame size http2 setting sent to the peer at startup. If set to 0 (false
* - default), the preferred frame size is not sent to the peer. Otherwise it
* sends a default preferred crypto frame size value of 4GB to the peer at
* the startup of each connection. */
#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \
"grpc.experimental.http2.enable_preferred_frame_size"
/** After a duration of this time the client/server pings its peer to see if the
transport is still alive. Int valued, milliseconds. */
#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms"
/** After waiting for a duration of this time, if the keepalive ping sender does
not receive the ping ack, it will close the transport. Int valued,
milliseconds. */
#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms"
/** Is it permissible to send keepalive pings from the client without any
outstanding streams. Int valued, 0(false)/1(true). */
#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \
"grpc.keepalive_permit_without_calls"
/** Default authority to pass if none specified on call construction. A string.
* */
#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
/** Primary user agent: goes at the start of the user-agent metadata
sent on each request. A string. */
#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent"
/** Secondary user agent: goes at the end of the user-agent metadata
sent on each request. A string. */
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
/** The minimum time between subsequent connection attempts, in ms */
#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms"
/** The maximum time between subsequent connection attempts, in ms */
#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms"
/** The time between the first and second connection attempts, in ms */
#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \
"grpc.initial_reconnect_backoff_ms"
/** Minimum amount of time between DNS resolutions, in ms */
#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \
"grpc.dns_min_time_between_resolutions_ms"
/** The timeout used on servers for finishing handshaking on an incoming
connection. Defaults to 120 seconds. */
#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms"
/** This *should* be used for testing only.
The caller of the secure_channel_create functions may override the target
name used for SSL host name checking using this channel argument which is of
type \a GRPC_ARG_STRING. If this argument is not specified, the name used
for SSL host name checking will be the target parameter (assuming that the
secure channel is an SSL channel). If this parameter is specified and the
underlying is not an SSL channel, it will just be ignored. */
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
/** If non-zero, a pointer to a session cache (a pointer of type
grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch
an appropriate pointer arg vtable) */
#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache"
/** If non-zero, it will determine the maximum frame size used by TSI's frame
* protector.
*/
#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size"
/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the
max sum of all metadata key-value entries in a batch of headers. Some random
sample of requests between this limit and
`GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum
of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set).
*/
#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size"
/** Maximum metadata size (hard limit), in bytes. Note this limit applies to the
max sum of all metadata key-value entries in a batch of headers. All requests
exceeding this limit will be rejected. Defaults to maximum of 16 KB and
`GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */
#define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size"
/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */
#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport"
/** If non-zero, a pointer to a buffer pool (a pointer of type
* grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an
* appropriate pointer arg vtable) */
#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota"
/** If non-zero, expand wildcard addresses to a list of local addresses. */
#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs"
/** Service config data in JSON form.
This value will be ignored if the name resolver returns a service config. */
#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config"
/** Disable looking up the service config via the name resolver. */
#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \
"grpc.service_config_disable_resolution"
/** LB policy name. */
#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name"
/** Cap for ring size in the ring_hash LB policy. The min and max ring size
values set in the LB policy config will be capped to this value.
Default is 4096. */
#define GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP "grpc.lb.ring_hash.ring_size_cap"
/** The grpc_socket_mutator instance that set the socket options. A pointer. */
#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
/** The grpc_socket_factory instance to create and bind sockets. A pointer. */
#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory"
/** The maximum amount of memory used by trace events per channel trace node.
* Once the maximum is reached, subsequent events will evict the oldest events
* from the buffer. The unit for this knob is bytes. Setting it to zero causes
* channel tracing to be disabled. */
#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \
"grpc.max_channel_trace_event_memory_per_node"
/** If non-zero, gRPC library will track stats and information at at per channel
* level. Disabling channelz naturally disables channel tracing. The default
* is for channelz to be enabled. */
#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz"
/** If non-zero, Cronet transport will coalesce packets to fewer frames
* when possible. */
#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
"grpc.use_cronet_packet_coalescing"
/** Channel arg (integer) setting how large a slice to try and read from the
wire each time recvmsg (or equivalent) is called **/
#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size"
/** Note this is not a "channel arg" key. This is the default slice size to use
* when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE
* channel arg is unspecified. */
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \
"grpc.experimental.tcp_min_read_chunk_size"
#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \
"grpc.experimental.tcp_max_read_chunk_size"
/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By
default, it is disabled. */
#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \
"grpc.experimental.tcp_tx_zerocopy_enabled"
/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By
default, this is set to 16KB. */
#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \
"grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold"
/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending
calls to tcp_write() using zerocopy. A tcp_write() is considered pending
until the kernel performs the zerocopy-done callback for all sendmsg() calls
issued by the tcp_write(). By default, this is set to 4. */
#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \
"grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends"
/* Overrides the TCP socket receive buffer size, SO_RCVBUF. */
#define GRPC_ARG_TCP_RECEIVE_BUFFER_SIZE "grpc.tcp_receive_buffer_size"
/* Timeout in milliseconds to use for calls to the grpclb load balancer.
If 0 or unset, the balancer calls will have no deadline. */
#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms"
/* Specifies the xDS bootstrap config as a JSON string.
FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION.
This option allows controlling the bootstrap configuration on a
per-channel basis, which is useful in tests. However, this results
in having a separate xDS client instance per channel rather than
using the global instance, which is not the intended way to use xDS.
Currently, this will (a) add unnecessary load on the xDS server and
(b) break use of CSDS, and there may be additional side effects in
the future. */
#define GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG \
"grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config"
/* Timeout in milliseconds to wait for the serverlist from the grpclb load
balancer before using fallback backend addresses from the resolver.
If 0, enter fallback mode immediately. Default value is 10000. */
#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms"
/* Experimental Arg. Channel args to be used for the control-plane channel
* created to the grpclb load balancers. This is a pointer arg whose value is a
* grpc_channel_args object. If unset, most channel args from the parent channel
* will be propagated to the grpclb channel. */
#define GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS \
"grpc.experimental.grpclb_channel_args"
/* Timeout in milliseconds to wait for the child of a specific priority to
complete its initial connection attempt before the priority LB policy fails
over to the next priority. Default value is 10 seconds. */
#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \
"grpc.priority_failover_timeout_ms"
/** If non-zero, grpc server's cronet compression workaround will be enabled */
#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \
"grpc.workaround.cronet_compression"
/** String defining the optimization target for a channel.
Can be: "latency" - attempt to minimize latency at the cost of throughput
"blend" - try to balance latency and throughput
"throughput" - attempt to maximize throughput at the expense of
latency
Defaults to "blend". In the current implementation "blend" is equivalent to
"latency". */
#define GRPC_ARG_OPTIMIZATION_TARGET "grpc.optimization_target"
/** Enables retry functionality. Defaults to true. When enabled,
transparent retries will be performed as appropriate, and configurable
retries are enabled when they are configured via the service config.
For details, see:
https://github.com/grpc/proposal/blob/master/A6-client-retries.md
NOTE: Hedging functionality is not yet implemented, so those
fields in the service config will currently be ignored. See
also the GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING arg below.
*/
#define GRPC_ARG_ENABLE_RETRIES "grpc.enable_retries"
/** Enables hedging functionality, as described in:
https://github.com/grpc/proposal/blob/master/A6-client-retries.md
Default is currently false, since this functionality is not yet
fully implemented.
NOTE: This channel arg is experimental and will eventually be removed.
Once hedging functionality has been implemented and proves stable,
this arg will be removed, and the hedging functionality will
be enabled via the GRPC_ARG_ENABLE_RETRIES arg above. */
#define GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING "grpc.experimental.enable_hedging"
/** Per-RPC retry buffer size, in bytes. Default is 256 KiB. */
#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size"
/** Channel arg that carries the bridged objective c object for custom metrics
* logging filter. */
#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context"
/** If non-zero, client authority filter is disabled for the channel */
#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \
"grpc.disable_client_authority_filter"
/** If set to zero, disables use of http proxies. Enabled by default. */
#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy"
/** Channel arg to set http proxy per channel. If set, the channel arg
* value will be preferred over the environment variable settings. */
#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy"
/** Specifies an HTTP proxy to use for individual addresses.
* The proxy must be specified as an IP address, not a DNS name.
* If set, the channel arg value will be preferred over the environment
* variable settings. */
#define GRPC_ARG_ADDRESS_HTTP_PROXY "grpc.address_http_proxy"
/** Comma separated list of addresses or address ranges that are behind the
* address HTTP proxy.
*/
#define GRPC_ARG_ADDRESS_HTTP_PROXY_ENABLED_ADDRESSES \
"grpc.address_http_proxy_enabled_addresses"
/** If set to non zero, surfaces the user agent string to the server. User
agent is surfaced by default. */
#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent"
/** If set, inhibits health checking (which may be enabled via the
* service config.) */
#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking"
/** If enabled, the channel's DNS resolver queries for SRV records.
* This is useful only when using the "grpclb" load balancing policy,
* as described in the following documents:
* https://github.com/grpc/proposal/blob/master/A5-grpclb-in-dns.md
* https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md
* https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md
* Note that this works only with the "ares" DNS resolver; it isn't supported
* by the "native" DNS resolver. */
#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries"
/** If set, determines an upper bound on the number of milliseconds that the
* c-ares based DNS resolver will wait on queries before cancelling them.
* The default value is 120,000. Setting this to "0" will disable the
* overall timeout entirely. Note that this doesn't include internal c-ares
* timeouts/backoff/retry logic, and so the actual DNS resolution may time out
* sooner than the value specified here. */
#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout"
/** If set, uses a local subchannel pool within the channel. Otherwise, uses the
* global subchannel pool. */
#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool"
/** gRPC Objective-C channel pooling domain string. */
#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain"
/** gRPC Objective-C channel pooling id. */
#define GRPC_ARG_CHANNEL_ID "grpc.channel_id"
/** Channel argument for grpc_authorization_policy_provider. If present, enables
gRPC authorization check. */
#define GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER \
"grpc.authorization_policy_provider"
/** EXPERIMENTAL. Updates to a server's configuration from a config fetcher (for
* example, listener updates from xDS) cause all older connections to be
* gracefully shut down (i.e., "drained") with a grace period configured by this
* channel arg. Int valued, milliseconds. Defaults to 10 minutes.*/
#define GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS \
"grpc.experimental.server_config_change_drain_grace_time_ms"
/** Configure the Differentiated Services Code Point used on outgoing packets.
* Integer value ranging from 0 to 63. */
#define GRPC_ARG_DSCP "grpc.dscp"
/** Connection Attempt Delay for use in Happy Eyeballs, in milliseconds.
* Defaults to 250ms. */
#define GRPC_ARG_HAPPY_EYEBALLS_CONNECTION_ATTEMPT_DELAY_MS \
"grpc.happy_eyeballs_connection_attempt_delay_ms"
/** It accepts a MemoryAllocatorFactory as input and If specified, it forces
* the default event engine to use memory allocators created using the provided
* factory. */
#define GRPC_ARG_EVENT_ENGINE_USE_MEMORY_ALLOCATOR_FACTORY \
"grpc.event_engine_use_memory_allocator_factory"
/** Configure the max number of allowed incoming connections to the server.
* If unspecified, it is unlimited */
#define GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS \
"grpc.max_allowed_incoming_connections"
/** Configure per-channel or per-server stats plugins. */
#define GRPC_ARG_EXPERIMENTAL_STATS_PLUGINS "grpc.experimental.stats_plugins"
/** If non-zero, allow security frames to be sent and received. */
#define GRPC_ARG_SECURITY_FRAME_ALLOWED "grpc.security_frame_allowed"
/** \} */
#endif /* GRPC_IMPL_CHANNEL_ARG_NAMES_H */

@ -21,14 +21,13 @@
// IWYU pragma: private, include <grpc/grpc.h>
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/compression_types.h>
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
@ -133,354 +132,6 @@ typedef struct {
grpc_arg* args;
} grpc_channel_args;
/** \defgroup grpc_arg_keys
* Channel argument keys.
* \{
*/
/** If non-zero, enable census for tracing and stats collection. */
#define GRPC_ARG_ENABLE_CENSUS "grpc.census"
/** If non-zero, enable load reporting. */
#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting"
/** If non-zero, call metric recording is enabled. */
#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \
"grpc.server_call_metric_recording"
/** Request that optional features default to off (regardless of what they
usually default to) - to enable tight control over what gets enabled */
#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack"
/** Maximum number of concurrent incoming streams to allow on a http2
connection. Int valued. */
#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams"
/** Maximum message length that the channel can receive. Int valued, bytes.
-1 means unlimited. */
#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length"
/** \deprecated For backward compatibility.
* Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */
#define GRPC_ARG_MAX_MESSAGE_LENGTH GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
/** Maximum message length that the channel can send. Int valued, bytes.
-1 means unlimited. */
#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length"
/** Maximum time that a channel may have no outstanding rpcs, after which the
* server will close the connection. Int valued, milliseconds. INT_MAX means
* unlimited. */
#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms"
/** Maximum time that a channel may exist. Int valued, milliseconds.
* INT_MAX means unlimited. */
#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms"
/** Grace period after the channel reaches its max age. Int valued,
milliseconds. INT_MAX means unlimited. */
#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms"
/** Timeout after the last RPC finishes on the client channel at which the
* channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means
* unlimited. The default value is 30 minutes and the min value is 1 second. */
#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms"
/** Enable/disable support for per-message compression. Defaults to 1, unless
GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */
#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression"
/** Experimental Arg. Enable/disable support for per-message decompression.
Defaults to 1. If disabled, decompression will not be performed and the
application will see the compressed message in the byte buffer. */
#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \
"grpc.per_message_decompression"
/** Enable/disable support for deadline checking. Defaults to 1, unless
GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0 */
#define GRPC_ARG_ENABLE_DEADLINE_CHECKS "grpc.enable_deadline_checking"
/** Initial stream ID for http2 transports. Int valued. */
#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \
"grpc.http2.initial_sequence_number"
/** Amount to read ahead on individual streams. Defaults to 64kb, larger
values can help throughput on high-latency connections.
NOTE: at some point we'd like to auto-tune this, and this parameter
will become a no-op. Int valued, bytes. */
#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes"
/** How much memory to use for hpack decoding. Int valued, bytes. */
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \
"grpc.http2.hpack_table_size.decoder"
/** How much memory to use for hpack encoding. Int valued, bytes. */
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \
"grpc.http2.hpack_table_size.encoder"
/** How big a frame are we willing to receive via HTTP2.
Min 16384, max 16777215. Larger values give lower CPU usage for large
messages, but more head of line blocking for small messages. */
#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size"
/** Should BDP probing be performed? */
#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe"
/** (DEPRECATED) Does not have any effect.
Earlier, this arg configured the minimum time between successive ping frames
without receiving any data/header frame, Int valued, milliseconds. This put
unnecessary constraints on the configuration of keepalive pings,
requiring users to set this channel arg along with
GRPC_ARG_KEEPALIVE_TIME_MS. This arg also limited the activity of the other
source of pings in gRPC Core - BDP pings, but BDP pings are only sent when
there is receive-side data activity, making this arg unuseful for BDP pings
too. */
#define GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS \
"grpc.http2.min_time_between_pings_ms"
/** Minimum allowed time between a server receiving successive ping frames
without sending any data/header frame. Int valued, milliseconds
*/
#define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \
"grpc.http2.min_ping_interval_without_data_ms"
/** Channel arg to override the http2 :scheme header */
#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
/** How many pings can the client send before needing to send a
data/header frame? (0 indicates that an infinite number of
pings can be sent without sending a data frame or header frame) */
#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \
"grpc.http2.max_pings_without_data"
/** How many misbehaving pings the server can bear before sending goaway and
closing the transport? (0 indicates that the server can bear an infinite
number of misbehaving pings) */
#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes"
/** How much data are we willing to queue up per stream if
GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */
#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
/** Should we allow receipt of true-binary data on http2 connections?
Defaults to on (1) */
#define GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY "grpc.http2.true_binary"
/** An experimental channel arg which determines whether the preferred crypto
* frame size http2 setting sent to the peer at startup. If set to 0 (false
* - default), the preferred frame size is not sent to the peer. Otherwise it
* sends a default preferred crypto frame size value of 4GB to the peer at
* the startup of each connection. */
#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \
"grpc.experimental.http2.enable_preferred_frame_size"
/** After a duration of this time the client/server pings its peer to see if the
transport is still alive. Int valued, milliseconds. */
#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms"
/** After waiting for a duration of this time, if the keepalive ping sender does
not receive the ping ack, it will close the transport. Int valued,
milliseconds. */
#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms"
/** Is it permissible to send keepalive pings from the client without any
outstanding streams. Int valued, 0(false)/1(true). */
#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \
"grpc.keepalive_permit_without_calls"
/** Default authority to pass if none specified on call construction. A string.
* */
#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
/** Primary user agent: goes at the start of the user-agent metadata
sent on each request. A string. */
#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent"
/** Secondary user agent: goes at the end of the user-agent metadata
sent on each request. A string. */
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
/** The minimum time between subsequent connection attempts, in ms */
#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms"
/** The maximum time between subsequent connection attempts, in ms */
#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms"
/** The time between the first and second connection attempts, in ms */
#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \
"grpc.initial_reconnect_backoff_ms"
/** Minimum amount of time between DNS resolutions, in ms */
#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \
"grpc.dns_min_time_between_resolutions_ms"
/** The timeout used on servers for finishing handshaking on an incoming
connection. Defaults to 120 seconds. */
#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms"
/** This *should* be used for testing only.
The caller of the secure_channel_create functions may override the target
name used for SSL host name checking using this channel argument which is of
type \a GRPC_ARG_STRING. If this argument is not specified, the name used
for SSL host name checking will be the target parameter (assuming that the
secure channel is an SSL channel). If this parameter is specified and the
underlying is not an SSL channel, it will just be ignored. */
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
/** If non-zero, a pointer to a session cache (a pointer of type
grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch
an appropriate pointer arg vtable) */
#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache"
/** If non-zero, it will determine the maximum frame size used by TSI's frame
* protector.
*/
#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size"
/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the
max sum of all metadata key-value entries in a batch of headers. Some random
sample of requests between this limit and
`GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum
of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set).
*/
#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size"
/** Maximum metadata size (hard limit), in bytes. Note this limit applies to the
max sum of all metadata key-value entries in a batch of headers. All requests
exceeding this limit will be rejected. Defaults to maximum of 16 KB and
`GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */
#define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size"
/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */
#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport"
/** If non-zero, a pointer to a buffer pool (a pointer of type
* grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an
* appropriate pointer arg vtable) */
#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota"
/** If non-zero, expand wildcard addresses to a list of local addresses. */
#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs"
/** Service config data in JSON form.
This value will be ignored if the name resolver returns a service config. */
#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config"
/** Disable looking up the service config via the name resolver. */
#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \
"grpc.service_config_disable_resolution"
/** LB policy name. */
#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name"
/** Cap for ring size in the ring_hash LB policy. The min and max ring size
values set in the LB policy config will be capped to this value.
Default is 4096. */
#define GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP "grpc.lb.ring_hash.ring_size_cap"
/** The grpc_socket_mutator instance that set the socket options. A pointer. */
#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
/** The grpc_socket_factory instance to create and bind sockets. A pointer. */
#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory"
/** The maximum amount of memory used by trace events per channel trace node.
* Once the maximum is reached, subsequent events will evict the oldest events
* from the buffer. The unit for this knob is bytes. Setting it to zero causes
* channel tracing to be disabled. */
#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \
"grpc.max_channel_trace_event_memory_per_node"
/** If non-zero, gRPC library will track stats and information at at per channel
* level. Disabling channelz naturally disables channel tracing. The default
* is for channelz to be enabled. */
#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz"
/** If non-zero, Cronet transport will coalesce packets to fewer frames
* when possible. */
#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
"grpc.use_cronet_packet_coalescing"
/** Channel arg (integer) setting how large a slice to try and read from the
wire each time recvmsg (or equivalent) is called **/
#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size"
/** Note this is not a "channel arg" key. This is the default slice size to use
* when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE
* channel arg is unspecified. */
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \
"grpc.experimental.tcp_min_read_chunk_size"
#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \
"grpc.experimental.tcp_max_read_chunk_size"
/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By
default, it is disabled. */
#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \
"grpc.experimental.tcp_tx_zerocopy_enabled"
/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By
default, this is set to 16KB. */
#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \
"grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold"
/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending
calls to tcp_write() using zerocopy. A tcp_write() is considered pending
until the kernel performs the zerocopy-done callback for all sendmsg() calls
issued by the tcp_write(). By default, this is set to 4. */
#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \
"grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends"
/* Timeout in milliseconds to use for calls to the grpclb load balancer.
If 0 or unset, the balancer calls will have no deadline. */
#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms"
/* Specifies the xDS bootstrap config as a JSON string.
FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION.
This option allows controlling the bootstrap configuration on a
per-channel basis, which is useful in tests. However, this results
in having a separate xDS client instance per channel rather than
using the global instance, which is not the intended way to use xDS.
Currently, this will (a) add unnecessary load on the xDS server and
(b) break use of CSDS, and there may be additional side effects in
the future. */
#define GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG \
"grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config"
/* Timeout in milliseconds to wait for the serverlist from the grpclb load
balancer before using fallback backend addresses from the resolver.
If 0, enter fallback mode immediately. Default value is 10000. */
#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms"
/* Experimental Arg. Channel args to be used for the control-plane channel
* created to the grpclb load balancers. This is a pointer arg whose value is a
* grpc_channel_args object. If unset, most channel args from the parent channel
* will be propagated to the grpclb channel. */
#define GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS \
"grpc.experimental.grpclb_channel_args"
/* Timeout in milliseconds to wait for the child of a specific priority to
complete its initial connection attempt before the priority LB policy fails
over to the next priority. Default value is 10 seconds. */
#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \
"grpc.priority_failover_timeout_ms"
/** If non-zero, grpc server's cronet compression workaround will be enabled */
#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \
"grpc.workaround.cronet_compression"
/** String defining the optimization target for a channel.
Can be: "latency" - attempt to minimize latency at the cost of throughput
"blend" - try to balance latency and throughput
"throughput" - attempt to maximize throughput at the expense of
latency
Defaults to "blend". In the current implementation "blend" is equivalent to
"latency". */
#define GRPC_ARG_OPTIMIZATION_TARGET "grpc.optimization_target"
/** Enables retry functionality. Defaults to true. When enabled,
transparent retries will be performed as appropriate, and configurable
retries are enabled when they are configured via the service config.
For details, see:
https://github.com/grpc/proposal/blob/master/A6-client-retries.md
NOTE: Hedging functionality is not yet implemented, so those
fields in the service config will currently be ignored. See
also the GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING arg below.
*/
#define GRPC_ARG_ENABLE_RETRIES "grpc.enable_retries"
/** Enables hedging functionality, as described in:
https://github.com/grpc/proposal/blob/master/A6-client-retries.md
Default is currently false, since this functionality is not yet
fully implemented.
NOTE: This channel arg is experimental and will eventually be removed.
Once hedging functionality has been implemented and proves stable,
this arg will be removed, and the hedging functionality will
be enabled via the GRPC_ARG_ENABLE_RETRIES arg above. */
#define GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING "grpc.experimental.enable_hedging"
/** Per-RPC retry buffer size, in bytes. Default is 256 KiB. */
#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size"
/** Channel arg that carries the bridged objective c object for custom metrics
* logging filter. */
#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context"
/** If non-zero, client authority filter is disabled for the channel */
#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \
"grpc.disable_client_authority_filter"
/** If set to zero, disables use of http proxies. Enabled by default. */
#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy"
/** Channel arg to set http proxy per channel. If set, the channel arg
* value will be preferred over the environment variable settings. */
#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy"
/** If set to non zero, surfaces the user agent string to the server. User
agent is surfaced by default. */
#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent"
/** If set, inhibits health checking (which may be enabled via the
* service config.) */
#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking"
/** If enabled, the channel's DNS resolver queries for SRV records.
* This is useful only when using the "grpclb" load balancing policy,
* as described in the following documents:
* https://github.com/grpc/proposal/blob/master/A5-grpclb-in-dns.md
* https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md
* https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md
* Note that this works only with the "ares" DNS resolver; it isn't supported
* by the "native" DNS resolver. */
#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries"
/** If set, determines an upper bound on the number of milliseconds that the
* c-ares based DNS resolver will wait on queries before cancelling them.
* The default value is 120,000. Setting this to "0" will disable the
* overall timeout entirely. Note that this doesn't include internal c-ares
* timeouts/backoff/retry logic, and so the actual DNS resolution may time out
* sooner than the value specified here. */
#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout"
/** If set, uses a local subchannel pool within the channel. Otherwise, uses the
* global subchannel pool. */
#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool"
/** gRPC Objective-C channel pooling domain string. */
#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain"
/** gRPC Objective-C channel pooling id. */
#define GRPC_ARG_CHANNEL_ID "grpc.channel_id"
/** Channel argument for grpc_authorization_policy_provider. If present, enables
gRPC authorization check. */
#define GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER \
"grpc.authorization_policy_provider"
/** EXPERIMENTAL. Updates to a server's configuration from a config fetcher (for
* example, listener updates from xDS) cause all older connections to be
* gracefully shut down (i.e., "drained") with a grace period configured by this
* channel arg. Int valued, milliseconds. Defaults to 10 minutes.*/
#define GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS \
"grpc.experimental.server_config_change_drain_grace_time_ms"
/** \} */
/** Result of a grpc call. If the caller satisfies the prerequisites of a
particular operation, the grpc_call_error returned will be GRPC_CALL_OK.
Receiving any other value listed here is an indication of a bug in the

@ -22,7 +22,6 @@
// IWYU pragma: private, include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#include <stddef.h>
typedef struct grpc_slice grpc_slice;
@ -74,7 +73,7 @@ struct grpc_slice {
} data;
};
#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8
#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 6
/** Represents an expandable array of slices, to be interpreted as a
single item. */

@ -0,0 +1,62 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_PASSIVE_LISTENER_H
#define GRPC_PASSIVE_LISTENER_H
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
#include <memory>
// #include <grpc/support/port_platform.h>
namespace grpc_core {
class Server;
namespace experimental {
class PassiveListenerImpl;
/// -- EXPERIMENTAL API --
/// Interface for used for Server Endpoint injection.
class PassiveListener {
public:
virtual ~PassiveListener() = default;
/// -- EXPERIMENTAL API --
///
/// Takes an Endpoint for an established connection, and treats it as if the
/// connection had been accepted by the server.
///
/// The server must be started before endpoints can be accepted.
virtual absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) = 0;
/// -- EXPERIMENTAL API --
///
/// Takes a connected file descriptor, and treats it as if the server had
/// accepted the connection itself.
///
/// Returns a failure status if the server's active EventEngine does not
/// support Endpoint creation from fds.
virtual absl::Status AcceptConnectedFd(int fd) = 0;
};
} // namespace experimental
} // namespace grpc_core
absl::Status grpc_server_add_passive_listener(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
#endif /* GRPC_PASSIVE_LISTENER_H */

@ -19,9 +19,8 @@
#ifndef GRPC_SLICE_H
#define GRPC_SLICE_H
#include <grpc/support/port_platform.h>
#include <grpc/impl/slice_type.h> // IWYU pragma: export
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
#ifdef __cplusplus

@ -19,9 +19,8 @@
#ifndef GRPC_SLICE_BUFFER_H
#define GRPC_SLICE_BUFFER_H
#include <grpc/support/port_platform.h>
#include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#ifdef __cplusplus
extern "C" {

@ -146,7 +146,7 @@ typedef enum {
GRPC_STATUS_DATA_LOSS = 15,
/** Force users to include a default branch: */
GRPC_STATUS__DO_NOT_USE = -1
GRPC_STATUS__DO_NOT_USE = 0x7fffffffu,
} grpc_status_code;
#ifdef __cplusplus

@ -20,7 +20,6 @@
#define GRPC_SUPPORT_ALLOC_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#ifdef __cplusplus

@ -79,17 +79,4 @@
#error could not determine platform for atm
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** Adds \a delta to \a *value, clamping the result to the range specified
by \a min and \a max. Returns the new value. */
gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm* value, gpr_atm delta,
gpr_atm min, gpr_atm max);
#ifdef __cplusplus
}
#endif
#endif /* GRPC_SUPPORT_ATM_H */

@ -0,0 +1,217 @@
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef GRPC_SUPPORT_JSON_H
#define GRPC_SUPPORT_JSON_H
#include <grpc/support/port_platform.h>
#include <stdint.h>
#include <map>
#include <string>
#include <utility>
#include <variant>
#include <vector>
#include "absl/strings/str_cat.h"
namespace grpc_core {
namespace experimental {
// A JSON value, which can be any one of null, boolean, number, string,
// object, or array.
class Json {
public:
// The JSON type.
enum class Type {
kNull, // No payload. Default type when using the zero-arg ctor.
kBoolean, // Use boolean() for payload.
kNumber, // Numbers are stored in string form to avoid precision
// and integer capacity issues. Use string() for payload.
kString, // Use string() for payload.
kObject, // Use object() for payload.
kArray, // Use array() for payload.
};
using Object = std::map<std::string, Json>;
using Array = std::vector<Json>;
// Factory method for kBoolean.
static Json FromBool(bool b) {
Json json;
json.value_ = b;
return json;
}
// Factory methods for kNumber.
static Json FromNumber(const std::string& str) {
Json json;
json.value_ = NumberValue{str};
return json;
}
static Json FromNumber(const char* str) {
Json json;
json.value_ = NumberValue{std::string(str)};
return json;
}
static Json FromNumber(std::string&& str) {
Json json;
json.value_ = NumberValue{std::move(str)};
return json;
}
static Json FromNumber(int32_t value) {
Json json;
json.value_ = NumberValue{absl::StrCat(value)};
return json;
}
static Json FromNumber(uint32_t value) {
Json json;
json.value_ = NumberValue{absl::StrCat(value)};
return json;
}
static Json FromNumber(int64_t value) {
Json json;
json.value_ = NumberValue{absl::StrCat(value)};
return json;
}
static Json FromNumber(uint64_t value) {
Json json;
json.value_ = NumberValue{absl::StrCat(value)};
return json;
}
static Json FromNumber(double value) {
Json json;
json.value_ = NumberValue{absl::StrCat(value)};
return json;
}
// Factory methods for kString.
static Json FromString(const std::string& str) {
Json json;
json.value_ = str;
return json;
}
static Json FromString(const char* str) {
Json json;
json.value_ = std::string(str);
return json;
}
static Json FromString(std::string&& str) {
Json json;
json.value_ = std::move(str);
return json;
}
// Factory methods for kObject.
static Json FromObject(const Object& object) {
Json json;
json.value_ = object;
return json;
}
static Json FromObject(Object&& object) {
Json json;
json.value_ = std::move(object);
return json;
}
// Factory methods for kArray.
static Json FromArray(const Array& array) {
Json json;
json.value_ = array;
return json;
}
static Json FromArray(Array&& array) {
Json json;
json.value_ = std::move(array);
return json;
}
Json() = default;
// Copyable.
Json(const Json& other) = default;
Json& operator=(const Json& other) = default;
// Moveable.
Json(Json&& other) noexcept : value_(std::move(other.value_)) {
other.value_ = std::monostate();
}
Json& operator=(Json&& other) noexcept {
value_ = std::move(other.value_);
other.value_ = std::monostate();
return *this;
}
// Returns the JSON type.
Type type() const {
struct ValueFunctor {
Json::Type operator()(const std::monostate&) { return Type::kNull; }
Json::Type operator()(bool) { return Type::kBoolean; }
Json::Type operator()(const NumberValue&) { return Type::kNumber; }
Json::Type operator()(const std::string&) { return Type::kString; }
Json::Type operator()(const Object&) { return Type::kObject; }
Json::Type operator()(const Array&) { return Type::kArray; }
};
return std::visit(ValueFunctor(), value_);
}
// Payload accessor for kBoolean.
// Must not be called for other types.
bool boolean() const { return std::get<bool>(value_); }
// Payload accessor for kNumber or kString.
// Must not be called for other types.
const std::string& string() const {
const NumberValue* num = std::get_if<NumberValue>(&value_);
if (num != nullptr) return num->value;
return std::get<std::string>(value_);
}
// Payload accessor for kObject.
// Must not be called for other types.
const Object& object() const { return std::get<Object>(value_); }
// Payload accessor for kArray.
// Must not be called for other types.
const Array& array() const { return std::get<Array>(value_); }
bool operator==(const Json& other) const { return value_ == other.value_; }
bool operator!=(const Json& other) const { return !(*this == other); }
private:
struct NumberValue {
std::string value;
bool operator==(const NumberValue& other) const {
return value == other.value;
}
};
using Value = std::variant<std::monostate, // kNull
bool, // kBoolean
NumberValue, // kNumber
std::string, // kString
Object, // kObject
Array>; // kArray
explicit Json(Value value) : value_(std::move(value)) {}
Value value_;
};
} // namespace experimental
} // namespace grpc_core
#endif // GRPC_SUPPORT_JSON_H

@ -20,7 +20,6 @@
#define GRPC_SUPPORT_LOG_H
#include <grpc/support/port_platform.h>
#include <stdarg.h>
#include <stdlib.h> /* for abort() */
@ -28,83 +27,57 @@
extern "C" {
#endif
/** GPR log API.
Usage (within grpc):
int argument1 = 3;
char* argument2 = "hello";
gpr_log(GPR_DEBUG, "format string %d", argument1);
gpr_log(GPR_INFO, "hello world");
gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */
/** The severity of a log message - use the #defines below when calling into
gpr_log to additionally supply file and line data */
grpc_absl_log to additionally supply file and line data */
typedef enum gpr_log_severity {
GPR_LOG_SEVERITY_DEBUG,
GPR_LOG_SEVERITY_INFO,
GPR_LOG_SEVERITY_ERROR
} gpr_log_severity;
/** Returns a string representation of the log severity */
GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity);
/** Macros to build log contexts at various severity levels */
#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
#define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
#define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
/** Log a message. It's advised to use GPR_xxx above to generate the context
* for each message */
GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
/**
* EXPERIMENTAL. API stability not guaranteed.
* Should only be used from gRPC PHP and RUBY.
* This will be removed once Ruby and PHP can start using C++ APIs.
* We would replace this with calls to absl LOG functions.
* grpc_absl_log is equivalent to
* ABSL_LOG(severity) << message_str;
* **/
GPRAPI void grpc_absl_log(const char* file, int line, gpr_log_severity severity,
const char* message_str);
GPRAPI int gpr_should_log(gpr_log_severity severity);
/**
* EXPERIMENTAL. API stability not guaranteed.
* Should only be used from gRPC PHP and RUBY.
* This will be removed once Ruby and PHP can start using C++ APIs.
* We would replace this with calls to absl LOG functions.
* grpc_absl_log_int is equivalent to
* ABSL_LOG(severity) << message_str << num;
* **/
GPRAPI void grpc_absl_log_int(const char* file, int line,
gpr_log_severity severity,
const char* message_str, intptr_t num);
GPRAPI void gpr_log_message(const char* file, int line,
gpr_log_severity severity, const char* message);
/** Set global log verbosity */
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
/**
* EXPERIMENTAL. API stability not guaranteed.
* Should only be used from gRPC PHP and RUBY.
* This will be removed once Ruby and PHP can start using C++ APIs.
* We would replace this with calls to absl LOG functions.
* grpc_absl_log_str is equivalent to
* ABSL_LOG(severity) << message_str1 << message_str2;
* **/
GPRAPI void grpc_absl_log_str(const char* file, int line,
gpr_log_severity severity,
const char* message_str1,
const char* message_str2);
GPRAPI void gpr_log_verbosity_init(void);
/** Log overrides: applications can use this API to intercept logging calls
and use their own implementations */
struct gpr_log_func_args {
const char* file;
int line;
gpr_log_severity severity;
const char* message;
};
typedef struct gpr_log_func_args gpr_log_func_args;
typedef void (*gpr_log_func)(gpr_log_func_args* args);
GPRAPI void gpr_set_log_function(gpr_log_func func);
GPRAPI void gpr_assertion_failed(const char* filename, int line,
const char* message) GPR_ATTRIBUTE_NORETURN;
/** abort() the process if x is zero, having written a line to the log.
Intended for internal invariants. If the error can be recovered from,
without the possibility of corruption, or might best be reflected via
an exception in a higher-level language, consider returning error code. */
#define GPR_ASSERT(x) \
do { \
if (GPR_UNLIKELY(!(x))) { \
gpr_assertion_failed(__FILE__, __LINE__, #x); \
} \
} while (0)
#ifndef NDEBUG
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(x)
#else
#define GPR_DEBUG_ASSERT(x)
#endif
#ifdef __cplusplus
}
#endif

@ -0,0 +1,66 @@
// Copyright 2024 The gRPC Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_SUPPORT_METRICS_H
#define GRPC_SUPPORT_METRICS_H
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/support/port_platform.h>
#include "absl/strings/string_view.h"
namespace grpc_core {
namespace experimental {
// Configuration (scope) for a specific client channel to be used for stats
// plugins. For some components like XdsClient where the same XdsClient instance
// can be shared across multiple channels that share the same target name but
// have different default authority and channel arguments, the component uses
// the configuration from the first channel that uses this XdsClient instance to
// determine StatsPluginChannelScope.
class StatsPluginChannelScope {
public:
StatsPluginChannelScope(
absl::string_view target, absl::string_view default_authority,
const grpc_event_engine::experimental::EndpointConfig& args)
: target_(target), default_authority_(default_authority), args_(args) {}
/// Returns the target used for creating the channel in the canonical form.
/// (Canonicalized target definition -
/// https://github.com/grpc/proposal/blob/master/A66-otel-stats.md)
absl::string_view target() const { return target_; }
/// Returns the default authority for the channel.
absl::string_view default_authority() const { return default_authority_; }
/// Returns channel arguments. THIS METHOD IS EXPERIMENTAL.
// TODO(roth, ctiller, yashkt): Find a better representation for
// channel args before de-experimentalizing this API.
const grpc_event_engine::experimental::EndpointConfig& experimental_args()
const {
return args_;
}
private:
// Disable copy constructor and copy-assignment operator.
StatsPluginChannelScope(const StatsPluginChannelScope&) = delete;
StatsPluginChannelScope& operator=(const StatsPluginChannelScope&) = delete;
absl::string_view target_;
absl::string_view default_authority_;
const grpc_event_engine::experimental::EndpointConfig& args_;
};
} // namespace experimental
} // namespace grpc_core
#endif /* GRPC_SUPPORT_METRICS_H */

@ -19,14 +19,6 @@
#ifndef GRPC_SUPPORT_PORT_PLATFORM_H
#define GRPC_SUPPORT_PORT_PLATFORM_H
/*
* Define GPR_BACKWARDS_COMPATIBILITY_MODE to try harder to be ABI
* compatible with older platforms (currently only on Linux)
* Causes:
* - some libc calls to be gotten via dlsym
* - some syscalls to be made directly
*/
// [[deprecated]] attribute is only available since C++14
#if __cplusplus >= 201402L
#define GRPC_DEPRECATED(reason) [[deprecated(reason)]]
@ -53,6 +45,57 @@
#define WIN32_LEAN_AND_MEAN
#endif /* WIN32_LEAN_AND_MEAN */
// GPRC_DLL
// inspired by
// https://github.com/abseil/abseil-cpp/blob/20220623.1/absl/base/config.h#L730-L747
//
// When building gRPC as a DLL, this macro expands to `__declspec(dllexport)`
// so we can annotate symbols appropriately as being exported. When used in
// headers consuming a DLL, this macro expands to `__declspec(dllimport)` so
// that consumers know the symbol is defined inside the DLL. In all other cases,
// the macro expands to nothing.
//
// Warning: shared library support for Windows (i.e. producing DLL plus import
// library instead of a static library) is experimental. Some symbols that can
// be linked using the static library may not be available when using the
// dynamically linked library.
//
// Note: GRPC_DLL_EXPORTS is set in CMakeLists.txt when building shared
// grpc{,_unsecure}
// GRPC_DLL_IMPORTS is set by us as part of the interface for consumers of
// the DLL
#if !defined(GRPC_DLL)
#if defined(GRPC_DLL_EXPORTS)
#define GRPC_DLL __declspec(dllexport)
#elif defined(GRPC_DLL_IMPORTS)
#define GRPC_DLL __declspec(dllimport)
#else
#define GRPC_DLL
#endif // defined(GRPC_DLL_EXPORTS)
#endif
// same for gRPC++
#if !defined(GRPCXX_DLL)
#if defined(GRPCXX_DLL_EXPORTS)
#define GRPCXX_DLL __declspec(dllexport)
#elif defined(GRPCXX_DLL_IMPORTS)
#define GRPCXX_DLL __declspec(dllimport)
#else
#define GRPCXX_DLL
#endif // defined(GRPCXX_DLL_EXPORTS)
#endif
// same for GPR
#if !defined(GPR_DLL)
#if defined(GPR_DLL_EXPORTS)
#define GPR_DLL __declspec(dllexport)
#elif defined(GPR_DLL_IMPORTS)
#define GPR_DLL __declspec(dllimport)
#else
#define GPR_DLL
#endif // defined(GPR_DLL_EXPORTS)
#endif
#ifndef NOMINMAX
#define GRPC_NOMINMX_WAS_NOT_DEFINED
#define NOMINMAX
@ -68,7 +111,6 @@
#error \
"Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
#endif /* _WIN32_WINNT < 0x0600 */
#endif /* defined(_WIN32_WINNT) */
#ifdef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
#undef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
@ -81,6 +123,11 @@
#endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
#endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || \
defined(WIN32) */
#else
#define GRPC_DLL
#define GRPCXX_DLL
#define GPR_DLL
#endif /* defined(_WIN32_WINNT) */
/* Override this file with one for your platform if you need to redefine
things. */
@ -125,7 +172,6 @@
#if __ANDROID_API__ < 21
#error "Requires Android API v21 and above"
#endif
#define GPR_SUPPORT_BINDER_TRANSPORT 1
// TODO(apolcyn): re-evaluate support for c-ares
// on android after upgrading our c-ares dependency.
// See https://github.com/grpc/grpc/issues/18038.
@ -148,6 +194,12 @@
#define GPR_HAS_PTHREAD_H 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_SUPPORT_CHANNELS_FROM_FD 1
#if defined(__has_include)
#if __has_include(<android/ndk-version.h>)
#include <android/ndk-version.h>
#endif /* __has_include(<android/ndk-version.h>) */
#endif /* defined(__has_include) */
#include <linux/version.h>
#elif defined(__linux__)
#define GPR_PLATFORM_STRING "linux"
#ifndef _BSD_SOURCE
@ -225,6 +277,9 @@
#define GPR_PLATFORM_STRING "ios"
#define GPR_CPU_IPHONE 1
#define GRPC_CFSTREAM 1
#ifndef GRPC_IOS_EVENT_ENGINE_CLIENT
#define GRPC_IOS_EVENT_ENGINE_CLIENT 1
#endif /* GRPC_IOS_EVENT_ENGINE_CLIENT */
/* the c-ares resolver isn't safe to enable on iOS */
#define GRPC_ARES 0
#else /* TARGET_OS_IPHONE */
@ -447,23 +502,29 @@
#else /* _LP64 */
#define GPR_ARCH_32 1
#endif /* _LP64 */
#elif defined(__QNX__) || defined(__QNXNTO__)
#define GPR_PLATFORM_STRING "qnx"
#define GPR_CPU_POSIX 1
#define GPR_GCC_ATOMIC 1
#define GPR_POSIX_LOG 1
#define GPR_POSIX_ENV 1
#define GPR_POSIX_TMPFILE 1
#define GPR_POSIX_STAT 1
#define GPR_POSIX_STRING 1
#define GPR_POSIX_SYNC 1
#define GPR_POSIX_TIME 1
#define GPR_HAS_PTHREAD_H 1
#define GPR_GETPID_IN_UNISTD_H 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */
#define GPR_ARCH_32 1
#endif /* _LP64 */
#else
#error "Could not auto-detect platform"
#endif
#endif /* GPR_NO_AUTODETECT_PLATFORM */
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
/*
* For backward compatibility mode, reset _FORTIFY_SOURCE to prevent
* a library from having non-standard symbols such as __asprintf_chk.
* This helps non-glibc systems such as alpine using musl to find symbols.
*/
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
#undef _FORTIFY_SOURCE
#define _FORTIFY_SOURCE 0
#endif
#endif
#if defined(__has_include)
#if __has_include(<atomic>)
#define GRPC_HAS_CXX11_ATOMIC
@ -563,29 +624,6 @@ typedef unsigned __int64 uint64_t;
#define GRPC_IF_NAMETOINDEX 1
#endif
#ifndef GRPC_MUST_USE_RESULT
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
#define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
#else
#define GRPC_MUST_USE_RESULT
#define GPR_ALIGN_STRUCT(n)
#endif
#ifdef USE_STRICT_WARNING
/* When building with USE_STRICT_WARNING (which -Werror), types with this
attribute will be treated as annotated with warn_unused_result, enforcing
returned values of this type should be used.
This is added in grpc::Status in mind to address the issue where it always
has this annotation internally but OSS doesn't, sometimes causing internal
build failure. To prevent this, this is added while not introducing
a breaking change to existing user code which may not use returned values
of grpc::Status. */
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPC_MUST_USE_RESULT
#else
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING
#endif
#endif
#ifndef GRPC_UNUSED
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_UNUSED __attribute__((unused))
@ -611,6 +649,47 @@ typedef unsigned __int64 uint64_t;
#endif
#endif /* GPR_HAS_CPP_ATTRIBUTE */
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
#else
#define GPR_ALIGN_STRUCT(n)
#endif
#ifndef GRPC_MUST_USE_RESULT
#if GPR_HAS_CPP_ATTRIBUTE(nodiscard)
#define GRPC_MUST_USE_RESULT [[nodiscard]]
#elif defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
#else
#define GRPC_MUST_USE_RESULT
#endif
#ifdef USE_STRICT_WARNING
/* When building with USE_STRICT_WARNING (which -Werror), types with this
attribute will be treated as annotated with warn_unused_result, enforcing
returned values of this type should be used.
This is added in grpc::Status in mind to address the issue where it always
has this annotation internally but OSS doesn't, sometimes causing internal
build failure. To prevent this, this is added while not introducing
a breaking change to existing user code which may not use returned values
of grpc::Status. */
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPC_MUST_USE_RESULT
#else
#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING
#endif
#endif
#ifndef GRPC_REINITIALIZES
#if defined(__clang__)
#if GPR_HAS_CPP_ATTRIBUTE(clang::reinitializes)
#define GRPC_REINITIALIZES [[clang::reinitializes]]
#else
#define GRPC_REINITIALIZES
#endif
#else
#define GRPC_REINITIALIZES
#endif
#endif
#ifndef GPR_HAS_ATTRIBUTE
#ifdef __has_attribute
#define GPR_HAS_ATTRIBUTE(a) __has_attribute(a)
@ -672,6 +751,22 @@ extern void gpr_unreachable_code(const char* reason, const char* file,
#endif
#endif /* GPR_ATTRIBUTE_NOINLINE */
#ifndef GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION
#ifdef __cplusplus
#if GPR_HAS_CPP_ATTRIBUTE(clang::always_inline)
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION [[clang::always_inline]]
#elif GPR_HAS_ATTRIBUTE(always_inline)
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION __attribute__((always_inline))
#else
// TODO(ctiller): add __forceinline for MSVC
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION
#endif
#else
// Disable for C code
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION
#endif
#endif /* GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION */
#ifndef GPR_NO_UNIQUE_ADDRESS
#if GPR_HAS_CPP_ATTRIBUTE(no_unique_address)
#define GPR_NO_UNIQUE_ADDRESS [[no_unique_address]]
@ -746,6 +841,12 @@ extern void gpr_unreachable_code(const char* reason, const char* file,
#endif /* __GPR_WINDOWS */
#endif /* GRPC_ALLOW_EXCEPTIONS */
#ifdef __has_builtin
#define GRPC_HAS_BUILTIN(a) __has_builtin(a)
#else
#define GRPC_HAS_BUILTIN(a) 0
#endif
/* Use GPR_LIKELY only in cases where you are sure that a certain outcome is the
* most likely. Ideally, also collect performance numbers to justify the claim.
*/

@ -20,7 +20,6 @@
#define GRPC_SUPPORT_STRING_UTIL_H
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
#ifdef __cplusplus

@ -21,7 +21,6 @@
/* Platform-specific type declarations of gpr_mu and gpr_cv. */
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h> /* for gpr_timespec */
#ifdef __cplusplus

@ -20,7 +20,6 @@
#define GRPC_SUPPORT_SYNC_ABSEIL_H
#include <grpc/support/port_platform.h>
#include <grpc/support/sync_generic.h>
#ifdef GPR_ABSEIL_SYNC

@ -20,7 +20,6 @@
#define GRPC_SUPPORT_SYNC_CUSTOM_H
#include <grpc/support/port_platform.h>
#include <grpc/support/sync_generic.h>
/* Users defining GPR_CUSTOM_SYNC need to define the following macros. */

@ -21,17 +21,15 @@
/* Generic type definitions for gpr_sync. */
#include <grpc/support/port_platform.h>
#include <grpc/support/atm.h>
#include <grpc/support/port_platform.h>
/* gpr_event */
typedef struct {
gpr_atm state;
} gpr_event;
#define GPR_EVENT_INIT \
{ 0 }
#define GPR_EVENT_INIT {0}
/* gpr_refcount */
typedef struct {
@ -43,7 +41,6 @@ typedef struct {
gpr_atm value;
} gpr_stats_counter;
#define GPR_STATS_INIT \
{ 0 }
#define GPR_STATS_INIT {0}
#endif /* GRPC_SUPPORT_SYNC_GENERIC_H */

@ -20,10 +20,8 @@
#define GRPC_SUPPORT_SYNC_POSIX_H
#include <grpc/support/port_platform.h>
#include <pthread.h>
#include <grpc/support/sync_generic.h>
#include <pthread.h>
#ifdef GRPC_ASAN_ENABLED
/* The member |leak_checker| is used to check whether there is a memory leak

@ -20,7 +20,6 @@
#define GRPC_SUPPORT_TIME_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <time.h>

@ -21,8 +21,6 @@
#ifndef GRPCPP_ALARM_H
#define GRPCPP_ALARM_H
#include <functional>
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
#include <grpcpp/completion_queue.h>
@ -30,11 +28,24 @@
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/time.h>
#include <functional>
namespace grpc {
/// Trigger a \a CompletionQueue event, or asynchronous callback execution,
/// after some deadline.
///
/// The \a Alarm API has separate \a Set methods for CompletionQueues and
/// callbacks, but only one can be used at any given time. After an alarm has
/// been triggered or cancelled, the same Alarm object may reused.
///
/// Alarm methods are not thread-safe. Applications must ensure a strict
/// ordering between calls to \a Set and \a Cancel. This also implies that any
/// cancellation that occurs before the alarm has been set will have no effect
/// on any future \a Set calls.
class Alarm : private grpc::internal::GrpcLibrary {
public:
/// Create an unset completion queue alarm
/// Create an unset Alarm.
Alarm();
/// Destroy the given completion queue alarm, cancelling it in the process.

@ -19,8 +19,6 @@
#ifndef GRPCPP_CHANNEL_H
#define GRPCPP_CHANNEL_H
#include <memory>
#include <grpc/grpc.h>
#include <grpcpp/completion_queue.h>
#include <grpcpp/impl/call.h>
@ -30,6 +28,8 @@
#include <grpcpp/support/client_interceptor.h>
#include <grpcpp/support/config.h>
#include <memory>
struct grpc_channel;
namespace grpc {

@ -34,13 +34,8 @@
#ifndef GRPCPP_CLIENT_CONTEXT_H
#define GRPCPP_CLIENT_CONTEXT_H
#include <map>
#include <memory>
#include <string>
#include <grpc/impl/compression_types.h>
#include <grpc/impl/propagation_bits.h>
#include <grpc/support/log.h>
#include <grpcpp/impl/create_auth_context.h>
#include <grpcpp/impl/metadata_map.h>
#include <grpcpp/impl/rpc_method.h>
@ -53,6 +48,12 @@
#include <grpcpp/support/string_ref.h>
#include <grpcpp/support/time.h>
#include <map>
#include <memory>
#include <string>
#include "absl/log/absl_check.h"
struct census_context;
struct grpc_call;
@ -246,7 +247,7 @@ class ClientContext {
/// \return A multimap of initial metadata key-value pairs from the server.
const std::multimap<grpc::string_ref, grpc::string_ref>&
GetServerInitialMetadata() const {
GPR_ASSERT(initial_metadata_received_);
ABSL_CHECK(initial_metadata_received_);
return *recv_initial_metadata_.map();
}

@ -32,11 +32,8 @@
#ifndef GRPCPP_COMPLETION_QUEUE_H
#define GRPCPP_COMPLETION_QUEUE_H
#include <list>
#include <grpc/grpc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/impl/codegen/rpc_service_method.h>
#include <grpcpp/impl/codegen/status.h>
@ -46,6 +43,10 @@
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/impl/sync.h>
#include <list>
#include "absl/log/absl_check.h"
struct grpc_completion_queue;
namespace grpc {
@ -323,7 +324,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
bool ok = ev.success != 0;
void* ignored = tag;
if (tag->FinalizeResult(&ignored, &ok)) {
GPR_ASSERT(ignored == tag);
ABSL_CHECK(ignored == tag);
return ok;
}
}
@ -344,7 +345,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
bool ok = ev.success != 0;
void* ignored = tag;
// the tag must be swallowed if using TryPluck
GPR_ASSERT(!tag->FinalizeResult(&ignored, &ok));
ABSL_CHECK(!tag->FinalizeResult(&ignored, &ok));
}
/// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if
@ -361,7 +362,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
bool ok = ev.success != 0;
void* ignored = tag;
GPR_ASSERT(!tag->FinalizeResult(&ignored, &ok));
ABSL_CHECK(!tag->FinalizeResult(&ignored, &ok));
}
/// Manage state of avalanching operations : completion queue tags that

@ -19,14 +19,14 @@
#ifndef GRPCPP_CREATE_CHANNEL_H
#define GRPCPP_CREATE_CHANNEL_H
#include <memory>
#include <grpcpp/channel.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/client_interceptor.h>
#include <grpcpp/support/config.h>
#include <memory>
namespace grpc {
/// Create a new \a Channel pointing to \a target.
///

@ -1,126 +0,0 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_CREATE_CHANNEL_BINDER_H
#define GRPCPP_CREATE_CHANNEL_BINDER_H
#include <grpc/support/port_platform.h>
#ifdef GPR_ANDROID
#include <jni.h>
#include <memory>
#include "absl/strings/string_view.h"
#include <grpcpp/channel.h>
#include <grpcpp/security/binder_security_policy.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc {
namespace experimental {
/// EXPERIMENTAL Create a new \a Channel based on binder transport. The package
/// name and class name will be used identify the specific application component
/// to connect to.
///
/// \param jni_env_void Pointer to a JNIEnv structure
/// \param context The context that we will use to invoke \a bindService See
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
/// for detail.
/// \param package_name Package name of the component to be connected to
/// \param class_name Class name of the component to be connected to
/// \param security_policy Used for checking if remote component is allowed to
/// connect
std::shared_ptr<grpc::Channel> CreateBinderChannel(
void* jni_env_void, jobject context, absl::string_view package_name,
absl::string_view class_name,
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
security_policy);
/// EXPERIMENTAL Create a new \a Channel based on binder transport. The package
/// name and class name will be used identify the specific application component
/// to connect to.
///
/// \param jni_env_void Pointer to a JNIEnv structure
/// \param context The context that we will use to invoke \a bindService See
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
/// for detail.
/// \param package_name Package name of the component to be connected to
/// \param class_name Class name of the component to be connected to
/// \param security_policy Used for checking if remote component is allowed to
/// connect
/// \param args Options for channel creation.
std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
void* jni_env_void, jobject context, absl::string_view package_name,
absl::string_view class_name,
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> security_policy,
const ChannelArguments& args);
/// EXPERIMENTAL Create a new \a Channel based on binder transport.
///
/// \param jni_env_void Pointer to a JNIEnv structure
/// \param context The context that we will use to invoke \a bindService See
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
/// for detail.
/// \param uri An URI that can be parsed as an `Intent` with
/// https://developer.android.com/reference/android/content/Intent#parseUri(java.lang.String,%20int)
/// \param security_policy Used for checking if remote component is allowed to
/// connect
std::shared_ptr<grpc::Channel> CreateBinderChannel(
void* jni_env_void, jobject context, absl::string_view uri,
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
security_policy);
/// EXPERIMENTAL Create a new \a Channel based on binder transport.
///
/// \param jni_env_void Pointer to a JNIEnv structure
/// \param context The context that we will use to invoke \a bindService See
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
/// for detail.
/// \param uri An URI that can be parsed as an `Intent` with
/// https://developer.android.com/reference/android/content/Intent#parseUri(java.lang.String,%20int)
/// \param security_policy Used for checking if remote component is allowed to
/// connect
/// \param args Options for channel creation.
std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
void* jni_env_void, jobject context, absl::string_view uri,
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> security_policy,
const ChannelArguments& args);
/// EXPERIMENTAL Finds internal binder transport Java code. To create channels
/// in threads created in native code, it is required to call this function
/// once beforehand in a thread that is not created in native code.
/// See
/// https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
/// for details of this limitation.
/// Returns true when the initialization is successful.
bool InitializeBinderChannelJavaClass(void* jni_env_void);
/// EXPERIMENTAL Alternative version of `InitializeBinderChannelJavaClass(void*
/// jni_env_void)`. This version used a user-specified function to find the
/// required internal Java class. When a class is found, the `class_finder`
/// function should return a local reference to the class (jclass type). The
/// returned jclass will then be used to create global reference for gRPC to use
/// it later. After that, gRPC will DeleteLocalRef the returned local reference.
bool InitializeBinderChannelJavaClass(
void* jni_env_void, std::function<void*(std::string)> class_finder);
} // namespace experimental
} // namespace grpc
#endif
#endif // GRPCPP_CREATE_CHANNEL_BINDER_H

@ -20,12 +20,11 @@
#define GRPCPP_CREATE_CHANNEL_POSIX_H
#include <grpc/support/port_platform.h>
#include <memory>
#include <grpcpp/channel.h>
#include <grpcpp/support/channel_arguments.h>
#include <memory>
namespace grpc {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD

@ -19,28 +19,29 @@
#ifndef GRPCPP_EXT_CALL_METRIC_RECORDER_H
#define GRPCPP_EXT_CALL_METRIC_RECORDER_H
#include <grpcpp/impl/sync.h>
#include <grpcpp/support/slice.h>
#include <memory>
#include <string>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <grpcpp/impl/sync.h>
#include <grpcpp/support/slice.h>
namespace grpc {
namespace experimental {
/// Records call metrics for the purpose of load balancing.
/// During an RPC, call \a ServerContext::ExperimentalGetCallMetricRecorder()
/// method to retrive the recorder for the current call.
/// method to retrieve the recorder for the current call.
class CallMetricRecorder {
public:
virtual ~CallMetricRecorder() = default;
/// Records a call metric measurement for CPU utilization.
/// Multiple calls to this method will override the stored value.
/// Values outside of the valid range [0, 1] are ignored.
/// Values may be larger than 1.0 when the usage exceeds the reporter
/// dependent notion of soft limits.
/// Values outside of the valid range [0, infy] are ignored.
virtual CallMetricRecorder& RecordCpuUtilizationMetric(double value) = 0;
/// Records a call metric measurement for memory utilization.
@ -48,6 +49,14 @@ class CallMetricRecorder {
/// Values outside of the valid range [0, 1] are ignored.
virtual CallMetricRecorder& RecordMemoryUtilizationMetric(double value) = 0;
/// Records a call metric measurement for application specific utilization.
/// Multiple calls to this method will override the stored value.
/// Values may be larger than 1.0 when the usage exceeds the reporter
/// dependent notion of soft limits.
/// Values outside of the valid range [0, infy] are ignored.
virtual CallMetricRecorder& RecordApplicationUtilizationMetric(
double value) = 0;
/// Records a call metric measurement for queries per second.
/// Multiple calls to this method will override the stored value.
/// Values outside of the valid range [0, infy) are ignored.
@ -78,6 +87,16 @@ class CallMetricRecorder {
/// are global constants.
virtual CallMetricRecorder& RecordRequestCostMetric(string_ref name,
double value) = 0;
/// Records an application-specific opaque metric measurement.
/// Multiple calls to this method with the same name will
/// override the corresponding stored value. The lifetime of the
/// name string needs to be longer than the lifetime of the RPC
/// itself, since it's going to be sent as trailers after the RPC
/// finishes. It is assumed the strings are common names that
/// are global constants.
virtual CallMetricRecorder& RecordNamedMetric(string_ref name,
double value) = 0;
};
} // namespace experimental

@ -20,7 +20,6 @@
#define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H
#include <grpc/support/port_platform.h>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/impl/server_initializer.h>
#include <grpcpp/support/config.h>

@ -0,0 +1,113 @@
//
//
// 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.
//
//
#ifndef GRPCPP_EXT_CSM_OBSERVABILITY_H
#define GRPCPP_EXT_CSM_OBSERVABILITY_H
#include <grpc/support/port_platform.h>
#include <grpcpp/ext/otel_plugin.h>
#include <memory>
#include "absl/functional/any_invocable.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "opentelemetry/metrics/meter_provider.h"
namespace grpc {
namespace internal {
class OpenTelemetryPluginBuilderImpl;
} // namespace internal
// This object maintains state around the registered CsmObservability plugin.
// The application is responsible for retaining this object until it has closed
// all channels and servers that are recording metrics.
class CsmObservability {
public:
CsmObservability() = default;
~CsmObservability();
// Disable copy constructor and copy-assignment operator.
CsmObservability(const CsmObservability&) = delete;
CsmObservability& operator=(const CsmObservability&) = delete;
CsmObservability(CsmObservability&&) noexcept;
CsmObservability& operator=(CsmObservability&&) noexcept;
private:
bool valid_ = true;
};
// CsmObservabilityBuilder configures observability for all service mesh traffic
// for a binary running on CSM.
class CsmObservabilityBuilder {
public:
CsmObservabilityBuilder();
~CsmObservabilityBuilder();
CsmObservabilityBuilder& SetMeterProvider(
std::shared_ptr<opentelemetry::metrics::MeterProvider> meter_provider);
// If set, \a target_attribute_filter is called per channel to decide whether
// to record the target attribute on client or to replace it with "other".
// This helps reduce the cardinality on metrics in cases where many channels
// are created with different targets in the same binary (which might happen
// for example, if the channel target string uses IP addresses directly).
CsmObservabilityBuilder& SetTargetAttributeFilter(
absl::AnyInvocable<bool(absl::string_view /*target*/) const>
target_attribute_filter);
// If set, \a generic_method_attribute_filter is called per call with a
// generic method type to decide whether to record the method name or to
// replace it with "other". Non-generic or pre-registered methods remain
// unaffected. If not set, by default, generic method names are replaced with
// "other" when recording metrics.
CsmObservabilityBuilder& SetGenericMethodAttributeFilter(
absl::AnyInvocable<bool(absl::string_view /*generic_method*/) const>
generic_method_attribute_filter);
// Builds the CsmObservability plugin. The return status shows whether
// CsmObservability was successfully enabled or not.
//
// The most common way to use this API is -
//
// auto observability =
// CsmObservabilityBuilder().SetMeterProvider(provider).BuildAndRegister();
//
// The set of instruments available are -
// grpc.client.attempt.started
// grpc.client.attempt.duration
// grpc.client.attempt.sent_total_compressed_message_size
// grpc.client.attempt.rcvd_total_compressed_message_size
// grpc.server.call.started
// grpc.server.call.duration
// grpc.server.call.sent_total_compressed_message_size
// grpc.server.call.rcvd_total_compressed_message_size
absl::StatusOr<CsmObservability> BuildAndRegister();
private:
std::unique_ptr<grpc::internal::OpenTelemetryPluginBuilderImpl> builder_;
};
namespace experimental {
// TODO(yashykt): Remove this once no longer needed.
using CsmObservability GRPC_DEPRECATED("Use grpc::CsmObservability instead.") =
grpc::CsmObservability;
using CsmObservabilityBuilder GRPC_DEPRECATED(
"Use grpc::CsmObservabilityBuilder instead.") =
grpc::CsmObservabilityBuilder;
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_EXT_CSM_OBSERVABILITY_H

@ -17,25 +17,96 @@
#ifndef GRPCPP_EXT_GCP_OBSERVABILITY_H
#define GRPCPP_EXT_GCP_OBSERVABILITY_H
#include <grpc/support/port_platform.h>
#include <grpcpp/impl/grpc_library.h>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
namespace grpc {
// GcpObservability objects follow the RAII idiom and help manage the lifetime
// of gRPC Observability data exporting to GCP. `GcpObservability::Init()`
// should be invoked instead to return an `GcpObservability` instance.
// Observability data is flushed at regular intervals, and also when this
// instance goes out of scope and its destructor is invoked.
class GcpObservability {
public:
// Initialize GCP Observability for gRPC.
// This should be called before any other gRPC operations like creating a
// channel, server, credentials etc.
// The return value helps determine whether observability was
// successfully enabled or not. On success, an object of class `Observability`
// is returned. When this object goes out of scope, GCP Observability stats,
// tracing and logging data is flushed. On failure, the status message can be
// used to determine the cause of failure. It is up to the applications to
// either crash on failure, or continue without GCP observability being
// enabled. The status codes do not have any special meaning at present, and
// users should not make any assumptions based on the status code, other than
// a non-OK status code meaning that observability initialization failed.
//
// The expected usage is to call this at the top (or near the top) in
// main(), and let it go out of scope after all RPCs and activities that we
// want to observe are done. Please look at
// https://github.com/grpc/grpc/blob/master/examples/cpp/gcp_observability/helloworld/greeter_client.cc
// and
// https://github.com/grpc/grpc/blob/master/examples/cpp/gcp_observability/helloworld/greeter_server.cc
// for sample usage.
//
// It is possible for an initialized GcpObservability object to go out of
// scope while RPCs and other gRPC operations are still ongoing. In this case,
// GCP Observability tries to flush all observability data collected till that
// point.
//
// Note that this is a blocking call which properly sets up gRPC Observability
// to work with GCP and might take a few seconds to return. Similarly, the
// destruction of a non-moved-from `Observability` object is also blocking
// since it flushes the observability data to GCP.
//
// As an implementation detail, this properly initializes the OpenCensus stats
// and tracing plugin, so applications do not need to perform any additional
// gRPC C++ OpenCensus setup/registration to get GCP Observability for gRPC.
static absl::StatusOr<GcpObservability> Init();
GcpObservability() = default;
// Move constructor and Move-assignment operator.
// The moved-from object will no longer be valid and will not cause GCP
// Observability stats, tracing and logging data to flush.
GcpObservability(GcpObservability&& other) noexcept;
GcpObservability& operator=(GcpObservability&& other) noexcept;
// Delete copy and copy-assignment operator
GcpObservability(const GcpObservability&) = delete;
GcpObservability& operator=(const GcpObservability&) = delete;
private:
// Helper class that aids in implementing GCP Observability.
// Inheriting from GrpcLibrary makes sure that gRPC is initialized and remains
// initialized for the lifetime of GCP Observability. In the future, when gRPC
// initialization goes away, we might still want to keep gRPC Event Engine
// initialized, just in case, we need to perform some IO operations during
// observability close.
// Note that the lifetime guarantees are only one way, i.e., GcpObservability
// object guarantees that gRPC will not shutdown while the object is still in
// scope, but the other way around does not hold true. Even though that is not
// the expected usage, GCP Observability can shutdown before gRPC shuts down.
// It follows that gRPC should not hold any callbacks from GcpObservability. A
// change in this restriction should go through a design review.
class GcpObservabilityImpl : private internal::GrpcLibrary {
public:
~GcpObservabilityImpl() override;
};
std::unique_ptr<GcpObservabilityImpl> impl_;
};
namespace experimental {
// Initialize GCP Observability for gRPC.
// This should be called before any other gRPC operations like creating a
// channel, server, credentials etc.
// The most common usage would call this at the top (or near the top) in main().
// As an implementation detail, this properly initializes the OpenCensus stats
// and tracing plugin, so applications do not need to perform any additional
// gRPC C++ OpenCensus setup/registration to get GCP Observability for gRPC.
// TODO(yashykt): Delete this after the 1.55 release.
GRPC_DEPRECATED("Use grpc::GcpObservability::Init() instead.")
absl::Status GcpObservabilityInit();
// Gracefully shuts down GCP Observability.
// Note that graceful shutdown for stats and tracing is not yet supported.
GRPC_DEPRECATED("Use grpc::GcpObservability::Init() instead.")
void GcpObservabilityClose();
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_EXT_GCP_OBSERVABILITY_H

@ -19,12 +19,12 @@
#ifndef GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H
#define GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H
#include <memory>
#include <grpcpp/health_check_service_interface.h>
#include <grpcpp/impl/server_builder_option.h>
#include <grpcpp/support/config.h>
#include <memory>
namespace grpc {
class HealthCheckServiceServerBuilderOption : public ServerBuilderOption {

@ -17,20 +17,27 @@
#ifndef GRPCPP_EXT_ORCA_SERVICE_H
#define GRPCPP_EXT_ORCA_SERVICE_H
#include <map>
#include <string>
#include "absl/time/time.h"
#include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h>
#include <grpcpp/ext/server_metric_recorder.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/impl/sync.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/support/server_callback.h>
#include <grpcpp/support/slice.h>
#include <grpcpp/support/status.h>
#include <cstdint>
#include <optional>
#include "absl/base/thread_annotations.h"
#include "absl/time/time.h"
namespace grpc {
namespace testing {
class OrcaServiceTest;
} // namespace testing
namespace experimental {
// RPC service implementation for supplying out-of-band backend
@ -54,7 +61,15 @@ class OrcaService : public Service {
Options options);
private:
class ReactorHook {
public:
virtual ~ReactorHook() = default;
virtual void OnFinish(grpc::Status status) = 0;
virtual void OnStartWrite(const ByteBuffer* response) = 0;
};
class Reactor;
friend class testing::OrcaServiceTest;
Slice GetOrCreateSerializedResponse();
@ -62,9 +77,9 @@ class OrcaService : public Service {
const absl::Duration min_report_duration_;
grpc::internal::Mutex mu_;
// Contains the last serialized metrics from server_metric_recorder_.
absl::optional<Slice> response_slice_ ABSL_GUARDED_BY(mu_);
std::optional<Slice> response_slice_ ABSL_GUARDED_BY(mu_);
// The update sequence number of metrics serialized in response_slice_.
absl::optional<uint64_t> response_slice_seq_ ABSL_GUARDED_BY(mu_);
std::optional<uint64_t> response_slice_seq_ ABSL_GUARDED_BY(mu_);
};
} // namespace experimental

@ -0,0 +1,182 @@
//
//
// 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.
//
//
#ifndef GRPCPP_EXT_OTEL_PLUGIN_H
#define GRPCPP_EXT_OTEL_PLUGIN_H
#include <grpc/support/metrics.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/support/channel_arguments.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "absl/functional/any_invocable.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "opentelemetry/metrics/meter_provider.h"
namespace grpc {
namespace internal {
class OpenTelemetryPluginBuilderImpl;
} // namespace internal
class OpenTelemetryPluginOption {
public:
virtual ~OpenTelemetryPluginOption() = default;
};
namespace experimental {
/// EXPERIMENTAL API
class OpenTelemetryPlugin {
public:
virtual ~OpenTelemetryPlugin() = default;
/// EXPERIMENTAL API
/// Adds this OpenTelemetryPlugin to the channel args \a args.
virtual void AddToChannelArguments(grpc::ChannelArguments* args) = 0;
/// EXPERIMENTAL API
/// Adds this OpenTelemetryPlugin to the channel arguments that will be used
/// to create the server through \a builder.
virtual void AddToServerBuilder(grpc::ServerBuilder* builder) = 0;
};
} // namespace experimental
/// The most common way to use this API is -
///
/// OpenTelemetryPluginBuilder().SetMeterProvider(provider).BuildAndRegister();
///
/// The set of instruments available are -
/// grpc.client.attempt.started
/// grpc.client.attempt.duration
/// grpc.client.attempt.sent_total_compressed_message_size
/// grpc.client.attempt.rcvd_total_compressed_message_size
/// grpc.server.call.started
/// grpc.server.call.duration
/// grpc.server.call.sent_total_compressed_message_size
/// grpc.server.call.rcvd_total_compressed_message_size
class OpenTelemetryPluginBuilder {
public:
using ChannelScope = grpc_core::experimental::StatsPluginChannelScope;
/// Metrics
static constexpr absl::string_view kClientAttemptStartedInstrumentName =
"grpc.client.attempt.started";
static constexpr absl::string_view kClientAttemptDurationInstrumentName =
"grpc.client.attempt.duration";
static constexpr absl::string_view
kClientAttemptSentTotalCompressedMessageSizeInstrumentName =
"grpc.client.attempt.sent_total_compressed_message_size";
static constexpr absl::string_view
kClientAttemptRcvdTotalCompressedMessageSizeInstrumentName =
"grpc.client.attempt.rcvd_total_compressed_message_size";
static constexpr absl::string_view kServerCallStartedInstrumentName =
"grpc.server.call.started";
static constexpr absl::string_view kServerCallDurationInstrumentName =
"grpc.server.call.duration";
static constexpr absl::string_view
kServerCallSentTotalCompressedMessageSizeInstrumentName =
"grpc.server.call.sent_total_compressed_message_size";
static constexpr absl::string_view
kServerCallRcvdTotalCompressedMessageSizeInstrumentName =
"grpc.server.call.rcvd_total_compressed_message_size";
OpenTelemetryPluginBuilder();
~OpenTelemetryPluginBuilder();
/// If `SetMeterProvider()` is not called, no metrics are collected.
OpenTelemetryPluginBuilder& SetMeterProvider(
std::shared_ptr<opentelemetry::metrics::MeterProvider> meter_provider);
/// DEPRECATED: If set, \a target_attribute_filter is called per channel to
/// decide whether to record the target attribute on client or to replace it
/// with "other". This helps reduce the cardinality on metrics in cases where
/// many channels are created with different targets in the same binary (which
/// might happen for example, if the channel target string uses IP addresses
/// directly).
/// This filtration only works for the per-call metrics -
/// grpc.client.attempt.started
/// grpc.client.attempt.duration
/// grpc.client.attempt.sent_total_compressed_message_size
/// grpc.client.attempt.rcvd_total_compressed_message_size
/// For example, the grpc.target attribute on pick first lb policy metrics
/// defined in
/// https://github.com/grpc/proposal/blob/master/A78-grpc-metrics-wrr-pf-xds.md
/// will not be filtered. Please contact the grpc team if this filtration is
/// of interest to you.
GRPC_DEPRECATED(
"Does not work as expected. Please raise an issue on "
"https://github.com/grpc/grpc if this would be of use to you.")
OpenTelemetryPluginBuilder& SetTargetAttributeFilter(
absl::AnyInvocable<bool(absl::string_view /*target*/) const>
target_attribute_filter);
/// If set, \a generic_method_attribute_filter is called per call with a
/// generic method type to decide whether to record the method name or to
/// replace it with "other". Non-generic or pre-registered methods remain
/// unaffected. If not set, by default, generic method names are replaced
/// with "other" when recording metrics.
OpenTelemetryPluginBuilder& SetGenericMethodAttributeFilter(
absl::AnyInvocable<bool(absl::string_view /*generic_method*/) const>
generic_method_attribute_filter);
// Methods to manipulate which instruments are enabled in the OpenTelemetry
// Stats Plugin.
OpenTelemetryPluginBuilder& EnableMetrics(
absl::Span<const absl::string_view> metric_names);
OpenTelemetryPluginBuilder& DisableMetrics(
absl::Span<const absl::string_view> metric_names);
OpenTelemetryPluginBuilder& DisableAllMetrics();
/// Add a plugin option to add to the opentelemetry plugin being built. At
/// present, this type is an opaque type. Ownership of \a option is
/// transferred when `AddPluginOption` is invoked. A maximum of 64 plugin
/// options can be added.
OpenTelemetryPluginBuilder& AddPluginOption(
std::unique_ptr<OpenTelemetryPluginOption> option);
/// Records \a optional_label_key on all metrics that provide it.
OpenTelemetryPluginBuilder& AddOptionalLabel(
absl::string_view optional_label_key);
/// Set scope filter to choose which channels are recorded by this plugin.
/// Server-side recording remains unaffected.
OpenTelemetryPluginBuilder& SetChannelScopeFilter(
absl::AnyInvocable<bool(const ChannelScope& /*scope*/) const>
channel_scope_filter);
/// Builds and registers a global plugin that acts on all channels and servers
/// running on the process. Must be called no more than once and must not be
/// called if Build() is called.
absl::Status BuildAndRegisterGlobal();
/// EXPERIMENTAL API
/// Builds an open telemetry plugin, returns the plugin object when succeeded
/// or an error status when failed. Must be called no more than once and must
/// not be called if BuildAndRegisterGlobal() is called.
GRPC_MUST_USE_RESULT
absl::StatusOr<std::shared_ptr<experimental::OpenTelemetryPlugin>> Build();
private:
std::unique_ptr<internal::OpenTelemetryPluginBuilderImpl> impl_;
};
namespace experimental {
// TODO(yashykt): Delete this after the 1.62 release.
GRPC_DEPRECATED(
"Use grpc::OpenTelemetryPluginBuilder instead. The experimental version "
"will be deleted after the 1.62 release.")
typedef grpc::OpenTelemetryPluginBuilder OpenTelemetryPluginBuilder;
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_EXT_OTEL_PLUGIN_H

@ -22,8 +22,12 @@
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/config.h>
#include <memory>
namespace grpc {
class ProtoServerReflection;
class ProtoServerReflectionBackend;
class ProtoServerReflectionV1;
class ServerInitializer;
namespace reflection {
@ -39,7 +43,9 @@ class ProtoServerReflectionPlugin : public grpc::ServerBuilderPlugin {
bool has_sync_methods() const override;
private:
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;
std::shared_ptr<grpc::ProtoServerReflectionBackend> backend_;
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_v1alpha_;
std::shared_ptr<grpc::ProtoServerReflectionV1> reflection_service_v1_;
};
/// Add proto reflection plugin to \a ServerBuilder.

@ -19,9 +19,8 @@
#ifndef GRPCPP_EXT_SERVER_LOAD_REPORTING_H
#define GRPCPP_EXT_SERVER_LOAD_REPORTING_H
#include <grpc/support/port_platform.h>
#include <grpc/load_reporting.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/impl/server_builder_option.h>
#include <grpcpp/server_context.h>
#include <grpcpp/support/config.h>

@ -19,13 +19,13 @@
#ifndef GRPCPP_EXT_SERVER_METRIC_RECORDER_H
#define GRPCPP_EXT_SERVER_METRIC_RECORDER_H
#include <grpcpp/impl/sync.h>
#include <grpcpp/support/string_ref.h>
#include <functional>
#include <map>
#include <memory>
#include <grpcpp/impl/sync.h>
#include <grpcpp/support/string_ref.h>
namespace grpc_core {
struct BackendMetricData;
} // namespace grpc_core
@ -43,14 +43,19 @@ class ServerMetricRecorder {
public:
// Factory method. Use this to create.
static std::unique_ptr<ServerMetricRecorder> Create();
/// Records the server CPU utilization in the range [0, 1].
/// Values outside of the valid range are rejected.
/// Overrides the stored value when called again with a valid value.
/// Records the server CPU utilization in the range [0, infy).
/// Values may be larger than 1.0 when the usage exceeds the reporter
/// dependent notion of soft limits. Values outside of the valid range are
/// rejected. Overrides the stored value when called again with a valid value.
void SetCpuUtilization(double value);
/// Records the server memory utilization in the range [0, 1].
/// Values outside of the valid range are rejected.
/// Overrides the stored value when called again with a valid value.
void SetMemoryUtilization(double value);
/// Records the application specific utilization in the range [0, infy].
/// Values outside of the valid range are rejected.
/// Overrides the stored value when called again with a valid value.
void SetApplicationUtilization(double value);
/// Records number of queries per second to the server in the range [0, infy).
/// Values outside of the valid range are rejected.
/// Overrides the stored value when called again with a valid value.
@ -76,6 +81,8 @@ class ServerMetricRecorder {
void ClearCpuUtilization();
/// Clears the server memory utilization if recorded.
void ClearMemoryUtilization();
/// Clears the application specific utilization if recorded.
void ClearApplicationUtilization();
/// Clears number of queries per second to the server if recorded.
void ClearQps();
/// Clears number of errors per second to the server if recorded.

@ -20,11 +20,9 @@
#define GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H
#include <grpc/support/port_platform.h>
#include <grpcpp/impl/server_callback_handlers.h>
#include <grpcpp/generic/callback_generic_service.h>
#include <grpcpp/support/async_stream.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/server_callback.h>
struct grpc_server;
@ -79,57 +77,6 @@ class AsyncGenericService final {
grpc::Server* server_;
};
/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs
/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with
/// ByteBuffer arguments.
using ServerGenericBidiReactor = ServerBidiReactor<ByteBuffer, ByteBuffer>;
class GenericCallbackServerContext final : public grpc::CallbackServerContext {
public:
const std::string& method() const { return method_; }
const std::string& host() const { return host_; }
private:
friend class grpc::Server;
std::string method_;
std::string host_;
};
/// \a CallbackGenericService is the base class for generic services implemented
/// using the callback API and registered through the ServerBuilder using
/// RegisterCallbackGenericService.
class CallbackGenericService {
public:
CallbackGenericService() {}
virtual ~CallbackGenericService() {}
/// The "method handler" for the generic API. This function should be
/// overridden to provide a ServerGenericBidiReactor that implements the
/// application-level interface for this RPC. Unimplemented by default.
virtual ServerGenericBidiReactor* CreateReactor(
GenericCallbackServerContext* /*ctx*/) {
class Reactor : public ServerGenericBidiReactor {
public:
Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); }
void OnDone() override { delete this; }
};
return new Reactor;
}
private:
friend class grpc::Server;
internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>* Handler() {
return new internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>(
[this](grpc::CallbackServerContext* ctx) {
return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx));
});
}
grpc::Server* server_{nullptr};
};
} // namespace grpc
#endif // GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H

@ -0,0 +1,84 @@
//
//
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
#define GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
#include <grpc/support/port_platform.h>
#include <grpcpp/impl/server_callback_handlers.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/server_callback.h>
struct grpc_server;
namespace grpc {
/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs
/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with
/// ByteBuffer arguments.
using ServerGenericBidiReactor = ServerBidiReactor<ByteBuffer, ByteBuffer>;
class GenericCallbackServerContext final : public grpc::CallbackServerContext {
public:
const std::string& method() const { return method_; }
const std::string& host() const { return host_; }
private:
friend class grpc::Server;
std::string method_;
std::string host_;
};
/// \a CallbackGenericService is the base class for generic services implemented
/// using the callback API and registered through the ServerBuilder using
/// RegisterCallbackGenericService.
class CallbackGenericService {
public:
CallbackGenericService() {}
virtual ~CallbackGenericService() {}
/// The "method handler" for the generic API. This function should be
/// overridden to provide a ServerGenericBidiReactor that implements the
/// application-level interface for this RPC. Unimplemented by default.
virtual ServerGenericBidiReactor* CreateReactor(
GenericCallbackServerContext* /*ctx*/) {
class Reactor : public ServerGenericBidiReactor {
public:
Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); }
void OnDone() override { delete this; }
};
return new Reactor;
}
private:
friend class grpc::Server;
internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>* Handler() {
return new internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>(
[this](grpc::CallbackServerContext* ctx) {
return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx));
});
}
grpc::Server* server_{nullptr};
};
} // namespace grpc
#endif // GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H

@ -19,15 +19,12 @@
#ifndef GRPCPP_GENERIC_GENERIC_STUB_H
#define GRPCPP_GENERIC_GENERIC_STUB_H
#include <functional>
#include <grpcpp/client_context.h>
#include <grpcpp/impl/generic_stub_internal.h>
#include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/async_stream.h>
#include <grpcpp/support/async_unary_call.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/client_callback.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
namespace grpc {
@ -42,10 +39,12 @@ typedef ClientAsyncResponseReader<ByteBuffer> GenericClientAsyncResponseReader;
/// by name. In practice, the Request and Response types should be basic
/// types like grpc::ByteBuffer or proto::MessageLite (the base protobuf).
template <class RequestType, class ResponseType>
class TemplatedGenericStub final {
class TemplatedGenericStub final
: public internal::TemplatedGenericStubCallbackInternal<RequestType,
ResponseType> {
public:
explicit TemplatedGenericStub(std::shared_ptr<grpc::ChannelInterface> channel)
: channel_(channel) {}
using internal::TemplatedGenericStubCallbackInternal<
RequestType, ResponseType>::TemplatedGenericStubCallbackInternal;
/// Setup a call to a named method \a method using \a context, but don't
/// start it. Let it be started explicitly with StartCall and a tag.
@ -74,6 +73,9 @@ class TemplatedGenericStub final {
context, request));
}
using internal::TemplatedGenericStubCallbackInternal<
RequestType, ResponseType>::PrepareUnaryCall;
/// DEPRECATED for multi-threaded use
/// Begin a call to a named method \a method using \a context.
/// A tag \a tag will be delivered to \a cq when the call has been started
@ -87,72 +89,9 @@ class TemplatedGenericStub final {
true, tag);
}
/// Setup and start a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
void UnaryCall(ClientContext* context, const std::string& method,
StubOptions options, const RequestType* request,
ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
UnaryCallInternal(context, method, options, request, response,
std::move(on_completion));
}
/// Setup a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
/// Like any other reactor-based RPC, it will not be activated until
/// StartCall is invoked on its reactor.
void PrepareUnaryCall(ClientContext* context, const std::string& method,
StubOptions options, const RequestType* request,
ResponseType* response, ClientUnaryReactor* reactor) {
PrepareUnaryCallInternal(context, method, options, request, response,
reactor);
}
/// Setup a call to a named method \a method using \a context and tied to
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
/// until StartCall is invoked on its reactor.
void PrepareBidiStreamingCall(
ClientContext* context, const std::string& method, StubOptions options,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
PrepareBidiStreamingCallInternal(context, method, options, reactor);
}
private:
std::shared_ptr<grpc::ChannelInterface> channel_;
void UnaryCallInternal(ClientContext* context, const std::string& method,
StubOptions options, const RequestType* request,
ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
internal::CallbackUnaryCall(
channel_.get(),
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, std::move(on_completion));
}
void PrepareUnaryCallInternal(ClientContext* context,
const std::string& method, StubOptions options,
const RequestType* request,
ResponseType* response,
ClientUnaryReactor* reactor) {
internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
channel_.get(),
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, reactor);
}
void PrepareBidiStreamingCallInternal(
ClientContext* context, const std::string& method, StubOptions options,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
internal::ClientCallbackReaderWriterFactory<RequestType, ResponseType>::
Create(channel_.get(),
grpc::internal::RpcMethod(
method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::BIDI_STREAMING),
context, reactor);
}
using internal::TemplatedGenericStubCallbackInternal<RequestType,
ResponseType>::channel_;
std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
CallInternal(grpc::ChannelInterface* channel, ClientContext* context,

@ -0,0 +1,44 @@
//
//
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPCPP_GENERIC_GENERIC_STUB_CALLBACK_H
#define GRPCPP_GENERIC_GENERIC_STUB_CALLBACK_H
#include <grpcpp/impl/generic_stub_internal.h>
#include <grpcpp/support/byte_buffer.h>
namespace grpc {
/// Generic stubs provide a type-unaware interface to call gRPC methods
/// by name. In practice, the Request and Response types should be basic
/// types like grpc::ByteBuffer or proto::MessageLite (the base protobuf).
template <class RequestType, class ResponseType>
class TemplatedGenericStubCallback final
: public internal::TemplatedGenericStubCallbackInternal<RequestType,
ResponseType> {
public:
using internal::TemplatedGenericStubCallbackInternal<
RequestType, ResponseType>::TemplatedGenericStubCallbackInternal;
};
typedef TemplatedGenericStubCallback<grpc::ByteBuffer, grpc::ByteBuffer>
GenericStubCallback;
} // namespace grpc
#endif // GRPCPP_GENERIC_GENERIC_STUB_CALLBACK_H

@ -19,16 +19,11 @@
#ifndef GRPCPP_IMPL_CALL_OP_SET_H
#define GRPCPP_IMPL_CALL_OP_SET_H
#include <cstring>
#include <map>
#include <memory>
#include <grpc/grpc.h>
#include <grpc/impl/compression_types.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/client_context.h>
#include <grpcpp/completion_queue.h>
#include <grpcpp/impl/call.h>
@ -43,6 +38,13 @@
#include <grpcpp/support/slice.h>
#include <grpcpp/support/string_ref.h>
#include <cstring>
#include <map>
#include <memory>
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
namespace grpc {
namespace internal {
@ -290,23 +292,23 @@ class CallOpSendMessage {
/// Send \a message using \a options for the write. The \a options are cleared
/// after use.
template <class M>
Status SendMessage(const M& message,
WriteOptions options) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessage(const M& message,
WriteOptions options);
template <class M>
Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessage(const M& message);
/// Send \a message using \a options for the write. The \a options are cleared
/// after use. This form of SendMessage allows gRPC to reference \a message
/// beyond the lifetime of SendMessage.
template <class M>
Status SendMessagePtr(const M* message,
WriteOptions options) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message,
WriteOptions options);
/// This form of SendMessage allows gRPC to reference \a message beyond the
/// lifetime of SendMessage.
template <class M>
Status SendMessagePtr(const M* message) GRPC_MUST_USE_RESULT;
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message);
protected:
void AddOp(grpc_op* ops, size_t* nops) {
@ -316,7 +318,7 @@ class CallOpSendMessage {
return;
}
if (msg_ != nullptr) {
GPR_ASSERT(serializer_(msg_).ok());
ABSL_CHECK(serializer_(msg_).ok());
}
serializer_ = nullptr;
grpc_op* op = &ops[(*nops)++];
@ -769,7 +771,9 @@ class CallOpRecvInitialMetadata {
class CallOpClientRecvStatus {
public:
CallOpClientRecvStatus()
: recv_status_(nullptr), debug_error_string_(nullptr) {}
: metadata_map_(nullptr),
recv_status_(nullptr),
debug_error_string_(nullptr) {}
void ClientRecvStatus(grpc::ClientContext* context, Status* status) {
client_context_ = context;
@ -795,7 +799,7 @@ class CallOpClientRecvStatus {
if (recv_status_ == nullptr || hijacked_) return;
if (static_cast<StatusCode>(status_code_) == StatusCode::OK) {
*recv_status_ = Status();
GPR_DEBUG_ASSERT(debug_error_string_ == nullptr);
ABSL_DCHECK_EQ(debug_error_string_, nullptr);
} else {
*recv_status_ =
Status(static_cast<StatusCode>(status_code_),
@ -972,9 +976,9 @@ class CallOpSet : public CallOpSetInterface,
// A failure here indicates an API misuse; for example, doing a Write
// while another Write is already pending on the same RPC or invoking
// WritesDone multiple times
gpr_log(GPR_ERROR, "API misuse of type %s observed",
grpc_call_error_to_string(err));
GPR_ASSERT(false);
ABSL_LOG(ERROR) << "API misuse of type " << grpc_call_error_to_string(err)
<< " observed";
ABSL_CHECK(false);
}
}
@ -984,7 +988,7 @@ class CallOpSet : public CallOpSetInterface,
done_intercepting_ = true;
// The following call_start_batch is internally-generated so no need for an
// explanatory log on failure.
GPR_ASSERT(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
ABSL_CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
nullptr) == GRPC_CALL_OK);
}

@ -19,12 +19,12 @@
#ifndef GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H
#define GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H
#include <map>
#include <memory>
#include <grpcpp/impl/server_builder_option.h>
#include <grpcpp/support/channel_arguments.h>
#include <map>
#include <memory>
namespace grpc {
std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(

@ -21,7 +21,9 @@
// IWYU pragma: private
#define GRPC_OPEN_SOURCE_PROTO
// #define GRPC_OPEN_SOURCE_PROTO
#define GRPC_PROTOBUF_CORD_SUPPORT_ENABLED
#ifndef GRPC_CUSTOM_MESSAGE
#ifdef GRPC_USE_PROTO_LITE
@ -38,8 +40,14 @@
#ifndef GRPC_CUSTOM_DESCRIPTOR
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 4025000
#define GRPC_PROTOBUF_EDITION_SUPPORT
#endif
#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor
#define GRPC_CUSTOM_DESCRIPTORPOOL ::google::protobuf::DescriptorPool
#ifdef GRPC_PROTOBUF_EDITION_SUPPORT
#define GRPC_CUSTOM_EDITION ::google::protobuf::Edition
#endif
#define GRPC_CUSTOM_FIELDDESCRIPTOR ::google::protobuf::FieldDescriptor
#define GRPC_CUSTOM_FILEDESCRIPTOR ::google::protobuf::FileDescriptor
#define GRPC_CUSTOM_FILEDESCRIPTORPROTO ::google::protobuf::FileDescriptorProto
@ -63,13 +71,16 @@
#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \
::google::protobuf::io::ZeroCopyInputStream
#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream
#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream
#endif
#ifndef GRPC_CUSTOM_JSONUTIL
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
#include "absl/status/status.h"
#define GRPC_CUSTOM_JSONUTIL ::google::protobuf::util
#define GRPC_CUSTOM_UTIL_STATUS ::google::protobuf::util::Status
#define GRPC_CUSTOM_UTIL_STATUS ::absl::Status
#endif
namespace grpc {
@ -81,6 +92,9 @@ typedef GRPC_CUSTOM_MESSAGELITE MessageLite;
typedef GRPC_CUSTOM_DESCRIPTOR Descriptor;
typedef GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool;
typedef GRPC_CUSTOM_DESCRIPTORDATABASE DescriptorDatabase;
#ifdef GRPC_PROTOBUF_EDITION_SUPPORT
typedef GRPC_CUSTOM_EDITION Edition;
#endif
typedef GRPC_CUSTOM_FIELDDESCRIPTOR FieldDescriptor;
typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor;
typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto;
@ -100,6 +114,7 @@ namespace io {
typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream;
typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream;
typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream;
typedef GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream;
} // namespace io
} // namespace protobuf

@ -19,11 +19,11 @@
#ifndef GRPCPP_IMPL_CREATE_AUTH_CONTEXT_H
#define GRPCPP_IMPL_CREATE_AUTH_CONTEXT_H
#include <memory>
#include <grpc/impl/grpc_types.h>
#include <grpcpp/security/auth_context.h>
#include <memory>
namespace grpc {
/// TODO(ctiller): not sure we want to make this a permanent thing

@ -19,10 +19,10 @@
#ifndef GRPCPP_IMPL_DELEGATING_CHANNEL_H
#define GRPCPP_IMPL_DELEGATING_CHANNEL_H
#include <memory>
#include <grpcpp/impl/channel_interface.h>
#include <memory>
namespace grpc {
namespace experimental {

@ -0,0 +1,93 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_IMPL_GENERIC_SERIALIZE_H
#define GRPCPP_IMPL_GENERIC_SERIALIZE_H
#include <grpc/byte_buffer_reader.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/slice.h>
#include <grpcpp/impl/codegen/config_protobuf.h>
#include <grpcpp/impl/serialization_traits.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/proto_buffer_reader.h>
#include <grpcpp/support/proto_buffer_writer.h>
#include <grpcpp/support/slice.h>
#include <grpcpp/support/status.h>
#include <type_traits>
#include "absl/log/absl_check.h"
/// This header provides serialization and deserialization between gRPC
/// messages serialized using protobuf and the C++ objects they represent.
namespace grpc {
// ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream.
template <class ProtoBufferWriter, class T>
Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
bool* own_buffer) {
static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream,
ProtoBufferWriter>::value,
"ProtoBufferWriter must be a subclass of "
"::protobuf::io::ZeroCopyOutputStream");
*own_buffer = true;
int byte_size = static_cast<int>(msg.ByteSizeLong());
if (static_cast<size_t>(byte_size) <= GRPC_SLICE_INLINED_SIZE) {
Slice slice(byte_size);
// We serialize directly into the allocated slices memory
ABSL_CHECK(slice.end() == msg.SerializeWithCachedSizesToArray(
const_cast<uint8_t*>(slice.begin())));
ByteBuffer tmp(&slice, 1);
bb->Swap(&tmp);
return grpc::Status::OK;
}
ProtoBufferWriter writer(bb, kProtoBufferWriterMaxBufferLength, byte_size);
protobuf::io::CodedOutputStream cs(&writer);
msg.SerializeWithCachedSizes(&cs);
return !cs.HadError()
? grpc::Status::OK
: Status(StatusCode::INTERNAL, "Failed to serialize message");
}
// BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream.
template <class ProtoBufferReader, class T>
Status GenericDeserialize(ByteBuffer* buffer,
grpc::protobuf::MessageLite* msg) {
static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream,
ProtoBufferReader>::value,
"ProtoBufferReader must be a subclass of "
"::protobuf::io::ZeroCopyInputStream");
if (buffer == nullptr) {
return Status(StatusCode::INTERNAL, "No payload");
}
Status result = grpc::Status::OK;
{
ProtoBufferReader reader(buffer);
if (!reader.status().ok()) {
return reader.status();
}
if (!msg->ParseFromZeroCopyStream(&reader)) {
result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
}
}
buffer->Clear();
return result;
}
} // namespace grpc
#endif // GRPCPP_IMPL_GENERIC_SERIALIZE_H

@ -0,0 +1,125 @@
//
//
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPCPP_IMPL_GENERIC_STUB_INTERNAL_H
#define GRPCPP_IMPL_GENERIC_STUB_INTERNAL_H
#include <grpcpp/client_context.h>
#include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/client_callback.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
#include <functional>
namespace grpc {
template <class RequestType, class ResponseType>
class TemplatedGenericStub;
template <class RequestType, class ResponseType>
class TemplatedGenericStubCallback;
namespace internal {
/// Generic stubs provide a type-unaware interface to call gRPC methods
/// by name. In practice, the Request and Response types should be basic
/// types like grpc::ByteBuffer or proto::MessageLite (the base protobuf).
template <class RequestType, class ResponseType>
class TemplatedGenericStubCallbackInternal {
public:
explicit TemplatedGenericStubCallbackInternal(
std::shared_ptr<grpc::ChannelInterface> channel)
: channel_(channel) {}
/// Setup and start a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
void UnaryCall(ClientContext* context, const std::string& method,
StubOptions options, const RequestType* request,
ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
UnaryCallInternal(context, method, options, request, response,
std::move(on_completion));
}
/// Setup a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
/// Like any other reactor-based RPC, it will not be activated until
/// StartCall is invoked on its reactor.
void PrepareUnaryCall(ClientContext* context, const std::string& method,
StubOptions options, const RequestType* request,
ResponseType* response, ClientUnaryReactor* reactor) {
PrepareUnaryCallInternal(context, method, options, request, response,
reactor);
}
/// Setup a call to a named method \a method using \a context and tied to
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
/// until StartCall is invoked on its reactor.
void PrepareBidiStreamingCall(
ClientContext* context, const std::string& method, StubOptions options,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
PrepareBidiStreamingCallInternal(context, method, options, reactor);
}
private:
template <class Req, class Resp>
friend class grpc::TemplatedGenericStub;
template <class Req, class Resp>
friend class grpc::TemplatedGenericStubCallback;
std::shared_ptr<grpc::ChannelInterface> channel_;
void UnaryCallInternal(ClientContext* context, const std::string& method,
StubOptions options, const RequestType* request,
ResponseType* response,
std::function<void(grpc::Status)> on_completion) {
internal::CallbackUnaryCall(
channel_.get(),
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, std::move(on_completion));
}
void PrepareUnaryCallInternal(ClientContext* context,
const std::string& method, StubOptions options,
const RequestType* request,
ResponseType* response,
ClientUnaryReactor* reactor) {
internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
channel_.get(),
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, reactor);
}
void PrepareBidiStreamingCallInternal(
ClientContext* context, const std::string& method, StubOptions options,
ClientBidiReactor<RequestType, ResponseType>* reactor) {
internal::ClientCallbackReaderWriterFactory<RequestType, ResponseType>::
Create(channel_.get(),
grpc::internal::RpcMethod(
method.c_str(), options.suffix_for_stats(),
grpc::internal::RpcMethod::BIDI_STREAMING),
context, reactor);
}
};
} // namespace internal
} // namespace grpc
#endif // GRPCPP_IMPL_GENERIC_STUB_INTERNAL_H

@ -19,11 +19,11 @@
#ifndef GRPCPP_IMPL_GRPC_LIBRARY_H
#define GRPCPP_IMPL_GRPC_LIBRARY_H
#include <iostream>
#include <grpc/grpc.h>
#include <grpcpp/impl/codegen/config.h>
#include <iostream>
namespace grpc {
namespace internal {

@ -19,17 +19,18 @@
#ifndef GRPCPP_IMPL_INTERCEPTOR_COMMON_H
#define GRPCPP_IMPL_INTERCEPTOR_COMMON_H
#include <array>
#include <functional>
#include <grpc/impl/grpc_types.h>
#include <grpc/support/log.h>
#include <grpcpp/impl/call.h>
#include <grpcpp/impl/call_op_set_interface.h>
#include <grpcpp/impl/intercepted_channel.h>
#include <grpcpp/support/client_interceptor.h>
#include <grpcpp/support/server_interceptor.h>
#include <array>
#include <functional>
#include "absl/log/absl_check.h"
namespace grpc {
namespace internal {
@ -56,16 +57,16 @@ class InterceptorBatchMethodsImpl
if (call_->client_rpc_info() != nullptr) {
return ProceedClient();
}
GPR_ASSERT(call_->server_rpc_info() != nullptr);
ABSL_CHECK_NE(call_->server_rpc_info(), nullptr);
ProceedServer();
}
void Hijack() override {
// Only the client can hijack when sending down initial metadata
GPR_ASSERT(!reverse_ && ops_ != nullptr &&
ABSL_CHECK(!reverse_ && ops_ != nullptr &&
call_->client_rpc_info() != nullptr);
// It is illegal to call Hijack twice
GPR_ASSERT(!ran_hijacking_interceptor_);
ABSL_CHECK(!ran_hijacking_interceptor_);
auto* rpc_info = call_->client_rpc_info();
rpc_info->hijacked_ = true;
rpc_info->hijacked_interceptor_ = current_interceptor_index_;
@ -80,21 +81,21 @@ class InterceptorBatchMethodsImpl
}
ByteBuffer* GetSerializedSendMessage() override {
GPR_ASSERT(orig_send_message_ != nullptr);
ABSL_CHECK_NE(orig_send_message_, nullptr);
if (*orig_send_message_ != nullptr) {
GPR_ASSERT(serializer_(*orig_send_message_).ok());
ABSL_CHECK(serializer_(*orig_send_message_).ok());
*orig_send_message_ = nullptr;
}
return send_message_;
}
const void* GetSendMessage() override {
GPR_ASSERT(orig_send_message_ != nullptr);
ABSL_CHECK_NE(orig_send_message_, nullptr);
return *orig_send_message_;
}
void ModifySendMessage(const void* message) override {
GPR_ASSERT(orig_send_message_ != nullptr);
ABSL_CHECK_NE(orig_send_message_, nullptr);
*orig_send_message_ = message;
}
@ -129,7 +130,7 @@ class InterceptorBatchMethodsImpl
Status* GetRecvStatus() override { return recv_status_; }
void FailHijackedSendMessage() override {
GPR_ASSERT(hooks_[static_cast<size_t>(
ABSL_CHECK(hooks_[static_cast<size_t>(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)]);
*fail_send_message_ = true;
}
@ -192,7 +193,7 @@ class InterceptorBatchMethodsImpl
}
void FailHijackedRecvMessage() override {
GPR_ASSERT(hooks_[static_cast<size_t>(
ABSL_CHECK(hooks_[static_cast<size_t>(
experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]);
*hijacked_recv_message_failed_ = true;
}
@ -236,7 +237,7 @@ class InterceptorBatchMethodsImpl
// ContinueFinalizeOpsAfterInterception will be called. Note that neither of
// them is invoked if there were no interceptors registered.
bool RunInterceptors() {
GPR_ASSERT(ops_);
ABSL_CHECK(ops_);
auto* client_rpc_info = call_->client_rpc_info();
if (client_rpc_info != nullptr) {
if (client_rpc_info->interceptors_.empty()) {
@ -261,8 +262,8 @@ class InterceptorBatchMethodsImpl
// SyncRequest.
bool RunInterceptors(std::function<void(void)> f) {
// This is used only by the server for initial call request
GPR_ASSERT(reverse_ == true);
GPR_ASSERT(call_->client_rpc_info() == nullptr);
ABSL_CHECK_EQ(reverse_, true);
ABSL_CHECK_EQ(call_->client_rpc_info(), nullptr);
auto* server_rpc_info = call_->server_rpc_info();
if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
return true;
@ -356,7 +357,7 @@ class InterceptorBatchMethodsImpl
return ops_->ContinueFinalizeResultAfterInterception();
}
}
GPR_ASSERT(callback_);
ABSL_CHECK(callback_);
callback_();
}
@ -422,112 +423,103 @@ class CancelInterceptorBatchMethods
void Hijack() override {
// Only the client can hijack when sending down initial metadata
GPR_ASSERT(false &&
"It is illegal to call Hijack on a method which has a "
"Cancel notification");
ABSL_CHECK(false) << "It is illegal to call Hijack on a method which has a "
"Cancel notification";
}
ByteBuffer* GetSerializedSendMessage() override {
GPR_ASSERT(false &&
"It is illegal to call GetSendMessage on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call GetSendMessage on a method which "
"has a Cancel notification";
return nullptr;
}
bool GetSendMessageStatus() override {
GPR_ASSERT(false &&
"It is illegal to call GetSendMessageStatus on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call GetSendMessageStatus on a method which "
"has a Cancel notification";
return false;
}
const void* GetSendMessage() override {
GPR_ASSERT(false &&
"It is illegal to call GetOriginalSendMessage on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call GetOriginalSendMessage on a method which "
"has a Cancel notification";
return nullptr;
}
void ModifySendMessage(const void* /*message*/) override {
GPR_ASSERT(false &&
"It is illegal to call ModifySendMessage on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call ModifySendMessage on a method which "
"has a Cancel notification";
}
std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
GPR_ASSERT(false &&
"It is illegal to call GetSendInitialMetadata on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call GetSendInitialMetadata on a "
"method which has a Cancel notification";
return nullptr;
}
Status GetSendStatus() override {
GPR_ASSERT(false &&
"It is illegal to call GetSendStatus on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call GetSendStatus on a method which "
"has a Cancel notification";
return Status();
}
void ModifySendStatus(const Status& /*status*/) override {
GPR_ASSERT(false &&
"It is illegal to call ModifySendStatus on a method "
"which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call ModifySendStatus on a method "
"which has a Cancel notification";
}
std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
GPR_ASSERT(false &&
"It is illegal to call GetSendTrailingMetadata on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call GetSendTrailingMetadata on a "
"method which has a Cancel notification";
return nullptr;
}
void* GetRecvMessage() override {
GPR_ASSERT(false &&
"It is illegal to call GetRecvMessage on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call GetRecvMessage on a method which "
"has a Cancel notification";
return nullptr;
}
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
override {
GPR_ASSERT(false &&
"It is illegal to call GetRecvInitialMetadata on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call GetRecvInitialMetadata on a "
"method which has a Cancel notification";
return nullptr;
}
Status* GetRecvStatus() override {
GPR_ASSERT(false &&
"It is illegal to call GetRecvStatus on a method which "
"has a Cancel notification");
ABSL_CHECK(false)
<< "It is illegal to call GetRecvStatus on a method which "
"has a Cancel notification";
return nullptr;
}
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
override {
GPR_ASSERT(false &&
"It is illegal to call GetRecvTrailingMetadata on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call GetRecvTrailingMetadata on a "
"method which has a Cancel notification";
return nullptr;
}
std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
GPR_ASSERT(false &&
"It is illegal to call GetInterceptedChannel on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call GetInterceptedChannel on a "
"method which has a Cancel notification";
return std::unique_ptr<ChannelInterface>(nullptr);
}
void FailHijackedRecvMessage() override {
GPR_ASSERT(false &&
"It is illegal to call FailHijackedRecvMessage on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call FailHijackedRecvMessage on a "
"method which has a Cancel notification";
}
void FailHijackedSendMessage() override {
GPR_ASSERT(false &&
"It is illegal to call FailHijackedSendMessage on a "
"method which has a Cancel notification");
ABSL_CHECK(false) << "It is illegal to call FailHijackedSendMessage on a "
"method which has a Cancel notification";
}
};
} // namespace internal

@ -19,12 +19,11 @@
#ifndef GRPCPP_IMPL_METADATA_MAP_H
#define GRPCPP_IMPL_METADATA_MAP_H
#include <map>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpcpp/support/slice.h>
#include <map>
namespace grpc {
namespace internal {

@ -19,13 +19,11 @@
#ifndef GRPCPP_IMPL_PROTO_UTILS_H
#define GRPCPP_IMPL_PROTO_UTILS_H
#include <type_traits>
#include <grpc/byte_buffer_reader.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpcpp/impl/codegen/config_protobuf.h>
#include <grpcpp/impl/generic_serialize.h>
#include <grpcpp/impl/serialization_traits.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/proto_buffer_reader.h>
@ -33,65 +31,13 @@
#include <grpcpp/support/slice.h>
#include <grpcpp/support/status.h>
#include <type_traits>
/// This header provides serialization and deserialization between gRPC
/// messages serialized using protobuf and the C++ objects they represent.
namespace grpc {
// ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream.
template <class ProtoBufferWriter, class T>
Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
bool* own_buffer) {
static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream,
ProtoBufferWriter>::value,
"ProtoBufferWriter must be a subclass of "
"::protobuf::io::ZeroCopyOutputStream");
*own_buffer = true;
int byte_size = static_cast<int>(msg.ByteSizeLong());
if (static_cast<size_t>(byte_size) <= GRPC_SLICE_INLINED_SIZE) {
Slice slice(byte_size);
// We serialize directly into the allocated slices memory
GPR_ASSERT(slice.end() == msg.SerializeWithCachedSizesToArray(
const_cast<uint8_t*>(slice.begin())));
ByteBuffer tmp(&slice, 1);
bb->Swap(&tmp);
return grpc::Status::OK;
}
ProtoBufferWriter writer(bb, kProtoBufferWriterMaxBufferLength, byte_size);
return msg.SerializeToZeroCopyStream(&writer)
? grpc::Status::OK
: Status(StatusCode::INTERNAL, "Failed to serialize message");
}
// BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream.
template <class ProtoBufferReader, class T>
Status GenericDeserialize(ByteBuffer* buffer,
grpc::protobuf::MessageLite* msg) {
static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream,
ProtoBufferReader>::value,
"ProtoBufferReader must be a subclass of "
"::protobuf::io::ZeroCopyInputStream");
if (buffer == nullptr) {
return Status(StatusCode::INTERNAL, "No payload");
}
Status result = grpc::Status::OK;
{
ProtoBufferReader reader(buffer);
if (!reader.status().ok()) {
return reader.status();
}
if (!msg->ParseFromZeroCopyStream(&reader)) {
result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
}
}
buffer->Clear();
return result;
}
// this is needed so the following class does not conflict with protobuf
// serializers that utilize internal-only tools.
#ifdef GRPC_OPEN_SOURCE_PROTO
// This class provides a protobuf serializer. It translates between protobuf
// objects and grpc_byte_buffers. More information about SerializationTraits can
// be found in include/grpcpp/impl/codegen/serialization_traits.h.
@ -110,7 +56,6 @@ class SerializationTraits<
return GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
}
};
#endif
} // namespace grpc

@ -19,10 +19,10 @@
#ifndef GRPCPP_IMPL_RPC_METHOD_H
#define GRPCPP_IMPL_RPC_METHOD_H
#include <memory>
#include <grpcpp/impl/codegen/channel_interface.h>
#include <memory>
namespace grpc {
namespace internal {
/// Descriptor of an RPC method

@ -19,17 +19,19 @@
#ifndef GRPCPP_IMPL_RPC_SERVICE_METHOD_H
#define GRPCPP_IMPL_RPC_SERVICE_METHOD_H
#include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/config.h>
#include <grpcpp/support/status.h>
#include <climits>
#include <functional>
#include <map>
#include <memory>
#include <vector>
#include <grpc/support/log.h>
#include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/config.h>
#include <grpcpp/support/status.h>
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
namespace grpc {
class ServerContextBase;
@ -75,7 +77,7 @@ class MethodHandler {
// retained by the handler. Returns nullptr if deserialization failed.
virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req,
Status* /*status*/, void** /*handler_data*/) {
GPR_ASSERT(req == nullptr);
ABSL_CHECK_EQ(req, nullptr);
return nullptr;
}
};
@ -114,12 +116,12 @@ class RpcServiceMethod : public RpcMethod {
// this is not an error condition, as it allows users to declare a server
// like WithRawMethod_foo<AsyncService>. However since it
// overwrites behavior, it should be logged.
gpr_log(
GPR_INFO,
"You are marking method %s as '%s', even though it was "
"previously marked '%s'. This behavior will overwrite the original "
"behavior. If you expected this then ignore this message.",
name(), TypeToString(api_type_), TypeToString(type));
ABSL_LOG(INFO)
<< "You are marking method " << name() << " as '"
<< TypeToString(api_type_)
<< "', even though it was previously marked '" << TypeToString(type)
<< "'. This behavior will overwrite the original behavior. If "
"you expected this then ignore this message.";
}
api_type_ = type;
}

@ -19,12 +19,12 @@
#ifndef GRPCPP_IMPL_SERVER_BUILDER_OPTION_H
#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_H
#include <map>
#include <memory>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/channel_arguments.h>
#include <map>
#include <memory>
namespace grpc {
/// Interface to pass an option to a \a ServerBuilder.

@ -19,11 +19,11 @@
#ifndef GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H
#define GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H
#include <memory>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h>
#include <memory>
namespace grpc {
class ServerBuilder;

@ -19,13 +19,15 @@
#define GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/impl/call.h>
#include <grpcpp/impl/rpc_service_method.h>
#include <grpcpp/server_context.h>
#include <grpcpp/support/message_allocator.h>
#include <grpcpp/support/server_callback.h>
#include <grpcpp/support/status.h>
#include "absl/log/absl_check.h"
namespace grpc {
namespace internal {
@ -146,7 +148,7 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
}
void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_);
ABSL_CHECK(!ctx_->sent_initial_metadata_);
this->Ref();
// The callback for this function should not be marked inline because it
// is directly invoking a user-controlled reaction
@ -186,6 +188,8 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
ctx_->set_message_allocator_state(allocator_state);
}
grpc_call* call() override { return call_.call(); }
/// SetupReactor binds the reactor (which also releases any queued
/// operations), maybe calls OnCancel if possible/needed, and maybe marks
/// the completion of the RPC. This should be the last component of the
@ -332,7 +336,7 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
}
void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_);
ABSL_CHECK(!ctx_->sent_initial_metadata_);
this->Ref();
// The callback for this function should not be inlined because it invokes
// a user-controlled reaction, but any resulting OnDone can be inlined in
@ -370,6 +374,8 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
std::function<void()> call_requester)
: ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {}
grpc_call* call() override { return call_.call(); }
void SetupReactor(ServerReadReactor<RequestType>* reactor) {
reactor_.store(reactor, std::memory_order_relaxed);
// The callback for this function should not be inlined because it invokes
@ -534,7 +540,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
}
void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_);
ABSL_CHECK(!ctx_->sent_initial_metadata_);
this->Ref();
// The callback for this function should not be inlined because it invokes
// a user-controlled reaction, but any resulting OnDone can be inlined in
@ -572,7 +578,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
ctx_->sent_initial_metadata_ = true;
}
// TODO(vjpai): don't assert
GPR_ASSERT(write_ops_.SendMessagePtr(resp, options).ok());
ABSL_CHECK(write_ops_.SendMessagePtr(resp, options).ok());
call_.PerformOps(&write_ops_);
}
@ -580,7 +586,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
grpc::Status s) override {
// This combines the write into the finish callback
// TODO(vjpai): don't assert
GPR_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok());
ABSL_CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
Finish(std::move(s));
}
@ -595,6 +601,8 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
req_(req),
call_requester_(std::move(call_requester)) {}
grpc_call* call() override { return call_.call(); }
void SetupReactor(ServerWriteReactor<ResponseType>* reactor) {
reactor_.store(reactor, std::memory_order_relaxed);
// The callback for this function should not be inlined because it invokes
@ -744,7 +752,7 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
}
void SendInitialMetadata() override {
GPR_ASSERT(!ctx_->sent_initial_metadata_);
ABSL_CHECK(!ctx_->sent_initial_metadata_);
this->Ref();
// The callback for this function should not be inlined because it invokes
// a user-controlled reaction, but any resulting OnDone can be inlined in
@ -782,14 +790,14 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
ctx_->sent_initial_metadata_ = true;
}
// TODO(vjpai): don't assert
GPR_ASSERT(write_ops_.SendMessagePtr(resp, options).ok());
ABSL_CHECK(write_ops_.SendMessagePtr(resp, options).ok());
call_.PerformOps(&write_ops_);
}
void WriteAndFinish(const ResponseType* resp, grpc::WriteOptions options,
grpc::Status s) override {
// TODO(vjpai): don't assert
GPR_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok());
ABSL_CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
Finish(std::move(s));
}
@ -807,6 +815,8 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
std::function<void()> call_requester)
: ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {}
grpc_call* call() override { return call_.call(); }
void SetupReactor(ServerBidiReactor<RequestType, ResponseType>* reactor) {
reactor_.store(reactor, std::memory_order_relaxed);
// The callbacks for these functions should not be inlined because they

@ -19,11 +19,11 @@
#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_H
#define GRPCPP_IMPL_SERVER_INITIALIZER_H
#include <grpcpp/server.h>
#include <memory>
#include <vector>
#include <grpcpp/server.h>
namespace grpc {
class Server;
class Service;

@ -19,13 +19,14 @@
#ifndef GRPCPP_IMPL_SERVICE_TYPE_H
#define GRPCPP_IMPL_SERVICE_TYPE_H
#include <grpc/support/log.h>
#include <grpcpp/impl/rpc_service_method.h>
#include <grpcpp/impl/serialization_traits.h>
#include <grpcpp/server_interface.h>
#include <grpcpp/support/config.h>
#include <grpcpp/support/status.h>
#include "absl/log/absl_check.h"
namespace grpc {
class CompletionQueue;
@ -150,9 +151,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index);
GPR_ASSERT(methods_[idx].get() != nullptr &&
"Cannot mark the method as 'async' because it has already been "
"marked as 'generic'.");
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
<< "Cannot mark the method as 'async' because it has already been "
"marked as 'generic'.";
methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::ASYNC);
}
@ -160,9 +161,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index);
GPR_ASSERT(methods_[idx].get() != nullptr &&
"Cannot mark the method as 'raw' because it has already "
"been marked as 'generic'.");
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
<< "Cannot mark the method as 'raw' because it has already "
"been marked as 'generic'.";
methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW);
}
@ -170,10 +171,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index);
GPR_ASSERT(
methods_[idx]->handler() != nullptr &&
"Cannot mark the method as 'generic' because it has already been "
"marked as 'async' or 'raw'.");
ABSL_CHECK_NE(methods_[idx]->handler(), nullptr)
<< "Cannot mark the method as 'generic' because it has already been "
"marked as 'async' or 'raw'.";
methods_[idx].reset();
}
@ -181,8 +181,8 @@ class Service {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index);
GPR_ASSERT(methods_[idx] && methods_[idx]->handler() &&
"Cannot mark an async or generic method Streamed");
ABSL_CHECK(methods_[idx] && methods_[idx]->handler())
<< "Cannot mark an async or generic method Streamed";
methods_[idx]->SetHandler(streamed_method);
// From the server's point of view, streamed unary is a special
@ -196,10 +196,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index);
GPR_ASSERT(
methods_[idx].get() != nullptr &&
"Cannot mark the method as 'callback' because it has already been "
"marked as 'generic'.");
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
<< "Cannot mark the method as 'callback' because it has already been "
"marked as 'generic'.";
methods_[idx]->SetHandler(handler);
methods_[idx]->SetServerApiType(
internal::RpcServiceMethod::ApiType::CALL_BACK);
@ -209,10 +208,9 @@ class Service {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
size_t idx = static_cast<size_t>(index);
GPR_ASSERT(
methods_[idx].get() != nullptr &&
"Cannot mark the method as 'raw callback' because it has already "
"been marked as 'generic'.");
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
<< "Cannot mark the method as 'raw callback' because it has already "
"been marked as 'generic'.";
methods_[idx]->SetHandler(handler);
methods_[idx]->SetServerApiType(
internal::RpcServiceMethod::ApiType::RAW_CALL_BACK);

@ -21,9 +21,8 @@
// IWYU pragma: private, include <grpcpp/support/status.h>
#include <grpc/support/port_platform.h>
#include <grpc/status.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/support/config.h>
#include <grpcpp/support/status_code_enum.h>
@ -32,7 +31,7 @@ namespace grpc {
/// Did it work? If it didn't, why?
///
/// See \a grpc::StatusCode for details on the available code and their meaning.
class GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING Status {
class GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPCXX_DLL Status {
public:
/// Construct an OK instance.
Status() : code_(StatusCode::OK) {

@ -25,20 +25,20 @@
#include <pthread.h>
#endif
#include <mutex>
#include "absl/synchronization/mutex.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include <mutex>
#include "absl/log/absl_check.h"
#include "absl/synchronization/mutex.h"
// The core library is not accessible in C++ codegen headers, and vice versa.
// Thus, we need to have duplicate headers with similar functionality.
// Make sure any change to this file is also reflected in
// src/core/lib/gprpp/sync.h too.
// src/core/util/sync.h too.
//
// Whenever possible, prefer "src/core/lib/gprpp/sync.h" over this file,
// Whenever possible, prefer "src/core/util/sync.h" over this file,
// since in core we do not rely on g_core_codegen_interface and hence do not
// pay the costs of virtual function calls.
@ -105,7 +105,7 @@ class ABSL_SCOPED_LOCKABLE ReleasableMutexLock {
ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete;
void Release() ABSL_UNLOCK_FUNCTION() {
GPR_DEBUG_ASSERT(!released_);
ABSL_DCHECK(!released_);
released_ = true;
mu_->Unlock();
}

@ -0,0 +1,27 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_PASSIVE_LISTENER_H
#define GRPCPP_PASSIVE_LISTENER_H
#include <grpc/passive_listener.h>
namespace grpc {
namespace experimental {
using grpc_core::experimental::PassiveListener;
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_PASSIVE_LISTENER_H

@ -19,12 +19,12 @@
#ifndef GRPCPP_SECURITY_ALTS_CONTEXT_H
#define GRPCPP_SECURITY_ALTS_CONTEXT_H
#include <map>
#include <memory>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/security/auth_context.h>
#include <map>
#include <memory>
struct grpc_gcp_AltsContext;
namespace grpc {

@ -19,13 +19,13 @@
#ifndef GRPCPP_SECURITY_ALTS_UTIL_H
#define GRPCPP_SECURITY_ALTS_UTIL_H
#include <memory>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/security/alts_context.h>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h>
#include <memory>
struct grpc_gcp_AltsContext;
namespace grpc {

@ -0,0 +1,44 @@
//
//
// 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.
//
//
#ifndef GRPCPP_SECURITY_AUDIT_LOGGING_H
#define GRPCPP_SECURITY_AUDIT_LOGGING_H
#include <grpc/grpc_audit_logging.h>
#include <grpcpp/support/string_ref.h>
#include <memory>
#include <string>
#include <utility>
#include "absl/status/statusor.h"
namespace grpc {
namespace experimental {
using grpc_core::experimental::AuditContext; // NOLINT(misc-unused-using-decls)
using grpc_core::experimental::AuditLogger; // NOLINT(misc-unused-using-decls)
using grpc_core::experimental::
AuditLoggerFactory; // NOLINT(misc-unused-using-decls)
using grpc_core::experimental::
RegisterAuditLoggerFactory; // NOLINT(misc-unused-using-decls)
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_SECURITY_AUDIT_LOGGING_H

@ -19,12 +19,12 @@
#ifndef GRPCPP_SECURITY_AUTH_CONTEXT_H
#define GRPCPP_SECURITY_AUTH_CONTEXT_H
#include <iterator>
#include <vector>
#include <grpcpp/support/config.h>
#include <grpcpp/support/string_ref.h>
#include <iterator>
#include <vector>
struct grpc_auth_context;
struct grpc_auth_property;
struct grpc_auth_property_iterator;

@ -19,12 +19,12 @@
#ifndef GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H
#define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H
#include <map>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
#include <map>
namespace grpc {
/// Interface allowing custom server-side authorization based on credentials

@ -15,12 +15,12 @@
#ifndef GRPCPP_SECURITY_AUTHORIZATION_POLICY_PROVIDER_H
#define GRPCPP_SECURITY_AUTHORIZATION_POLICY_PROVIDER_H
#include <memory>
#include <grpc/grpc_security.h>
#include <grpc/status.h>
#include <grpcpp/impl/codegen/status.h>
#include <memory>
namespace grpc {
namespace experimental {

@ -1,43 +0,0 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_SECURITY_BINDER_CREDENTIALS_H
#define GRPCPP_SECURITY_BINDER_CREDENTIALS_H
#include <memory>
#include <grpcpp/security/binder_security_policy.h>
#include <grpcpp/security/server_credentials.h>
namespace grpc {
class ChannelCredentials;
namespace experimental {
/// EXPERIMENTAL Builds Binder ServerCredentials.
///
/// This should be used along with `binder:` URI scheme. The path in the URI can
/// later be used to access the server's endpoint binder.
/// Note that calling \a ServerBuilder::AddListeningPort() with Binder
/// ServerCredentials in a non-supported environment will make the subsequent
/// call to \a ServerBuilder::BuildAndStart() return a null pointer.
std::shared_ptr<grpc::ServerCredentials> BinderServerCredentials(
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
security_policy);
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_SECURITY_BINDER_CREDENTIALS_H

@ -1,82 +0,0 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_SECURITY_BINDER_SECURITY_POLICY_H
#define GRPCPP_SECURITY_BINDER_SECURITY_POLICY_H
#include <memory>
#ifdef GPR_ANDROID
#include <jni.h>
#endif
namespace grpc {
namespace experimental {
namespace binder {
// EXPERIMENTAL Determinines if a connection is allowed to be
// established on Android. See https://source.android.com/security/app-sandbox
// for more info about UID.
class SecurityPolicy {
public:
virtual ~SecurityPolicy() = default;
// Returns true if the UID is authorized to connect.
// Must return the same value for the same inputs so callers can safely cache
// the result.
virtual bool IsAuthorized(int uid) = 0;
};
// EXPERIMENTAL Allows all connection. Anything on the Android device will be
// able to connect, use with caution!
class UntrustedSecurityPolicy : public SecurityPolicy {
public:
UntrustedSecurityPolicy();
~UntrustedSecurityPolicy() override;
bool IsAuthorized(int uid) override;
};
// EXPERIMENTAL Only allows the connections from processes with the same UID. In
// most cases this means "from the same APK".
class InternalOnlySecurityPolicy : public SecurityPolicy {
public:
InternalOnlySecurityPolicy();
~InternalOnlySecurityPolicy() override;
bool IsAuthorized(int uid) override;
};
#ifdef GPR_ANDROID
// EXPERIMENTAL Only allows the connections from the APK that have the same
// signature.
class SameSignatureSecurityPolicy : public SecurityPolicy {
public:
// `context` is required for getting PackageManager Java class
SameSignatureSecurityPolicy(JavaVM* jvm, jobject context);
~SameSignatureSecurityPolicy() override;
bool IsAuthorized(int uid) override;
private:
JavaVM* jvm_;
jobject context_;
};
#endif
} // namespace binder
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_SECURITY_BINDER_SECURITY_POLICY_H

@ -19,10 +19,6 @@
#ifndef GRPCPP_SECURITY_CREDENTIALS_H
#define GRPCPP_SECURITY_CREDENTIALS_H
#include <map>
#include <memory>
#include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/channel.h>
#include <grpcpp/impl/grpc_library.h>
@ -33,13 +29,18 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
#include <map>
#include <memory>
#include <vector>
struct grpc_call;
namespace grpc {
class CallCredentials;
class SecureCallCredentials;
class SecureChannelCredentials;
class ChannelCredentials;
namespace testing {
std::string GetOauth2AccessToken();
}
std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target,
@ -68,26 +69,18 @@ std::shared_ptr<ChannelCredentials> XdsCredentials(
/// \see https://grpc.io/docs/guides/auth.html
class ChannelCredentials : private grpc::internal::GrpcLibrary {
public:
~ChannelCredentials() override;
protected:
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
explicit ChannelCredentials(grpc_channel_credentials* creds);
// TODO(yashykt): We need this friend declaration mainly for access to
// AsSecureCredentials(). Once we are able to remove insecure builds from gRPC
// (and also internal dependencies on the indirect method of creating a
// channel through credentials), we would be able to remove this.
friend std::shared_ptr<ChannelCredentials> grpc::XdsCredentials(
const std::shared_ptr<ChannelCredentials>& fallback_creds);
virtual SecureChannelCredentials* AsSecureCredentials() = 0;
grpc_channel_credentials* c_creds() { return c_creds_; }
private:
friend std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args);
friend std::shared_ptr<grpc::Channel>
grpc::experimental::CreateCustomChannelWithInterceptors(
const grpc::string& target,
@ -96,24 +89,23 @@ class ChannelCredentials : private grpc::internal::GrpcLibrary {
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
friend class XdsChannelCredentialsImpl;
virtual std::shared_ptr<Channel> CreateChannelImpl(
const grpc::string& target, const ChannelArguments& args) = 0;
// This function should have been a pure virtual function, but it is
// implemented as a virtual function so that it does not break API.
virtual std::shared_ptr<Channel> CreateChannelWithInterceptors(
const grpc::string& /*target*/, const ChannelArguments& /*args*/,
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
/*interceptor_creators*/) {
return nullptr;
const grpc::string& target, const ChannelArguments& args) {
return CreateChannelWithInterceptors(target, args, {});
}
// TODO(yashkt): This is a hack that is needed since InsecureCredentials can
// not use grpc_channel_credentials internally and should be removed after
// insecure builds are removed from gRPC.
virtual bool IsInsecure() const { return false; }
virtual std::shared_ptr<Channel> CreateChannelWithInterceptors(
const grpc::string& target, const ChannelArguments& args,
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
grpc_channel_credentials* const c_creds_;
};
/// A call credentials object encapsulates the state needed by a client to
@ -122,22 +114,24 @@ class ChannelCredentials : private grpc::internal::GrpcLibrary {
/// \see https://grpc.io/docs/guides/auth.html
class CallCredentials : private grpc::internal::GrpcLibrary {
public:
~CallCredentials() override;
/// Apply this instance's credentials to \a call.
virtual bool ApplyToCall(grpc_call* call) = 0;
virtual grpc::string DebugString() {
return "CallCredentials did not provide a debug string";
}
bool ApplyToCall(grpc_call* call);
grpc::string DebugString();
protected:
explicit CallCredentials(grpc_call_credentials* creds);
private:
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
friend class CompositeCallCredentialsImpl;
friend std::string grpc::testing::GetOauth2AccessToken();
friend std::shared_ptr<CallCredentials> CompositeCallCredentials(
const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2);
virtual SecureCallCredentials* AsSecureCredentials() = 0;
grpc_call_credentials* c_creds_ = nullptr;
};
/// Options used to build SslCredentials.
@ -253,7 +247,7 @@ class MetadataCredentialsPlugin {
/// Type of credentials this plugin is implementing.
virtual const char* GetType() const { return ""; }
/// Gets the auth metatada produced by this plugin.
/// Gets the auth metadata produced by this plugin.
/// The fully qualified method name is:
/// service_url + "/" + method_name.
/// The channel_auth_context contains (among other things), the identity of
@ -301,7 +295,7 @@ grpc::Status StsCredentialsOptionsFromJson(const std::string& json_string,
/// Creates STS credentials options from the $STS_CREDENTIALS environment
/// variable. This environment variable points to the path of a JSON file
/// comforming to the schema described above.
/// conforming to the schema described above.
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options);
std::shared_ptr<CallCredentials> StsCredentials(

@ -19,22 +19,22 @@
#ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H
#define GRPCPP_SECURITY_SERVER_CREDENTIALS_H
#include <memory>
#include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/security/auth_metadata_processor.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/config.h>
#include <memory>
#include <vector>
struct grpc_server;
namespace grpc {
class Server;
class ServerCredentials;
class SecureServerCredentials;
/// Options to create ServerCredentials with SSL
struct SslServerCredentialsOptions {
/// \warning Deprecated
@ -68,17 +68,23 @@ std::shared_ptr<ServerCredentials> XdsServerCredentials(
/// Wrapper around \a grpc_server_credentials, a way to authenticate a server.
class ServerCredentials : private grpc::internal::GrpcLibrary {
public:
~ServerCredentials() override;
/// This method is not thread-safe and has to be called before the server is
/// started. The last call to this function wins.
virtual void SetAuthMetadataProcessor(
const std::shared_ptr<grpc::AuthMetadataProcessor>& processor) = 0;
const std::shared_ptr<grpc::AuthMetadataProcessor>& processor);
protected:
explicit ServerCredentials(grpc_server_credentials* creds);
grpc_server_credentials* c_creds() const { return c_creds_; }
private:
// Needed for access to AddPortToServer.
friend class Server;
// We need this friend declaration for access to Insecure() and
// AsSecureServerCredentials(). When these two functions are no longer
// necessary, this friend declaration can be removed too.
// Needed for access to c_creds_.
friend class ServerBuilder;
friend std::shared_ptr<ServerCredentials> grpc::XdsServerCredentials(
const std::shared_ptr<ServerCredentials>& fallback_credentials);
@ -87,18 +93,9 @@ class ServerCredentials : private grpc::internal::GrpcLibrary {
///
/// \return bound port number on success, 0 on failure.
// TODO(dgq): the "port" part seems to be a misnomer.
virtual int AddPortToServer(const std::string& addr, grpc_server* server) = 0;
virtual int AddPortToServer(const std::string& addr, grpc_server* server);
// TODO(yashykt): This is a hack since InsecureServerCredentials() cannot use
// grpc_insecure_server_credentials_create() and should be removed after
// insecure builds are removed from gRPC.
virtual bool IsInsecure() const { return false; }
// TODO(yashkt): This is a hack that should be removed once we remove insecure
// builds and the indirect method of adding ports to a server.
virtual SecureServerCredentials* AsSecureServerCredentials() {
return nullptr;
}
grpc_server_credentials* c_creds_;
};
/// Builds SSL ServerCredentials given SSL specific options
@ -119,9 +116,6 @@ std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options);
/// Builds Local ServerCredentials.
std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options);
std::shared_ptr<ServerCredentials> LocalServerCredentials(
grpc_local_connect_type type);

@ -17,22 +17,26 @@
#ifndef GRPCPP_SECURITY_TLS_CERTIFICATE_PROVIDER_H
#define GRPCPP_SECURITY_TLS_CERTIFICATE_PROVIDER_H
#include <memory>
#include <vector>
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/grpc_security_constants.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/support/config.h>
#include <memory>
#include <string>
#include <vector>
#include "absl/status/statusor.h"
namespace grpc {
namespace experimental {
// Interface for a class that handles the process to fetch credential data.
// Implementations should be a wrapper class of an internal provider
// implementation.
class CertificateProviderInterface {
class GRPCXX_DLL CertificateProviderInterface {
public:
virtual ~CertificateProviderInterface() = default;
virtual grpc_tls_certificate_provider* c_provider() = 0;
@ -41,7 +45,7 @@ class CertificateProviderInterface {
// A struct that stores the credential data presented to the peer in handshake
// to show local identity. The private_key and certificate_chain should always
// match.
struct IdentityKeyCertPair {
struct GRPCXX_DLL IdentityKeyCertPair {
std::string private_key;
std::string certificate_chain;
};
@ -49,7 +53,8 @@ struct IdentityKeyCertPair {
// A basic CertificateProviderInterface implementation that will load credential
// data from static string during initialization. This provider will always
// return the same cert data for all cert names, and reloading is not supported.
class StaticDataCertificateProvider : public CertificateProviderInterface {
class GRPCXX_DLL StaticDataCertificateProvider
: public CertificateProviderInterface {
public:
StaticDataCertificateProvider(
const std::string& root_certificate,
@ -66,6 +71,12 @@ class StaticDataCertificateProvider : public CertificateProviderInterface {
grpc_tls_certificate_provider* c_provider() override { return c_provider_; }
// Returns an OK status if the following conditions hold:
// - the root certificates consist of one or more valid PEM blocks, and
// - every identity key-cert pair has a certificate chain that consists of
// valid PEM blocks and has a private key is a valid PEM block.
absl::Status ValidateCredentials() const;
private:
grpc_tls_certificate_provider* c_provider_ = nullptr;
};
@ -84,7 +95,7 @@ class StaticDataCertificateProvider : public CertificateProviderInterface {
// then renaming the new directory to the original name of the old directory.
// 2) using a symlink for the directory. When need to change, put new
// credential data in a new directory, and change symlink.
class FileWatcherCertificateProvider final
class GRPCXX_DLL FileWatcherCertificateProvider final
: public CertificateProviderInterface {
public:
// Constructor to get credential updates from root and identity file paths.
@ -116,6 +127,14 @@ class FileWatcherCertificateProvider final
grpc_tls_certificate_provider* c_provider() override { return c_provider_; }
// Returns an OK status if the following conditions hold:
// - the currently-loaded root certificates, if any, consist of one or more
// valid PEM blocks, and
// - every currently-loaded identity key-cert pair, if any, has a certificate
// chain that consists of valid PEM blocks and has a private key is a valid
// PEM block.
absl::Status ValidateCredentials() const;
private:
grpc_tls_certificate_provider* c_provider_ = nullptr;
};

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