grpc 1.2.5 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1434 -399
- data/etc/roots.pem +34 -150
- data/include/grpc/grpc.h +71 -0
- data/include/grpc/impl/codegen/atm.h +5 -0
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +11 -0
- data/include/grpc/impl/codegen/grpc_types.h +54 -13
- data/include/grpc/impl/codegen/port_platform.h +15 -1
- data/include/grpc/support/alloc.h +2 -1
- data/include/grpc/support/sync.h +4 -0
- data/include/grpc/support/tls.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.h +1 -1
- data/src/core/ext/census/grpc_filter.c +14 -10
- data/src/core/ext/census/grpc_plugin.c +3 -1
- data/src/core/ext/census/trace_label.h +1 -1
- data/src/core/ext/census/trace_propagation.h +1 -1
- data/src/core/ext/census/trace_status.h +1 -1
- data/src/core/ext/census/trace_string.h +1 -1
- data/src/core/ext/census/tracing.h +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
- data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
- data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
- data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
- data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
- data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
- data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
- data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
- data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
- data/src/core/lib/channel/channel_args.c +7 -0
- data/src/core/lib/channel/channel_args.h +2 -0
- data/src/core/lib/channel/channel_stack.c +20 -27
- data/src/core/lib/channel/channel_stack.h +18 -16
- data/src/core/lib/channel/compress_filter.c +20 -18
- data/src/core/lib/channel/connected_channel.c +9 -8
- data/src/core/lib/channel/deadline_filter.c +28 -24
- data/src/core/lib/channel/deadline_filter.h +3 -3
- data/src/core/lib/channel/handshaker.c +3 -2
- data/src/core/lib/channel/http_client_filter.c +119 -61
- data/src/core/lib/channel/http_server_filter.c +124 -69
- data/src/core/lib/channel/message_size_filter.c +23 -19
- data/src/core/lib/http/httpcli.c +8 -6
- data/src/core/lib/http/httpcli_security_connector.c +5 -5
- data/src/core/lib/http/parser.c +57 -31
- data/src/core/lib/iomgr/closure.c +15 -0
- data/src/core/lib/iomgr/closure.h +4 -0
- data/src/core/lib/iomgr/combiner.c +8 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -3
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
- data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
- data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
- data/src/core/lib/iomgr/error.c +360 -177
- data/src/core/lib/iomgr/error.h +31 -33
- data/src/core/lib/iomgr/error_internal.h +30 -9
- data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
- data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
- data/src/core/lib/iomgr/ev_posix.c +6 -0
- data/src/core/lib/iomgr/ev_posix.h +3 -0
- data/src/core/lib/iomgr/exec_ctx.c +6 -0
- data/src/core/lib/iomgr/executor.c +8 -2
- data/src/core/lib/iomgr/load_file.c +6 -3
- data/src/core/lib/iomgr/lockfree_event.c +238 -0
- data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
- data/src/core/lib/iomgr/pollset.h +4 -0
- data/src/core/lib/iomgr/pollset_windows.c +2 -2
- data/src/core/lib/iomgr/port.h +9 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
- data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
- data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
- data/src/core/lib/iomgr/resource_quota.c +19 -4
- data/src/core/lib/iomgr/resource_quota.h +2 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
- data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
- data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
- data/src/core/lib/iomgr/tcp_client.h +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
- data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
- data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
- data/src/core/lib/iomgr/tcp_posix.c +111 -22
- data/src/core/lib/iomgr/tcp_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
- data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
- data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
- data/src/core/lib/iomgr/tcp_uv.c +16 -13
- data/src/core/lib/iomgr/tcp_windows.c +24 -12
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer.h +3 -0
- data/src/core/lib/iomgr/timer_generic.c +257 -72
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_heap.c +8 -8
- data/src/core/lib/iomgr/udp_server.c +54 -24
- data/src/core/lib/iomgr/udp_server.h +7 -7
- data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
- data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
- data/src/core/lib/profiling/basic_timers.c +1 -1
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
- data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
- data/src/core/lib/security/transport/client_auth_filter.c +33 -26
- data/src/core/lib/security/transport/secure_endpoint.c +8 -5
- data/src/core/lib/security/transport/security_connector.c +37 -37
- data/src/core/lib/security/transport/security_connector.h +1 -1
- data/src/core/lib/security/transport/security_handshaker.c +15 -12
- data/src/core/lib/security/transport/server_auth_filter.c +20 -18
- data/src/core/lib/security/transport/tsi_error.c +5 -3
- data/src/core/lib/security/transport/tsi_error.h +1 -1
- data/src/core/lib/{security/util → slice}/b64.c +21 -6
- data/src/core/lib/{security/util → slice}/b64.h +16 -4
- data/src/core/lib/slice/slice.c +4 -2
- data/src/core/lib/slice/slice_buffer.c +16 -14
- data/src/core/lib/support/arena.c +98 -0
- data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
- data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
- data/src/core/lib/support/cpu_linux.c +5 -0
- data/src/core/lib/support/sync.c +4 -0
- data/src/core/lib/support/time.c +4 -10
- data/src/core/lib/support/wrap_memcpy.c +3 -1
- data/src/core/lib/surface/call.c +252 -221
- data/src/core/lib/surface/channel.c +72 -21
- data/src/core/lib/surface/channel.h +8 -0
- data/src/core/lib/surface/completion_queue.c +2 -3
- data/src/core/lib/surface/completion_queue_factory.c +77 -0
- data/src/core/lib/surface/completion_queue_factory.h +51 -0
- data/src/core/lib/surface/init_secure.c +3 -1
- data/src/core/lib/surface/lame_client.c +18 -14
- data/src/core/lib/surface/server.c +43 -41
- data/src/core/lib/surface/validate_metadata.c +8 -4
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.h +1 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/error_utils.c +17 -17
- data/src/core/lib/transport/error_utils.h +1 -1
- data/src/core/lib/transport/metadata_batch.c +6 -7
- data/src/core/lib/transport/pid_controller.c +1 -0
- data/src/core/lib/transport/service_config.c +12 -0
- data/src/core/lib/transport/service_config.h +6 -0
- data/src/core/lib/transport/transport.c +29 -17
- data/src/core/lib/transport/transport.h +85 -42
- data/src/core/lib/transport/transport_impl.h +5 -3
- data/src/core/lib/transport/transport_op_string.c +20 -14
- data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
- data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
- data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
- data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
- data/src/ruby/ext/grpc/rb_channel.c +520 -93
- data/src/ruby/ext/grpc/rb_channel.h +2 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
- data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
- data/src/ruby/ext/grpc/rb_grpc.c +29 -7
- data/src/ruby/ext/grpc/rb_grpc.h +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_connection_spec.rb +173 -0
- data/src/ruby/spec/channel_spec.rb +29 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
- data/third_party/cares/ares_build.h +264 -0
- data/third_party/cares/cares/ares.h +636 -0
- data/third_party/cares/cares/ares__close_sockets.c +61 -0
- data/third_party/cares/cares/ares__get_hostent.c +261 -0
- data/third_party/cares/cares/ares__read_line.c +73 -0
- data/third_party/cares/cares/ares__timeval.c +111 -0
- data/third_party/cares/cares/ares_cancel.c +63 -0
- data/third_party/cares/cares/ares_create_query.c +202 -0
- data/third_party/cares/cares/ares_data.c +221 -0
- data/third_party/cares/cares/ares_data.h +72 -0
- data/third_party/cares/cares/ares_destroy.c +108 -0
- data/third_party/cares/cares/ares_dns.h +103 -0
- data/third_party/cares/cares/ares_expand_name.c +205 -0
- data/third_party/cares/cares/ares_expand_string.c +70 -0
- data/third_party/cares/cares/ares_fds.c +59 -0
- data/third_party/cares/cares/ares_free_hostent.c +41 -0
- data/third_party/cares/cares/ares_free_string.c +25 -0
- data/third_party/cares/cares/ares_getenv.c +30 -0
- data/third_party/cares/cares/ares_getenv.h +26 -0
- data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
- data/third_party/cares/cares/ares_gethostbyname.c +518 -0
- data/third_party/cares/cares/ares_getnameinfo.c +422 -0
- data/third_party/cares/cares/ares_getopt.c +122 -0
- data/third_party/cares/cares/ares_getopt.h +53 -0
- data/third_party/cares/cares/ares_getsock.c +66 -0
- data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
- data/third_party/cares/cares/ares_init.c +2146 -0
- data/third_party/cares/cares/ares_iphlpapi.h +221 -0
- data/third_party/cares/cares/ares_ipv6.h +78 -0
- data/third_party/cares/cares/ares_library_init.c +167 -0
- data/third_party/cares/cares/ares_library_init.h +42 -0
- data/third_party/cares/cares/ares_llist.c +63 -0
- data/third_party/cares/cares/ares_llist.h +39 -0
- data/third_party/cares/cares/ares_mkquery.c +24 -0
- data/third_party/cares/cares/ares_nowarn.c +260 -0
- data/third_party/cares/cares/ares_nowarn.h +61 -0
- data/third_party/cares/cares/ares_options.c +402 -0
- data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
- data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
- data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
- data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
- data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
- data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
- data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
- data/third_party/cares/cares/ares_platform.c +11035 -0
- data/third_party/cares/cares/ares_platform.h +43 -0
- data/third_party/cares/cares/ares_private.h +363 -0
- data/third_party/cares/cares/ares_process.c +1359 -0
- data/third_party/cares/cares/ares_query.c +186 -0
- data/third_party/cares/cares/ares_rules.h +125 -0
- data/third_party/cares/cares/ares_search.c +316 -0
- data/third_party/cares/cares/ares_send.c +131 -0
- data/third_party/cares/cares/ares_setup.h +217 -0
- data/third_party/cares/cares/ares_strcasecmp.c +66 -0
- data/third_party/cares/cares/ares_strcasecmp.h +30 -0
- data/third_party/cares/cares/ares_strdup.c +49 -0
- data/third_party/cares/cares/ares_strdup.h +24 -0
- data/third_party/cares/cares/ares_strerror.c +56 -0
- data/third_party/cares/cares/ares_timeout.c +88 -0
- data/third_party/cares/cares/ares_version.c +11 -0
- data/third_party/cares/cares/ares_version.h +24 -0
- data/third_party/cares/cares/ares_writev.c +79 -0
- data/third_party/cares/cares/bitncmp.c +59 -0
- data/third_party/cares/cares/bitncmp.h +26 -0
- data/third_party/cares/cares/config-win32.h +377 -0
- data/third_party/cares/cares/inet_net_pton.c +450 -0
- data/third_party/cares/cares/inet_ntop.c +208 -0
- data/third_party/cares/cares/setup_once.h +554 -0
- data/third_party/cares/cares/windows_port.c +22 -0
- data/third_party/cares/config_darwin/ares_config.h +523 -0
- data/third_party/cares/config_linux/ares_config.h +524 -0
- metadata +164 -68
@@ -0,0 +1,64 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2016, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
|
36
|
+
|
37
|
+
#include "src/core/lib/iomgr/exec_ctx.h"
|
38
|
+
#include "src/core/lib/iomgr/iomgr.h"
|
39
|
+
#include "src/core/lib/iomgr/polling_entity.h"
|
40
|
+
#include "src/core/lib/iomgr/resolve_address.h"
|
41
|
+
|
42
|
+
/* Asynchronously resolve addr. Use \a default_port if a port isn't designated
|
43
|
+
in addr, otherwise use the port in addr. grpc_ares_init() must be called at
|
44
|
+
least once before this function. \a on_done may be called directly in this
|
45
|
+
function without being scheduled with \a exec_ctx, it must not try to acquire
|
46
|
+
locks that are being held by the caller. */
|
47
|
+
extern void (*grpc_resolve_address_ares)(grpc_exec_ctx *exec_ctx,
|
48
|
+
const char *addr,
|
49
|
+
const char *default_port,
|
50
|
+
grpc_pollset_set *interested_parties,
|
51
|
+
grpc_closure *on_done,
|
52
|
+
grpc_resolved_addresses **addresses);
|
53
|
+
|
54
|
+
/* Initialize gRPC ares wrapper. Must be called at least once before
|
55
|
+
grpc_resolve_address_ares(). */
|
56
|
+
grpc_error *grpc_ares_init(void);
|
57
|
+
|
58
|
+
/* Uninitialized gRPC ares wrapper. If there was more than one previous call to
|
59
|
+
grpc_ares_init(), this function uninitializes the gRPC ares wrapper only if
|
60
|
+
it has been called the same number of times as grpc_ares_init(). */
|
61
|
+
void grpc_ares_cleanup(void);
|
62
|
+
|
63
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H \
|
64
|
+
*/
|
@@ -37,13 +37,14 @@
|
|
37
37
|
#include <grpc/support/host_port.h>
|
38
38
|
#include <grpc/support/string_util.h>
|
39
39
|
|
40
|
-
#include "src/core/ext/client_channel/lb_policy_registry.h"
|
41
|
-
#include "src/core/ext/client_channel/resolver_registry.h"
|
40
|
+
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
41
|
+
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
42
42
|
#include "src/core/lib/channel/channel_args.h"
|
43
43
|
#include "src/core/lib/iomgr/combiner.h"
|
44
44
|
#include "src/core/lib/iomgr/resolve_address.h"
|
45
45
|
#include "src/core/lib/iomgr/timer.h"
|
46
46
|
#include "src/core/lib/support/backoff.h"
|
47
|
+
#include "src/core/lib/support/env.h"
|
47
48
|
#include "src/core/lib/support/string.h"
|
48
49
|
|
49
50
|
#define GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS 1
|
@@ -113,8 +114,9 @@ static void dns_shutdown_locked(grpc_exec_ctx *exec_ctx,
|
|
113
114
|
}
|
114
115
|
if (r->next_completion != NULL) {
|
115
116
|
*r->target_result = NULL;
|
116
|
-
grpc_closure_sched(
|
117
|
-
|
117
|
+
grpc_closure_sched(
|
118
|
+
exec_ctx, r->next_completion,
|
119
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
|
118
120
|
r->next_completion = NULL;
|
119
121
|
}
|
120
122
|
}
|
@@ -303,7 +305,21 @@ static grpc_resolver_factory *dns_resolver_factory_create() {
|
|
303
305
|
}
|
304
306
|
|
305
307
|
void grpc_resolver_dns_native_init(void) {
|
306
|
-
|
308
|
+
char *resolver = gpr_getenv("GRPC_DNS_RESOLVER");
|
309
|
+
if (resolver != NULL && gpr_stricmp(resolver, "native") == 0) {
|
310
|
+
gpr_log(GPR_DEBUG, "Using native dns resolver");
|
311
|
+
grpc_register_resolver_type(dns_resolver_factory_create());
|
312
|
+
} else {
|
313
|
+
grpc_resolver_factory *existing_factory =
|
314
|
+
grpc_resolver_factory_lookup("dns");
|
315
|
+
if (existing_factory == NULL) {
|
316
|
+
gpr_log(GPR_DEBUG, "Using native dns resolver");
|
317
|
+
grpc_register_resolver_type(dns_resolver_factory_create());
|
318
|
+
} else {
|
319
|
+
grpc_resolver_factory_unref(existing_factory);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
gpr_free(resolver);
|
307
323
|
}
|
308
324
|
|
309
325
|
void grpc_resolver_dns_native_shutdown(void) {}
|
@@ -41,9 +41,9 @@
|
|
41
41
|
#include <grpc/support/port_platform.h>
|
42
42
|
#include <grpc/support/string_util.h>
|
43
43
|
|
44
|
-
#include "src/core/ext/client_channel/lb_policy_factory.h"
|
45
|
-
#include "src/core/ext/client_channel/parse_address.h"
|
46
|
-
#include "src/core/ext/client_channel/resolver_registry.h"
|
44
|
+
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
45
|
+
#include "src/core/ext/filters/client_channel/parse_address.h"
|
46
|
+
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
47
47
|
#include "src/core/lib/channel/channel_args.h"
|
48
48
|
#include "src/core/lib/iomgr/combiner.h"
|
49
49
|
#include "src/core/lib/iomgr/resolve_address.h"
|
@@ -31,12 +31,12 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H
|
36
36
|
|
37
|
-
#include "src/core/ext/client_channel/client_channel_factory.h"
|
38
|
-
#include "src/core/ext/client_channel/resolver.h"
|
39
|
-
#include "src/core/ext/client_channel/uri_parser.h"
|
37
|
+
#include "src/core/ext/filters/client_channel/client_channel_factory.h"
|
38
|
+
#include "src/core/ext/filters/client_channel/resolver.h"
|
39
|
+
#include "src/core/ext/filters/client_channel/uri_parser.h"
|
40
40
|
#include "src/core/lib/iomgr/pollset_set.h"
|
41
41
|
|
42
42
|
typedef struct grpc_resolver_factory grpc_resolver_factory;
|
@@ -82,4 +82,4 @@ grpc_resolver *grpc_resolver_factory_create_resolver(
|
|
82
82
|
char *grpc_resolver_factory_get_default_authority(
|
83
83
|
grpc_resolver_factory *factory, grpc_uri *uri);
|
84
84
|
|
85
|
-
#endif /*
|
85
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */
|
@@ -31,7 +31,7 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#include "src/core/ext/client_channel/resolver_registry.h"
|
34
|
+
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
35
35
|
|
36
36
|
#include <string.h>
|
37
37
|
|
@@ -93,7 +93,6 @@ static grpc_resolver_factory *lookup_factory(const char *name) {
|
|
93
93
|
return g_all_of_the_resolvers[i];
|
94
94
|
}
|
95
95
|
}
|
96
|
-
|
97
96
|
return NULL;
|
98
97
|
}
|
99
98
|
|
@@ -31,10 +31,10 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H
|
36
36
|
|
37
|
-
#include "src/core/ext/client_channel/resolver_factory.h"
|
37
|
+
#include "src/core/ext/filters/client_channel/resolver_factory.h"
|
38
38
|
#include "src/core/lib/iomgr/pollset_set.h"
|
39
39
|
|
40
40
|
void grpc_resolver_registry_init();
|
@@ -81,4 +81,4 @@ char *grpc_get_default_authority(grpc_exec_ctx *exec_ctx, const char *target);
|
|
81
81
|
char *grpc_resolver_factory_add_default_prefix_if_needed(
|
82
82
|
grpc_exec_ctx *exec_ctx, const char *target);
|
83
83
|
|
84
|
-
#endif /*
|
84
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */
|
@@ -0,0 +1,210 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include "src/core/ext/filters/client_channel/retry_throttle.h"
|
35
|
+
|
36
|
+
#include <limits.h>
|
37
|
+
#include <string.h>
|
38
|
+
|
39
|
+
#include <grpc/support/alloc.h>
|
40
|
+
#include <grpc/support/atm.h>
|
41
|
+
#include <grpc/support/avl.h>
|
42
|
+
#include <grpc/support/string_util.h>
|
43
|
+
#include <grpc/support/sync.h>
|
44
|
+
|
45
|
+
//
|
46
|
+
// server_retry_throttle_data
|
47
|
+
//
|
48
|
+
|
49
|
+
struct grpc_server_retry_throttle_data {
|
50
|
+
gpr_refcount refs;
|
51
|
+
int max_milli_tokens;
|
52
|
+
int milli_token_ratio;
|
53
|
+
gpr_atm milli_tokens;
|
54
|
+
// A pointer to the replacement for this grpc_server_retry_throttle_data
|
55
|
+
// entry. If non-NULL, then this entry is stale and must not be used.
|
56
|
+
// We hold a reference to the replacement.
|
57
|
+
gpr_atm replacement;
|
58
|
+
};
|
59
|
+
|
60
|
+
static void get_replacement_throttle_data_if_needed(
|
61
|
+
grpc_server_retry_throttle_data** throttle_data) {
|
62
|
+
while (true) {
|
63
|
+
grpc_server_retry_throttle_data* new_throttle_data =
|
64
|
+
(grpc_server_retry_throttle_data*)gpr_atm_acq_load(
|
65
|
+
&(*throttle_data)->replacement);
|
66
|
+
if (new_throttle_data == NULL) return;
|
67
|
+
*throttle_data = new_throttle_data;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
bool grpc_server_retry_throttle_data_record_failure(
|
72
|
+
grpc_server_retry_throttle_data* throttle_data) {
|
73
|
+
// First, check if we are stale and need to be replaced.
|
74
|
+
get_replacement_throttle_data_if_needed(&throttle_data);
|
75
|
+
// We decrement milli_tokens by 1000 (1 token) for each failure.
|
76
|
+
const int new_value = (int)gpr_atm_no_barrier_clamped_add(
|
77
|
+
&throttle_data->milli_tokens, (gpr_atm)-1000, (gpr_atm)0,
|
78
|
+
(gpr_atm)throttle_data->max_milli_tokens);
|
79
|
+
// Retries are allowed as long as the new value is above the threshold
|
80
|
+
// (max_milli_tokens / 2).
|
81
|
+
return new_value > throttle_data->max_milli_tokens / 2;
|
82
|
+
}
|
83
|
+
|
84
|
+
void grpc_server_retry_throttle_data_record_success(
|
85
|
+
grpc_server_retry_throttle_data* throttle_data) {
|
86
|
+
// First, check if we are stale and need to be replaced.
|
87
|
+
get_replacement_throttle_data_if_needed(&throttle_data);
|
88
|
+
// We increment milli_tokens by milli_token_ratio for each success.
|
89
|
+
gpr_atm_no_barrier_clamped_add(
|
90
|
+
&throttle_data->milli_tokens, (gpr_atm)throttle_data->milli_token_ratio,
|
91
|
+
(gpr_atm)0, (gpr_atm)throttle_data->max_milli_tokens);
|
92
|
+
}
|
93
|
+
|
94
|
+
grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_ref(
|
95
|
+
grpc_server_retry_throttle_data* throttle_data) {
|
96
|
+
gpr_ref(&throttle_data->refs);
|
97
|
+
return throttle_data;
|
98
|
+
}
|
99
|
+
|
100
|
+
void grpc_server_retry_throttle_data_unref(
|
101
|
+
grpc_server_retry_throttle_data* throttle_data) {
|
102
|
+
if (gpr_unref(&throttle_data->refs)) {
|
103
|
+
grpc_server_retry_throttle_data* replacement =
|
104
|
+
(grpc_server_retry_throttle_data*)gpr_atm_acq_load(
|
105
|
+
&throttle_data->replacement);
|
106
|
+
if (replacement != NULL) {
|
107
|
+
grpc_server_retry_throttle_data_unref(replacement);
|
108
|
+
}
|
109
|
+
gpr_free(throttle_data);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
|
114
|
+
int max_milli_tokens, int milli_token_ratio,
|
115
|
+
grpc_server_retry_throttle_data* old_throttle_data) {
|
116
|
+
grpc_server_retry_throttle_data* throttle_data =
|
117
|
+
gpr_malloc(sizeof(*throttle_data));
|
118
|
+
memset(throttle_data, 0, sizeof(*throttle_data));
|
119
|
+
gpr_ref_init(&throttle_data->refs, 1);
|
120
|
+
throttle_data->max_milli_tokens = max_milli_tokens;
|
121
|
+
throttle_data->milli_token_ratio = milli_token_ratio;
|
122
|
+
int initial_milli_tokens = max_milli_tokens;
|
123
|
+
// If there was a pre-existing entry for this server name, initialize
|
124
|
+
// the token count by scaling proportionately to the old data. This
|
125
|
+
// ensures that if we're already throttling retries on the old scale,
|
126
|
+
// we will start out doing the same thing on the new one.
|
127
|
+
if (old_throttle_data != NULL) {
|
128
|
+
double token_fraction =
|
129
|
+
(int)gpr_atm_acq_load(&old_throttle_data->milli_tokens) /
|
130
|
+
(double)old_throttle_data->max_milli_tokens;
|
131
|
+
initial_milli_tokens = (int)(token_fraction * max_milli_tokens);
|
132
|
+
}
|
133
|
+
gpr_atm_rel_store(&throttle_data->milli_tokens,
|
134
|
+
(gpr_atm)initial_milli_tokens);
|
135
|
+
// If there was a pre-existing entry, mark it as stale and give it a
|
136
|
+
// pointer to the new entry, which is its replacement.
|
137
|
+
if (old_throttle_data != NULL) {
|
138
|
+
grpc_server_retry_throttle_data_ref(throttle_data);
|
139
|
+
gpr_atm_rel_store(&old_throttle_data->replacement, (gpr_atm)throttle_data);
|
140
|
+
}
|
141
|
+
return throttle_data;
|
142
|
+
}
|
143
|
+
|
144
|
+
//
|
145
|
+
// avl vtable for string -> server_retry_throttle_data map
|
146
|
+
//
|
147
|
+
|
148
|
+
static void* copy_server_name(void* key) { return gpr_strdup(key); }
|
149
|
+
|
150
|
+
static long compare_server_name(void* key1, void* key2) {
|
151
|
+
return strcmp(key1, key2);
|
152
|
+
}
|
153
|
+
|
154
|
+
static void destroy_server_retry_throttle_data(void* value) {
|
155
|
+
grpc_server_retry_throttle_data* throttle_data = value;
|
156
|
+
grpc_server_retry_throttle_data_unref(throttle_data);
|
157
|
+
}
|
158
|
+
|
159
|
+
static void* copy_server_retry_throttle_data(void* value) {
|
160
|
+
grpc_server_retry_throttle_data* throttle_data = value;
|
161
|
+
return grpc_server_retry_throttle_data_ref(throttle_data);
|
162
|
+
}
|
163
|
+
|
164
|
+
static const gpr_avl_vtable avl_vtable = {
|
165
|
+
gpr_free /* destroy_key */, copy_server_name, compare_server_name,
|
166
|
+
destroy_server_retry_throttle_data, copy_server_retry_throttle_data};
|
167
|
+
|
168
|
+
//
|
169
|
+
// server_retry_throttle_map
|
170
|
+
//
|
171
|
+
|
172
|
+
static gpr_mu g_mu;
|
173
|
+
static gpr_avl g_avl;
|
174
|
+
|
175
|
+
void grpc_retry_throttle_map_init() {
|
176
|
+
gpr_mu_init(&g_mu);
|
177
|
+
g_avl = gpr_avl_create(&avl_vtable);
|
178
|
+
}
|
179
|
+
|
180
|
+
void grpc_retry_throttle_map_shutdown() {
|
181
|
+
gpr_mu_destroy(&g_mu);
|
182
|
+
gpr_avl_unref(g_avl);
|
183
|
+
}
|
184
|
+
|
185
|
+
grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
|
186
|
+
const char* server_name, int max_milli_tokens, int milli_token_ratio) {
|
187
|
+
gpr_mu_lock(&g_mu);
|
188
|
+
grpc_server_retry_throttle_data* throttle_data =
|
189
|
+
gpr_avl_get(g_avl, (char*)server_name);
|
190
|
+
if (throttle_data == NULL) {
|
191
|
+
// Entry not found. Create a new one.
|
192
|
+
throttle_data = grpc_server_retry_throttle_data_create(
|
193
|
+
max_milli_tokens, milli_token_ratio, NULL);
|
194
|
+
g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data);
|
195
|
+
} else {
|
196
|
+
if (throttle_data->max_milli_tokens != max_milli_tokens ||
|
197
|
+
throttle_data->milli_token_ratio != milli_token_ratio) {
|
198
|
+
// Entry found but with old parameters. Create a new one based on
|
199
|
+
// the original one.
|
200
|
+
throttle_data = grpc_server_retry_throttle_data_create(
|
201
|
+
max_milli_tokens, milli_token_ratio, throttle_data);
|
202
|
+
g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data);
|
203
|
+
} else {
|
204
|
+
// Entry found. Increase refcount.
|
205
|
+
grpc_server_retry_throttle_data_ref(throttle_data);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
gpr_mu_unlock(&g_mu);
|
209
|
+
return throttle_data;
|
210
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H
|
36
|
+
|
37
|
+
#include <stdbool.h>
|
38
|
+
|
39
|
+
/// Tracks retry throttling data for an individual server name.
|
40
|
+
typedef struct grpc_server_retry_throttle_data grpc_server_retry_throttle_data;
|
41
|
+
|
42
|
+
/// Records a failure. Returns true if it's okay to send a retry.
|
43
|
+
bool grpc_server_retry_throttle_data_record_failure(
|
44
|
+
grpc_server_retry_throttle_data* throttle_data);
|
45
|
+
/// Records a success.
|
46
|
+
void grpc_server_retry_throttle_data_record_success(
|
47
|
+
grpc_server_retry_throttle_data* throttle_data);
|
48
|
+
|
49
|
+
grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_ref(
|
50
|
+
grpc_server_retry_throttle_data* throttle_data);
|
51
|
+
void grpc_server_retry_throttle_data_unref(
|
52
|
+
grpc_server_retry_throttle_data* throttle_data);
|
53
|
+
|
54
|
+
/// Initializes global map of failure data for each server name.
|
55
|
+
void grpc_retry_throttle_map_init();
|
56
|
+
/// Shuts down global map of failure data for each server name.
|
57
|
+
void grpc_retry_throttle_map_shutdown();
|
58
|
+
|
59
|
+
/// Returns a reference to the failure data for \a server_name, creating
|
60
|
+
/// a new entry if needed.
|
61
|
+
/// Caller must eventually unref via \a grpc_server_retry_throttle_data_unref().
|
62
|
+
grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
|
63
|
+
const char* server_name, int max_milli_tokens, int milli_token_ratio);
|
64
|
+
|
65
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H */
|