grpc 0.14.1 → 0.15.0
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 +1398 -817
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +10 -1
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +70 -0
- data/include/grpc/impl/codegen/atm.h +2 -2
- data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
- data/include/grpc/impl/codegen/compression_types.h +39 -5
- data/include/grpc/impl/codegen/connectivity_state.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -0
- data/include/grpc/impl/codegen/log.h +2 -1
- data/include/grpc/impl/codegen/port_platform.h +30 -12
- data/include/grpc/impl/codegen/slice_buffer.h +2 -3
- data/include/grpc/impl/codegen/sync.h +2 -2
- data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
- data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
- data/include/grpc/support/avl.h +5 -0
- data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
- data/include/grpc/support/string_util.h +2 -1
- data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
- data/src/core/ext/census/gen/census.pb.c +179 -0
- data/src/core/ext/census/gen/census.pb.h +294 -0
- data/src/core/ext/census/grpc_filter.c +11 -7
- data/src/core/ext/client_config/channel_connectivity.c +28 -14
- data/src/core/ext/client_config/client_channel.c +77 -53
- data/src/core/ext/client_config/connector.h +1 -1
- data/src/core/ext/client_config/lb_policy.c +9 -6
- data/src/core/ext/client_config/lb_policy.h +9 -5
- data/src/core/ext/client_config/subchannel.c +58 -39
- data/src/core/ext/client_config/subchannel.h +3 -2
- data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
- data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
- data/src/core/ext/client_config/subchannel_index.c +20 -9
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
- data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
- data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
- data/src/core/ext/load_reporting/load_reporting.c +133 -0
- data/src/core/ext/load_reporting/load_reporting.h +75 -0
- data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
- data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
- data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
- data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
- data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
- data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
- data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
- data/src/core/lib/channel/channel_args.c +26 -12
- data/src/core/lib/channel/channel_args.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -8
- data/src/core/lib/channel/channel_stack.h +27 -11
- data/src/core/lib/channel/channel_stack_builder.c +2 -2
- data/src/core/lib/channel/compress_filter.c +26 -31
- data/src/core/lib/channel/compress_filter.h +4 -4
- data/src/core/lib/channel/connected_channel.c +7 -5
- data/src/core/lib/channel/http_client_filter.c +34 -8
- data/src/core/lib/channel/http_client_filter.h +1 -1
- data/src/core/lib/channel/http_server_filter.c +21 -12
- data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
- data/src/core/lib/http/httpcli.c +81 -59
- data/src/core/lib/http/httpcli.h +11 -15
- data/src/core/lib/http/httpcli_security_connector.c +5 -3
- data/src/core/lib/http/parser.c +127 -118
- data/src/core/lib/http/parser.h +11 -6
- data/src/core/lib/iomgr/closure.c +20 -16
- data/src/core/lib/iomgr/closure.h +19 -15
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
- data/src/core/lib/iomgr/error.c +535 -0
- data/src/core/lib/iomgr/error.h +192 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
- data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
- data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
- data/src/core/lib/iomgr/ev_posix.c +104 -14
- data/src/core/lib/iomgr/ev_posix.h +17 -7
- data/src/core/lib/iomgr/exec_ctx.c +25 -7
- data/src/core/lib/iomgr/exec_ctx.h +27 -8
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/iocp_windows.c +2 -41
- data/src/core/lib/iomgr/iocp_windows.h +0 -8
- data/src/core/lib/iomgr/iomgr.c +5 -4
- data/src/core/lib/iomgr/iomgr_posix.c +5 -1
- data/src/core/lib/iomgr/iomgr_windows.c +1 -1
- data/src/core/lib/{support → iomgr}/load_file.c +15 -17
- data/src/core/lib/{support → iomgr}/load_file.h +8 -7
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +6 -5
- data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
- data/src/core/lib/iomgr/pollset_windows.c +10 -6
- data/src/core/lib/iomgr/resolve_address.h +5 -9
- data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
- data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
- data/src/core/lib/iomgr/sockaddr.h +2 -2
- data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
- data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
- data/src/core/lib/iomgr/socket_windows.c +61 -2
- data/src/core/lib/iomgr/socket_windows.h +13 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
- data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
- data/src/core/lib/iomgr/tcp_posix.c +43 -39
- data/src/core/lib/iomgr/tcp_server.h +5 -3
- data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
- data/src/core/lib/iomgr/tcp_windows.c +45 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -1
- data/src/core/lib/iomgr/timer.c +26 -13
- data/src/core/lib/iomgr/udp_server.c +28 -4
- data/src/core/lib/iomgr/udp_server.h +5 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
- data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
- data/src/core/lib/iomgr/workqueue.h +5 -4
- data/src/core/lib/iomgr/workqueue_posix.c +40 -26
- data/src/core/lib/iomgr/workqueue_windows.c +2 -2
- data/src/core/lib/profiling/basic_timers.c +2 -2
- data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
- data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +233 -0
- data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
- data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
- data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
- data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
- data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
- data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
- data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
- data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
- data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
- data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
- data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
- data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
- data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
- data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
- data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
- data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
- data/src/core/lib/security/transport/tsi_error.c +40 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
- data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/support/avl.c +11 -0
- data/src/core/lib/support/cpu_windows.c +2 -2
- data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
- data/src/core/lib/support/log.c +3 -1
- data/src/core/lib/support/log_linux.c +2 -2
- data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
- data/src/core/lib/support/murmur_hash.c +3 -5
- data/src/core/lib/support/string.c +10 -0
- data/src/core/lib/support/string.h +4 -0
- data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
- data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
- data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
- data/src/core/lib/support/subprocess_windows.c +1 -1
- data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
- data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
- data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
- data/src/core/lib/support/tmpfile_msys.c +1 -1
- data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
- data/src/core/lib/surface/alarm.c +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +13 -6
- data/src/core/lib/surface/call.c +323 -123
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/channel.c +64 -15
- data/src/core/lib/surface/channel.h +9 -0
- data/src/core/lib/surface/channel_ping.c +3 -3
- data/src/core/lib/surface/completion_queue.c +75 -19
- data/src/core/lib/surface/completion_queue.h +7 -2
- data/src/core/lib/surface/init.c +2 -1
- data/src/core/lib/surface/init_secure.c +4 -4
- data/src/core/lib/surface/lame_client.c +12 -8
- data/src/core/lib/surface/server.c +213 -120
- data/src/core/lib/surface/server.h +1 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/connectivity_state.c +40 -18
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/metadata.c +23 -23
- data/src/core/lib/transport/metadata.h +4 -0
- data/src/core/lib/transport/metadata_batch.c +9 -0
- data/src/core/lib/transport/metadata_batch.h +3 -0
- data/src/core/lib/transport/static_metadata.c +6 -5
- data/src/core/lib/transport/static_metadata.h +64 -60
- data/src/core/lib/transport/transport.c +24 -12
- data/src/core/lib/transport/transport.h +6 -5
- data/src/core/lib/transport/transport_impl.h +4 -0
- data/src/core/lib/transport/transport_op_string.c +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
- data/src/ruby/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- data/src/ruby/lib/grpc/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +86 -48
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
- data/src/core/lib/security/credentials.c +0 -1296
- data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -31,6 +31,34 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
+
/** Round Robin Policy.
|
35
|
+
*
|
36
|
+
* This policy keeps:
|
37
|
+
* - A circular list of ready (connected) subchannels, the *readylist*. An empty
|
38
|
+
* readylist consists solely of its root (dummy) node.
|
39
|
+
* - A pointer to the last element picked from the readylist, the *lastpick*.
|
40
|
+
* Initially set to point to the readylist's root.
|
41
|
+
*
|
42
|
+
* Behavior:
|
43
|
+
* - When a subchannel connects, it's *prepended* to the readylist's root node.
|
44
|
+
* Ie, if readylist = A <-> B <-> ROOT <-> C
|
45
|
+
* ^ ^
|
46
|
+
* |____________________|
|
47
|
+
* and subchannel D becomes connected, the addition of D to the readylist
|
48
|
+
* results in readylist = A <-> B <-> D <-> ROOT <-> C
|
49
|
+
* ^ ^
|
50
|
+
* |__________________________|
|
51
|
+
* - When a subchannel disconnects, it's removed from the readylist. If the
|
52
|
+
* subchannel being removed was the most recently picked, the *lastpick*
|
53
|
+
* pointer moves to the removed node's previous element. Note that if the
|
54
|
+
* readylist only had one element, this is still legal, as the lastpick would
|
55
|
+
* point to the dummy root node, for an empty readylist.
|
56
|
+
* - Upon picking, *lastpick* is updated to point to the returned (connected)
|
57
|
+
* subchannel. Note that it's possible that the selected subchannel becomes
|
58
|
+
* disconnected in the interim between the selection and the actual usage of
|
59
|
+
* the subchannel by the caller.
|
60
|
+
*/
|
61
|
+
|
34
62
|
#include <string.h>
|
35
63
|
|
36
64
|
#include <grpc/support/alloc.h>
|
@@ -48,7 +76,7 @@ int grpc_lb_round_robin_trace = 0;
|
|
48
76
|
* Once a pick is available, \a target is updated and \a on_complete called. */
|
49
77
|
typedef struct pending_pick {
|
50
78
|
struct pending_pick *next;
|
51
|
-
|
79
|
+
grpc_polling_entity *pollent;
|
52
80
|
uint32_t initial_metadata_flags;
|
53
81
|
grpc_connected_subchannel **target;
|
54
82
|
grpc_closure *on_complete;
|
@@ -173,9 +201,7 @@ static void remove_disconnected_sc_locked(round_robin_lb_policy *p,
|
|
173
201
|
return;
|
174
202
|
}
|
175
203
|
if (node == p->ready_list_last_pick) {
|
176
|
-
|
177
|
-
* dummy root of the list */
|
178
|
-
p->ready_list_last_pick = &p->ready_list;
|
204
|
+
p->ready_list_last_pick = p->ready_list_last_pick->prev;
|
179
205
|
}
|
180
206
|
|
181
207
|
/* removing last item */
|
@@ -239,11 +265,13 @@ static void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
239
265
|
while ((pp = p->pending_picks)) {
|
240
266
|
p->pending_picks = pp->next;
|
241
267
|
*pp->target = NULL;
|
242
|
-
|
268
|
+
grpc_exec_ctx_sched(exec_ctx, pp->on_complete,
|
269
|
+
GRPC_ERROR_CREATE("Channel Shutdown"), NULL);
|
243
270
|
gpr_free(pp);
|
244
271
|
}
|
245
|
-
grpc_connectivity_state_set(
|
246
|
-
|
272
|
+
grpc_connectivity_state_set(
|
273
|
+
exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
|
274
|
+
GRPC_ERROR_CREATE("Channel Shutdown"), "shutdown");
|
247
275
|
for (i = 0; i < p->num_subchannels; i++) {
|
248
276
|
subchannel_data *sd = p->subchannels[i];
|
249
277
|
grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, NULL,
|
@@ -262,10 +290,11 @@ static void rr_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
262
290
|
while (pp != NULL) {
|
263
291
|
pending_pick *next = pp->next;
|
264
292
|
if (pp->target == target) {
|
265
|
-
|
266
|
-
|
293
|
+
grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
|
294
|
+
p->base.interested_parties);
|
267
295
|
*target = NULL;
|
268
|
-
|
296
|
+
grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_CANCELLED,
|
297
|
+
NULL);
|
269
298
|
gpr_free(pp);
|
270
299
|
} else {
|
271
300
|
pp->next = p->pending_picks;
|
@@ -288,10 +317,11 @@ static void rr_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
288
317
|
pending_pick *next = pp->next;
|
289
318
|
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
|
290
319
|
initial_metadata_flags_eq) {
|
291
|
-
|
292
|
-
|
320
|
+
grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
|
321
|
+
p->base.interested_parties);
|
293
322
|
*pp->target = NULL;
|
294
|
-
|
323
|
+
grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_CANCELLED,
|
324
|
+
NULL);
|
295
325
|
gpr_free(pp);
|
296
326
|
} else {
|
297
327
|
pp->next = p->pending_picks;
|
@@ -307,7 +337,7 @@ static void start_picking(grpc_exec_ctx *exec_ctx, round_robin_lb_policy *p) {
|
|
307
337
|
p->started_picking = 1;
|
308
338
|
|
309
339
|
if (grpc_lb_round_robin_trace) {
|
310
|
-
gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%
|
340
|
+
gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%" PRIuPTR, p,
|
311
341
|
p->num_subchannels);
|
312
342
|
}
|
313
343
|
|
@@ -331,7 +361,8 @@ static void rr_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
331
361
|
}
|
332
362
|
|
333
363
|
static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
334
|
-
|
364
|
+
grpc_polling_entity *pollent,
|
365
|
+
grpc_metadata_batch *initial_metadata,
|
335
366
|
uint32_t initial_metadata_flags,
|
336
367
|
grpc_connected_subchannel **target,
|
337
368
|
grpc_closure *on_complete) {
|
@@ -344,8 +375,8 @@ static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
344
375
|
*target = grpc_subchannel_get_connected_subchannel(selected->subchannel);
|
345
376
|
if (grpc_lb_round_robin_trace) {
|
346
377
|
gpr_log(GPR_DEBUG,
|
347
|
-
"[RR PICK] TARGET <-- CONNECTED SUBCHANNEL %p (NODE %p)",
|
348
|
-
selected
|
378
|
+
"[RR PICK] TARGET <-- CONNECTED SUBCHANNEL %p (NODE %p)", *target,
|
379
|
+
selected);
|
349
380
|
}
|
350
381
|
/* only advance the last picked pointer if the selection was used */
|
351
382
|
advance_last_picked_locked(p);
|
@@ -354,10 +385,11 @@ static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
354
385
|
if (!p->started_picking) {
|
355
386
|
start_picking(exec_ctx, p);
|
356
387
|
}
|
357
|
-
|
388
|
+
grpc_polling_entity_add_to_pollset_set(exec_ctx, pollent,
|
389
|
+
p->base.interested_parties);
|
358
390
|
pp = gpr_malloc(sizeof(*pp));
|
359
391
|
pp->next = p->pending_picks;
|
360
|
-
pp->
|
392
|
+
pp->pollent = pollent;
|
361
393
|
pp->target = target;
|
362
394
|
pp->on_complete = on_complete;
|
363
395
|
pp->initial_metadata_flags = initial_metadata_flags;
|
@@ -368,7 +400,7 @@ static int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
368
400
|
}
|
369
401
|
|
370
402
|
static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
371
|
-
|
403
|
+
grpc_error *error) {
|
372
404
|
subchannel_data *sd = arg;
|
373
405
|
round_robin_lb_policy *p = sd->policy;
|
374
406
|
pending_pick *pp;
|
@@ -376,6 +408,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
376
408
|
|
377
409
|
int unref = 0;
|
378
410
|
|
411
|
+
GRPC_ERROR_REF(error);
|
379
412
|
gpr_mu_lock(&p->mu);
|
380
413
|
|
381
414
|
if (p->shutdown) {
|
@@ -384,7 +417,8 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
384
417
|
switch (sd->connectivity_state) {
|
385
418
|
case GRPC_CHANNEL_READY:
|
386
419
|
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
|
387
|
-
GRPC_CHANNEL_READY,
|
420
|
+
GRPC_CHANNEL_READY, GRPC_ERROR_REF(error),
|
421
|
+
"connecting_ready");
|
388
422
|
/* add the newly connected subchannel to the list of connected ones.
|
389
423
|
* Note that it goes to the "end of the line". */
|
390
424
|
sd->ready_list_node = add_connected_sc_locked(p, sd->subchannel);
|
@@ -406,9 +440,9 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
406
440
|
"[RR CONN CHANGED] TARGET <-- SUBCHANNEL %p (NODE %p)",
|
407
441
|
selected->subchannel, selected);
|
408
442
|
}
|
409
|
-
|
410
|
-
|
411
|
-
|
443
|
+
grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
|
444
|
+
p->base.interested_parties);
|
445
|
+
grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_NONE, NULL);
|
412
446
|
gpr_free(pp);
|
413
447
|
}
|
414
448
|
grpc_subchannel_notify_on_state_change(
|
@@ -417,9 +451,9 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
417
451
|
break;
|
418
452
|
case GRPC_CHANNEL_CONNECTING:
|
419
453
|
case GRPC_CHANNEL_IDLE:
|
420
|
-
grpc_connectivity_state_set(
|
421
|
-
|
422
|
-
|
454
|
+
grpc_connectivity_state_set(
|
455
|
+
exec_ctx, &p->state_tracker, sd->connectivity_state,
|
456
|
+
GRPC_ERROR_REF(error), "connecting_changed");
|
423
457
|
grpc_subchannel_notify_on_state_change(
|
424
458
|
exec_ctx, sd->subchannel, p->base.interested_parties,
|
425
459
|
&sd->connectivity_state, &sd->connectivity_changed_closure);
|
@@ -435,11 +469,11 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
435
469
|
remove_disconnected_sc_locked(p, sd->ready_list_node);
|
436
470
|
sd->ready_list_node = NULL;
|
437
471
|
}
|
438
|
-
grpc_connectivity_state_set(
|
439
|
-
|
440
|
-
|
472
|
+
grpc_connectivity_state_set(
|
473
|
+
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
|
474
|
+
GRPC_ERROR_REF(error), "connecting_transient_failure");
|
441
475
|
break;
|
442
|
-
case
|
476
|
+
case GRPC_CHANNEL_SHUTDOWN:
|
443
477
|
if (sd->ready_list_node != NULL) {
|
444
478
|
remove_disconnected_sc_locked(p, sd->ready_list_node);
|
445
479
|
sd->ready_list_node = NULL;
|
@@ -454,19 +488,22 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
454
488
|
|
455
489
|
unref = 1;
|
456
490
|
if (p->num_subchannels == 0) {
|
457
|
-
grpc_connectivity_state_set(
|
458
|
-
|
459
|
-
|
491
|
+
grpc_connectivity_state_set(
|
492
|
+
exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
|
493
|
+
GRPC_ERROR_CREATE_REFERENCING("Round Robin Channels Exhausted",
|
494
|
+
&error, 1),
|
495
|
+
"no_more_channels");
|
460
496
|
while ((pp = p->pending_picks)) {
|
461
497
|
p->pending_picks = pp->next;
|
462
498
|
*pp->target = NULL;
|
463
|
-
|
499
|
+
grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_NONE,
|
500
|
+
NULL);
|
464
501
|
gpr_free(pp);
|
465
502
|
}
|
466
503
|
} else {
|
467
|
-
grpc_connectivity_state_set(
|
468
|
-
|
469
|
-
|
504
|
+
grpc_connectivity_state_set(
|
505
|
+
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
|
506
|
+
GRPC_ERROR_REF(error), "subchannel_failed");
|
470
507
|
}
|
471
508
|
} /* switch */
|
472
509
|
} /* !unref */
|
@@ -476,14 +513,17 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
|
|
476
513
|
if (unref) {
|
477
514
|
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "round_robin_connectivity");
|
478
515
|
}
|
516
|
+
|
517
|
+
GRPC_ERROR_UNREF(error);
|
479
518
|
}
|
480
519
|
|
481
520
|
static grpc_connectivity_state rr_check_connectivity(grpc_exec_ctx *exec_ctx,
|
482
|
-
grpc_lb_policy *pol
|
521
|
+
grpc_lb_policy *pol,
|
522
|
+
grpc_error **error) {
|
483
523
|
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
|
484
524
|
grpc_connectivity_state st;
|
485
525
|
gpr_mu_lock(&p->mu);
|
486
|
-
st = grpc_connectivity_state_check(&p->state_tracker);
|
526
|
+
st = grpc_connectivity_state_check(&p->state_tracker, error);
|
487
527
|
gpr_mu_unlock(&p->mu);
|
488
528
|
return st;
|
489
529
|
}
|
@@ -511,7 +551,8 @@ static void rr_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
511
551
|
grpc_connected_subchannel_ping(exec_ctx, target, closure);
|
512
552
|
} else {
|
513
553
|
gpr_mu_unlock(&p->mu);
|
514
|
-
|
554
|
+
grpc_exec_ctx_sched(exec_ctx, closure,
|
555
|
+
GRPC_ERROR_CREATE("Round Robin not connected"), NULL);
|
515
556
|
}
|
516
557
|
}
|
517
558
|
|
@@ -524,7 +565,7 @@ static void round_robin_factory_ref(grpc_lb_policy_factory *factory) {}
|
|
524
565
|
|
525
566
|
static void round_robin_factory_unref(grpc_lb_policy_factory *factory) {}
|
526
567
|
|
527
|
-
static grpc_lb_policy *
|
568
|
+
static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
|
528
569
|
grpc_lb_policy_factory *factory,
|
529
570
|
grpc_lb_policy_args *args) {
|
530
571
|
GPR_ASSERT(args->addresses != NULL);
|
@@ -580,7 +621,7 @@ static grpc_lb_policy *create_round_robin(grpc_exec_ctx *exec_ctx,
|
|
580
621
|
}
|
581
622
|
|
582
623
|
static const grpc_lb_policy_factory_vtable round_robin_factory_vtable = {
|
583
|
-
round_robin_factory_ref, round_robin_factory_unref,
|
624
|
+
round_robin_factory_ref, round_robin_factory_unref, round_robin_create,
|
584
625
|
"round_robin"};
|
585
626
|
|
586
627
|
static grpc_lb_policy_factory round_robin_lb_policy_factory = {
|
@@ -0,0 +1,133 @@
|
|
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
|
+
#include <limits.h>
|
35
|
+
#include <string.h>
|
36
|
+
|
37
|
+
#include <grpc/support/alloc.h>
|
38
|
+
#include <grpc/support/sync.h>
|
39
|
+
|
40
|
+
#include "src/core/ext/load_reporting/load_reporting.h"
|
41
|
+
#include "src/core/ext/load_reporting/load_reporting_filter.h"
|
42
|
+
#include "src/core/lib/channel/channel_stack_builder.h"
|
43
|
+
#include "src/core/lib/surface/channel_init.h"
|
44
|
+
|
45
|
+
struct grpc_load_reporting_config {
|
46
|
+
grpc_load_reporting_fn fn;
|
47
|
+
void *user_data;
|
48
|
+
};
|
49
|
+
|
50
|
+
grpc_load_reporting_config *grpc_load_reporting_config_create(
|
51
|
+
grpc_load_reporting_fn fn, void *user_data) {
|
52
|
+
GPR_ASSERT(fn != NULL);
|
53
|
+
grpc_load_reporting_config *lrc =
|
54
|
+
gpr_malloc(sizeof(grpc_load_reporting_config));
|
55
|
+
lrc->fn = fn;
|
56
|
+
lrc->user_data = user_data;
|
57
|
+
return lrc;
|
58
|
+
}
|
59
|
+
|
60
|
+
grpc_load_reporting_config *grpc_load_reporting_config_copy(
|
61
|
+
grpc_load_reporting_config *src) {
|
62
|
+
return grpc_load_reporting_config_create(src->fn, src->user_data);
|
63
|
+
}
|
64
|
+
|
65
|
+
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc) {
|
66
|
+
gpr_free(lrc);
|
67
|
+
}
|
68
|
+
|
69
|
+
void grpc_load_reporting_config_call(
|
70
|
+
grpc_load_reporting_config *lrc,
|
71
|
+
const grpc_load_reporting_call_data *call_data) {
|
72
|
+
lrc->fn(call_data, lrc->user_data);
|
73
|
+
}
|
74
|
+
|
75
|
+
static bool is_load_reporting_enabled(const grpc_channel_args *a) {
|
76
|
+
if (a == NULL) return false;
|
77
|
+
for (size_t i = 0; i < a->num_args; i++) {
|
78
|
+
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_LOAD_REPORTING)) {
|
79
|
+
return a->args[i].type == GRPC_ARG_POINTER &&
|
80
|
+
a->args[i].value.pointer.p != NULL;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
|
86
|
+
static bool maybe_add_load_reporting_filter(grpc_channel_stack_builder *builder,
|
87
|
+
void *arg) {
|
88
|
+
const grpc_channel_args *args =
|
89
|
+
grpc_channel_stack_builder_get_channel_arguments(builder);
|
90
|
+
if (is_load_reporting_enabled(args)) {
|
91
|
+
return grpc_channel_stack_builder_prepend_filter(
|
92
|
+
builder, (const grpc_channel_filter *)arg, NULL, NULL);
|
93
|
+
}
|
94
|
+
return true;
|
95
|
+
}
|
96
|
+
|
97
|
+
static void lrd_arg_destroy(void *p) { grpc_load_reporting_config_destroy(p); }
|
98
|
+
|
99
|
+
static void *lrd_arg_copy(void *p) {
|
100
|
+
return grpc_load_reporting_config_copy(p);
|
101
|
+
}
|
102
|
+
|
103
|
+
static int lrd_arg_cmp(void *a, void *b) {
|
104
|
+
grpc_load_reporting_config *lhs = a;
|
105
|
+
grpc_load_reporting_config *rhs = b;
|
106
|
+
return !(lhs->fn == rhs->fn && lhs->user_data == rhs->user_data);
|
107
|
+
}
|
108
|
+
|
109
|
+
static const grpc_arg_pointer_vtable lrd_ptr_vtable = {
|
110
|
+
lrd_arg_copy, lrd_arg_destroy, lrd_arg_cmp};
|
111
|
+
|
112
|
+
grpc_arg grpc_load_reporting_config_create_arg(
|
113
|
+
grpc_load_reporting_config *lrc) {
|
114
|
+
grpc_arg arg;
|
115
|
+
arg.type = GRPC_ARG_POINTER;
|
116
|
+
arg.key = GRPC_ARG_ENABLE_LOAD_REPORTING;
|
117
|
+
arg.value.pointer.p = lrc;
|
118
|
+
arg.value.pointer.vtable = &lrd_ptr_vtable;
|
119
|
+
return arg;
|
120
|
+
}
|
121
|
+
|
122
|
+
/* Plugin registration */
|
123
|
+
|
124
|
+
void grpc_load_reporting_plugin_init(void) {
|
125
|
+
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
|
126
|
+
maybe_add_load_reporting_filter,
|
127
|
+
(void *)&grpc_load_reporting_filter);
|
128
|
+
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
|
129
|
+
maybe_add_load_reporting_filter,
|
130
|
+
(void *)&grpc_load_reporting_filter);
|
131
|
+
}
|
132
|
+
|
133
|
+
void grpc_load_reporting_plugin_shutdown() {}
|
@@ -0,0 +1,75 @@
|
|
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_LOAD_REPORTING_LOAD_REPORTING_H
|
35
|
+
#define GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H
|
36
|
+
|
37
|
+
#include "src/core/lib/iomgr/closure.h"
|
38
|
+
#include "src/core/lib/surface/call.h"
|
39
|
+
|
40
|
+
typedef struct grpc_load_reporting_config grpc_load_reporting_config;
|
41
|
+
|
42
|
+
/** Call information to be passed to the provided load reporting function upon
|
43
|
+
* completion of the call */
|
44
|
+
typedef struct grpc_load_reporting_call_data {
|
45
|
+
const grpc_call_stats *stats; /**< Stats for the call */
|
46
|
+
const char *trailing_md_string; /**< LR trailing metadata info */
|
47
|
+
} grpc_load_reporting_call_data;
|
48
|
+
|
49
|
+
/** Custom function to be called by the load reporting filter. */
|
50
|
+
typedef void (*grpc_load_reporting_fn)(
|
51
|
+
const grpc_load_reporting_call_data *call_data, void *user_data);
|
52
|
+
|
53
|
+
/** Register \a fn as the function to be invoked by the load reporting filter.
|
54
|
+
* \a fn will be invoked at the beginning and at the end of the call.
|
55
|
+
*
|
56
|
+
* For the first invocation, \a fn's first argument
|
57
|
+
* (grpc_load_reporting_call_data*) will be NULL. \a user_data is always passed
|
58
|
+
* as-is. */
|
59
|
+
grpc_load_reporting_config *grpc_load_reporting_config_create(
|
60
|
+
grpc_load_reporting_fn fn, void *user_data);
|
61
|
+
|
62
|
+
grpc_load_reporting_config *grpc_load_reporting_config_copy(
|
63
|
+
grpc_load_reporting_config *src);
|
64
|
+
|
65
|
+
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc);
|
66
|
+
|
67
|
+
/** Invoke the function registered by \a grpc_load_reporting_init. */
|
68
|
+
void grpc_load_reporting_config_call(
|
69
|
+
grpc_load_reporting_config *lrc,
|
70
|
+
const grpc_load_reporting_call_data *call_data);
|
71
|
+
|
72
|
+
/** Return a \a grpc_arg enabling load reporting */
|
73
|
+
grpc_arg grpc_load_reporting_config_create_arg(grpc_load_reporting_config *lrc);
|
74
|
+
|
75
|
+
#endif /* GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H */
|