wearefair-grpc 1.3.1.pre.c → 1.4.0.fair
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +418 -126
- data/include/grpc/grpc.h +15 -69
- data/include/grpc/grpc_security.h +1 -1
- data/include/grpc/impl/codegen/compression_types.h +3 -4
- data/include/grpc/impl/codegen/gpr_types.h +0 -1
- data/include/grpc/impl/codegen/grpc_types.h +69 -3
- data/include/grpc/impl/codegen/port_platform.h +6 -0
- data/include/grpc/impl/codegen/slice.h +2 -1
- data/include/grpc/load_reporting.h +6 -6
- data/include/grpc/slice.h +25 -3
- data/include/grpc/slice_buffer.h +4 -0
- data/src/core/ext/census/context.c +1 -1
- data/src/core/ext/census/resource.c +3 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
- data/src/core/ext/filters/client_channel/client_channel.c +158 -100
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
- data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +5 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +344 -88
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +6 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +13 -12
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
- data/src/core/ext/filters/client_channel/parse_address.c +37 -7
- data/src/core/ext/filters/client_channel/parse_address.h +11 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/filters/client_channel/subchannel.c +19 -16
- data/src/core/ext/filters/client_channel/subchannel.h +1 -0
- data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
- data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
- data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
- data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
- data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
- data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
- data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
- data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
- data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
- data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
- data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
- data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
- data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
- data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
- data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +296 -172
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
- data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
- data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
- data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
- data/src/core/lib/channel/channel_args.c +28 -9
- data/src/core/lib/channel/channel_args.h +5 -1
- data/src/core/lib/channel/channel_stack.c +1 -1
- data/src/core/lib/channel/channel_stack.h +2 -2
- data/src/core/lib/channel/channel_stack_builder.c +13 -1
- data/src/core/lib/channel/channel_stack_builder.h +5 -1
- data/src/core/lib/channel/connected_channel.c +3 -1
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/compression/message_compress.c +2 -2
- data/src/core/lib/debug/trace.c +13 -6
- data/src/core/lib/debug/trace.h +27 -1
- data/src/core/lib/http/httpcli.c +1 -1
- data/src/core/lib/http/httpcli_security_connector.c +6 -10
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/combiner.c +6 -6
- data/src/core/lib/iomgr/combiner.h +2 -1
- data/src/core/lib/iomgr/error.c +12 -5
- data/src/core/lib/iomgr/error.h +13 -13
- data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
- data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
- data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +24 -31
- data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
- data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
- data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
- data/src/core/lib/iomgr/ev_posix.c +22 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -3
- data/src/core/lib/iomgr/exec_ctx.c +5 -0
- data/src/core/lib/iomgr/exec_ctx.h +2 -0
- data/src/core/lib/iomgr/iomgr.c +4 -0
- data/src/core/lib/iomgr/iomgr.h +3 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
- data/src/core/lib/iomgr/lockfree_event.c +16 -0
- data/src/core/lib/iomgr/pollset.h +2 -5
- data/src/core/lib/iomgr/pollset_uv.c +1 -1
- data/src/core/lib/iomgr/pollset_windows.c +3 -3
- data/src/core/lib/iomgr/resource_quota.c +9 -8
- data/src/core/lib/iomgr/resource_quota.h +2 -1
- data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
- data/src/core/lib/iomgr/socket_mutator.h +2 -0
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
- data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
- data/src/core/lib/iomgr/tcp_posix.c +7 -7
- data/src/core/lib/iomgr/tcp_posix.h +2 -1
- data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +6 -6
- data/src/core/lib/iomgr/tcp_uv.h +2 -1
- data/src/core/lib/iomgr/tcp_windows.c +1 -1
- data/src/core/lib/iomgr/timer_generic.c +24 -25
- data/src/core/lib/iomgr/timer_manager.c +276 -0
- data/src/core/lib/iomgr/timer_manager.h +52 -0
- data/src/core/lib/iomgr/timer_uv.c +6 -0
- data/src/core/lib/iomgr/udp_server.c +42 -9
- data/src/core/lib/iomgr/udp_server.h +3 -1
- data/src/core/lib/security/credentials/credentials.c +0 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
- data/src/core/lib/security/transport/client_auth_filter.c +9 -3
- data/src/core/lib/security/transport/secure_endpoint.c +7 -7
- data/src/core/lib/security/transport/secure_endpoint.h +1 -1
- data/src/core/lib/security/transport/security_connector.c +32 -51
- data/src/core/lib/security/transport/security_connector.h +10 -14
- data/src/core/lib/slice/b64.c +1 -1
- data/src/core/lib/slice/percent_encoding.c +3 -3
- data/src/core/lib/slice/slice.c +66 -33
- data/src/core/lib/slice/slice_buffer.c +25 -6
- data/src/core/lib/slice/slice_hash_table.c +33 -35
- data/src/core/lib/slice/slice_hash_table.h +7 -12
- data/src/core/lib/support/atomic.h +45 -0
- data/src/core/lib/support/atomic_with_atm.h +70 -0
- data/src/core/lib/support/atomic_with_std.h +48 -0
- data/src/core/lib/support/avl.c +14 -14
- data/src/core/lib/support/memory.h +74 -0
- data/src/core/lib/support/mpscq.c +12 -1
- data/src/core/lib/support/mpscq.h +4 -0
- data/src/core/lib/support/stack_lockfree.c +3 -36
- data/src/core/lib/support/time_posix.c +8 -0
- data/src/core/lib/support/tmpfile_posix.c +10 -10
- data/src/core/lib/surface/alarm.c +3 -1
- data/src/core/lib/surface/api_trace.c +2 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +1 -1
- data/src/core/lib/surface/call.c +65 -22
- data/src/core/lib/surface/call.h +4 -2
- data/src/core/lib/surface/channel_init.c +2 -19
- data/src/core/lib/surface/channel_stack_type.c +18 -0
- data/src/core/lib/surface/channel_stack_type.h +2 -0
- data/src/core/lib/surface/completion_queue.c +249 -83
- data/src/core/lib/surface/completion_queue.h +18 -13
- data/src/core/lib/surface/completion_queue_factory.c +24 -9
- data/src/core/lib/surface/init.c +1 -52
- data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
- data/src/core/lib/surface/server.c +50 -27
- data/src/core/lib/surface/server.h +2 -1
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +20 -9
- data/src/core/lib/transport/bdp_estimator.h +5 -1
- data/src/core/lib/transport/byte_stream.c +23 -9
- data/src/core/lib/transport/byte_stream.h +15 -6
- data/src/core/lib/transport/connectivity_state.c +6 -6
- data/src/core/lib/transport/connectivity_state.h +2 -1
- data/src/core/lib/transport/service_config.c +6 -13
- data/src/core/lib/transport/service_config.h +2 -2
- data/src/core/lib/transport/static_metadata.c +403 -389
- data/src/core/lib/transport/static_metadata.h +127 -114
- data/src/core/plugin_registry/grpc_plugin_registry.c +12 -0
- data/src/core/tsi/fake_transport_security.c +5 -4
- data/src/core/tsi/ssl_transport_security.c +71 -82
- data/src/core/tsi/ssl_transport_security.h +39 -61
- data/src/core/tsi/transport_security.c +83 -2
- data/src/core/tsi/transport_security.h +27 -2
- data/src/core/tsi/transport_security_adapter.c +236 -0
- data/src/core/tsi/transport_security_adapter.h +62 -0
- data/src/core/tsi/transport_security_interface.h +179 -66
- data/src/ruby/ext/grpc/extconf.rb +2 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
- data/src/ruby/ext/grpc/rb_call.c +56 -48
- data/src/ruby/ext/grpc/rb_call.h +3 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
- data/src/ruby/ext/grpc/rb_channel.c +45 -29
- data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
- data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
- data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
- data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
- data/src/ruby/ext/grpc/rb_grpc.c +11 -15
- data/src/ruby/ext/grpc/rb_grpc.h +2 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +14 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +22 -10
- data/src/ruby/ext/grpc/rb_server.c +26 -28
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +40 -18
- data/src/ruby/lib/grpc/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
@@ -189,7 +189,8 @@ static void pf_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
189
189
|
|
190
190
|
static int pf_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
191
191
|
const grpc_lb_policy_pick_args *pick_args,
|
192
|
-
grpc_connected_subchannel **target,
|
192
|
+
grpc_connected_subchannel **target,
|
193
|
+
grpc_call_context_element *context, void **user_data,
|
193
194
|
grpc_closure *on_complete) {
|
194
195
|
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
|
195
196
|
pending_pick *pp;
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
typedef struct round_robin_lb_policy round_robin_lb_policy;
|
76
76
|
|
77
|
-
|
77
|
+
grpc_tracer_flag grpc_lb_round_robin_trace = GRPC_TRACER_INITIALIZER(false);
|
78
78
|
|
79
79
|
/** List of entities waiting for a pick.
|
80
80
|
*
|
@@ -198,7 +198,7 @@ static void advance_last_picked_locked(round_robin_lb_policy *p) {
|
|
198
198
|
GPR_ASSERT(p->ready_list_last_pick == &p->ready_list);
|
199
199
|
}
|
200
200
|
|
201
|
-
if (grpc_lb_round_robin_trace) {
|
201
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
202
202
|
gpr_log(GPR_DEBUG,
|
203
203
|
"[READYLIST, RR: %p] ADVANCED LAST PICK. NOW AT NODE %p (SC %p, "
|
204
204
|
"CSC %p)",
|
@@ -228,7 +228,7 @@ static ready_list *add_connected_sc_locked(round_robin_lb_policy *p,
|
|
228
228
|
p->ready_list.prev->next = new_elem;
|
229
229
|
p->ready_list.prev = new_elem;
|
230
230
|
}
|
231
|
-
if (grpc_lb_round_robin_trace) {
|
231
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
232
232
|
gpr_log(GPR_DEBUG, "[READYLIST] ADDING NODE %p (Conn. SC %p)",
|
233
233
|
(void *)new_elem, (void *)sd->subchannel);
|
234
234
|
}
|
@@ -256,7 +256,7 @@ static void remove_disconnected_sc_locked(round_robin_lb_policy *p,
|
|
256
256
|
node->next->prev = node->prev;
|
257
257
|
}
|
258
258
|
|
259
|
-
if (grpc_lb_round_robin_trace) {
|
259
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
260
260
|
gpr_log(GPR_DEBUG, "[READYLIST] REMOVED NODE %p (SC %p)", (void *)node,
|
261
261
|
(void *)node->subchannel);
|
262
262
|
}
|
@@ -276,7 +276,7 @@ static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
276
276
|
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
|
277
277
|
ready_list *elem;
|
278
278
|
|
279
|
-
if (grpc_lb_round_robin_trace) {
|
279
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
280
280
|
gpr_log(GPR_DEBUG, "Destroying Round Robin policy at %p", (void *)pol);
|
281
281
|
}
|
282
282
|
|
@@ -312,7 +312,7 @@ static void rr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
312
312
|
pending_pick *pp;
|
313
313
|
size_t i;
|
314
314
|
|
315
|
-
if (grpc_lb_round_robin_trace) {
|
315
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
316
316
|
gpr_log(GPR_DEBUG, "Shutting down Round Robin policy at %p", (void *)pol);
|
317
317
|
}
|
318
318
|
|
@@ -414,13 +414,14 @@ static void rr_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
414
414
|
|
415
415
|
static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
416
416
|
const grpc_lb_policy_pick_args *pick_args,
|
417
|
-
grpc_connected_subchannel **target,
|
417
|
+
grpc_connected_subchannel **target,
|
418
|
+
grpc_call_context_element *context, void **user_data,
|
418
419
|
grpc_closure *on_complete) {
|
419
420
|
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
|
420
421
|
pending_pick *pp;
|
421
422
|
ready_list *selected;
|
422
423
|
|
423
|
-
if (grpc_lb_round_robin_trace) {
|
424
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
424
425
|
gpr_log(GPR_INFO, "Round Robin %p trying to pick", (void *)pol);
|
425
426
|
}
|
426
427
|
|
@@ -433,7 +434,7 @@ static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
433
434
|
if (user_data != NULL) {
|
434
435
|
*user_data = selected->user_data;
|
435
436
|
}
|
436
|
-
if (grpc_lb_round_robin_trace) {
|
437
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
437
438
|
gpr_log(GPR_DEBUG,
|
438
439
|
"[RR PICK] TARGET <-- CONNECTED SUBCHANNEL %p (NODE %p)",
|
439
440
|
(void *)*target, (void *)selected);
|
@@ -565,7 +566,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
565
566
|
if (pp->user_data != NULL) {
|
566
567
|
*pp->user_data = selected->user_data;
|
567
568
|
}
|
568
|
-
if (grpc_lb_round_robin_trace) {
|
569
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
569
570
|
gpr_log(GPR_DEBUG,
|
570
571
|
"[RR CONN CHANGED] TARGET <-- SUBCHANNEL %p (NODE %p)",
|
571
572
|
(void *)selected->subchannel, (void *)selected);
|
@@ -723,7 +724,7 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
|
|
723
724
|
sc_args.args = new_args;
|
724
725
|
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
|
725
726
|
exec_ctx, args->client_channel_factory, &sc_args);
|
726
|
-
if (grpc_lb_round_robin_trace) {
|
727
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
727
728
|
char *address_uri =
|
728
729
|
grpc_sockaddr_to_uri(&addresses->addresses[i].address);
|
729
730
|
gpr_log(GPR_DEBUG, "Created subchannel %p for address uri %s",
|
@@ -767,7 +768,7 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
|
|
767
768
|
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
|
768
769
|
"round_robin");
|
769
770
|
|
770
|
-
if (grpc_lb_round_robin_trace) {
|
771
|
+
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
771
772
|
gpr_log(GPR_DEBUG, "Created RR policy at %p with %lu subchannels",
|
772
773
|
(void *)p, (unsigned long)p->num_subchannels);
|
773
774
|
}
|
@@ -36,16 +36,18 @@
|
|
36
36
|
#include <grpc/support/alloc.h>
|
37
37
|
#include <grpc/support/string_util.h>
|
38
38
|
|
39
|
+
#include "src/core/lib/channel/channel_args.h"
|
40
|
+
|
39
41
|
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
42
|
+
#include "src/core/ext/filters/client_channel/parse_address.h"
|
40
43
|
|
41
44
|
grpc_lb_addresses* grpc_lb_addresses_create(
|
42
45
|
size_t num_addresses, const grpc_lb_user_data_vtable* user_data_vtable) {
|
43
|
-
grpc_lb_addresses* addresses =
|
46
|
+
grpc_lb_addresses* addresses = gpr_zalloc(sizeof(grpc_lb_addresses));
|
44
47
|
addresses->num_addresses = num_addresses;
|
45
48
|
addresses->user_data_vtable = user_data_vtable;
|
46
49
|
const size_t addresses_size = sizeof(grpc_lb_address) * num_addresses;
|
47
|
-
addresses->addresses =
|
48
|
-
memset(addresses->addresses, 0, addresses_size);
|
50
|
+
addresses->addresses = gpr_zalloc(addresses_size);
|
49
51
|
return addresses;
|
50
52
|
}
|
51
53
|
|
@@ -69,7 +71,7 @@ grpc_lb_addresses* grpc_lb_addresses_copy(const grpc_lb_addresses* addresses) {
|
|
69
71
|
|
70
72
|
void grpc_lb_addresses_set_address(grpc_lb_addresses* addresses, size_t index,
|
71
73
|
void* address, size_t address_len,
|
72
|
-
bool is_balancer, char* balancer_name,
|
74
|
+
bool is_balancer, const char* balancer_name,
|
73
75
|
void* user_data) {
|
74
76
|
GPR_ASSERT(index < addresses->num_addresses);
|
75
77
|
if (user_data != NULL) GPR_ASSERT(addresses->user_data_vtable != NULL);
|
@@ -77,10 +79,22 @@ void grpc_lb_addresses_set_address(grpc_lb_addresses* addresses, size_t index,
|
|
77
79
|
memcpy(target->address.addr, address, address_len);
|
78
80
|
target->address.len = address_len;
|
79
81
|
target->is_balancer = is_balancer;
|
80
|
-
target->balancer_name = balancer_name;
|
82
|
+
target->balancer_name = gpr_strdup(balancer_name);
|
81
83
|
target->user_data = user_data;
|
82
84
|
}
|
83
85
|
|
86
|
+
bool grpc_lb_addresses_set_address_from_uri(grpc_lb_addresses* addresses,
|
87
|
+
size_t index, const grpc_uri* uri,
|
88
|
+
bool is_balancer,
|
89
|
+
const char* balancer_name,
|
90
|
+
void* user_data) {
|
91
|
+
grpc_resolved_address address;
|
92
|
+
if (!grpc_parse_uri(uri, &address)) return false;
|
93
|
+
grpc_lb_addresses_set_address(addresses, index, address.addr, address.len,
|
94
|
+
is_balancer, balancer_name, user_data);
|
95
|
+
return true;
|
96
|
+
}
|
97
|
+
|
84
98
|
int grpc_lb_addresses_cmp(const grpc_lb_addresses* addresses1,
|
85
99
|
const grpc_lb_addresses* addresses2) {
|
86
100
|
if (addresses1->num_addresses > addresses2->num_addresses) return 1;
|
@@ -147,6 +161,15 @@ grpc_arg grpc_lb_addresses_create_channel_arg(
|
|
147
161
|
return arg;
|
148
162
|
}
|
149
163
|
|
164
|
+
grpc_lb_addresses* grpc_lb_addresses_find_channel_arg(
|
165
|
+
const grpc_channel_args* channel_args) {
|
166
|
+
const grpc_arg* lb_addresses_arg =
|
167
|
+
grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES);
|
168
|
+
if (lb_addresses_arg == NULL || lb_addresses_arg->type != GRPC_ARG_POINTER)
|
169
|
+
return NULL;
|
170
|
+
return lb_addresses_arg->value.pointer.p;
|
171
|
+
}
|
172
|
+
|
150
173
|
void grpc_lb_policy_factory_ref(grpc_lb_policy_factory* factory) {
|
151
174
|
factory->vtable->ref(factory);
|
152
175
|
}
|
@@ -34,12 +34,13 @@
|
|
34
34
|
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H
|
35
35
|
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H
|
36
36
|
|
37
|
-
#include "src/core/ext/filters/client_channel/client_channel_factory.h"
|
38
|
-
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
39
|
-
|
40
37
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
41
38
|
#include "src/core/lib/iomgr/resolve_address.h"
|
42
39
|
|
40
|
+
#include "src/core/ext/filters/client_channel/client_channel_factory.h"
|
41
|
+
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
42
|
+
#include "src/core/ext/filters/client_channel/uri_parser.h"
|
43
|
+
|
43
44
|
// Channel arg key for grpc_lb_addresses.
|
44
45
|
#define GRPC_ARG_LB_ADDRESSES "grpc.lb_addresses"
|
45
46
|
|
@@ -88,9 +89,18 @@ grpc_lb_addresses *grpc_lb_addresses_copy(const grpc_lb_addresses *addresses);
|
|
88
89
|
* Takes ownership of \a balancer_name. */
|
89
90
|
void grpc_lb_addresses_set_address(grpc_lb_addresses *addresses, size_t index,
|
90
91
|
void *address, size_t address_len,
|
91
|
-
bool is_balancer, char *balancer_name,
|
92
|
+
bool is_balancer, const char *balancer_name,
|
92
93
|
void *user_data);
|
93
94
|
|
95
|
+
/** Sets the value of the address at index \a index of \a addresses from \a uri.
|
96
|
+
* Returns true upon success, false otherwise. Takes ownership of \a
|
97
|
+
* balancer_name. */
|
98
|
+
bool grpc_lb_addresses_set_address_from_uri(grpc_lb_addresses *addresses,
|
99
|
+
size_t index, const grpc_uri *uri,
|
100
|
+
bool is_balancer,
|
101
|
+
const char *balancer_name,
|
102
|
+
void *user_data);
|
103
|
+
|
94
104
|
/** Compares \a addresses1 and \a addresses2. */
|
95
105
|
int grpc_lb_addresses_cmp(const grpc_lb_addresses *addresses1,
|
96
106
|
const grpc_lb_addresses *addresses2);
|
@@ -103,6 +113,10 @@ void grpc_lb_addresses_destroy(grpc_exec_ctx *exec_ctx,
|
|
103
113
|
grpc_arg grpc_lb_addresses_create_channel_arg(
|
104
114
|
const grpc_lb_addresses *addresses);
|
105
115
|
|
116
|
+
/** Returns the \a grpc_lb_addresses instance in \a channel_args or NULL */
|
117
|
+
grpc_lb_addresses *grpc_lb_addresses_find_channel_arg(
|
118
|
+
const grpc_channel_args *channel_args);
|
119
|
+
|
106
120
|
/** Arguments passed to LB policies. */
|
107
121
|
typedef struct grpc_lb_policy_args {
|
108
122
|
grpc_client_channel_factory *client_channel_factory;
|
@@ -48,7 +48,12 @@
|
|
48
48
|
|
49
49
|
#ifdef GRPC_HAVE_UNIX_SOCKET
|
50
50
|
|
51
|
-
|
51
|
+
bool grpc_parse_unix(const grpc_uri *uri,
|
52
|
+
grpc_resolved_address *resolved_addr) {
|
53
|
+
if (strcmp("unix", uri->scheme) != 0) {
|
54
|
+
gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'", uri->scheme);
|
55
|
+
return false;
|
56
|
+
}
|
52
57
|
struct sockaddr_un *un = (struct sockaddr_un *)resolved_addr->addr;
|
53
58
|
const size_t maxlen = sizeof(un->sun_path);
|
54
59
|
const size_t path_len = strnlen(uri->path, maxlen);
|
@@ -61,21 +66,29 @@ int parse_unix(grpc_uri *uri, grpc_resolved_address *resolved_addr) {
|
|
61
66
|
|
62
67
|
#else /* GRPC_HAVE_UNIX_SOCKET */
|
63
68
|
|
64
|
-
|
69
|
+
bool grpc_parse_unix(const grpc_uri *uri,
|
70
|
+
grpc_resolved_address *resolved_addr) {
|
71
|
+
abort();
|
72
|
+
}
|
65
73
|
|
66
74
|
#endif /* GRPC_HAVE_UNIX_SOCKET */
|
67
75
|
|
68
|
-
|
76
|
+
bool grpc_parse_ipv4(const grpc_uri *uri,
|
77
|
+
grpc_resolved_address *resolved_addr) {
|
78
|
+
if (strcmp("ipv4", uri->scheme) != 0) {
|
79
|
+
gpr_log(GPR_ERROR, "Expected 'ipv4' scheme, got '%s'", uri->scheme);
|
80
|
+
return false;
|
81
|
+
}
|
69
82
|
const char *host_port = uri->path;
|
70
83
|
char *host;
|
71
84
|
char *port;
|
72
85
|
int port_num;
|
73
|
-
|
86
|
+
bool result = false;
|
74
87
|
struct sockaddr_in *in = (struct sockaddr_in *)resolved_addr->addr;
|
75
88
|
|
76
89
|
if (*host_port == '/') ++host_port;
|
77
90
|
if (!gpr_split_host_port(host_port, &host, &port)) {
|
78
|
-
return
|
91
|
+
return false;
|
79
92
|
}
|
80
93
|
|
81
94
|
memset(resolved_addr, 0, sizeof(grpc_resolved_address));
|
@@ -98,14 +111,19 @@ int parse_ipv4(grpc_uri *uri, grpc_resolved_address *resolved_addr) {
|
|
98
111
|
goto done;
|
99
112
|
}
|
100
113
|
|
101
|
-
result =
|
114
|
+
result = true;
|
102
115
|
done:
|
103
116
|
gpr_free(host);
|
104
117
|
gpr_free(port);
|
105
118
|
return result;
|
106
119
|
}
|
107
120
|
|
108
|
-
|
121
|
+
bool grpc_parse_ipv6(const grpc_uri *uri,
|
122
|
+
grpc_resolved_address *resolved_addr) {
|
123
|
+
if (strcmp("ipv6", uri->scheme) != 0) {
|
124
|
+
gpr_log(GPR_ERROR, "Expected 'ipv6' scheme, got '%s'", uri->scheme);
|
125
|
+
return false;
|
126
|
+
}
|
109
127
|
const char *host_port = uri->path;
|
110
128
|
char *host;
|
111
129
|
char *port;
|
@@ -168,3 +186,15 @@ done:
|
|
168
186
|
gpr_free(port);
|
169
187
|
return result;
|
170
188
|
}
|
189
|
+
|
190
|
+
bool grpc_parse_uri(const grpc_uri *uri, grpc_resolved_address *resolved_addr) {
|
191
|
+
if (strcmp("unix", uri->scheme) == 0) {
|
192
|
+
return grpc_parse_unix(uri, resolved_addr);
|
193
|
+
} else if (strcmp("ipv4", uri->scheme) == 0) {
|
194
|
+
return grpc_parse_ipv4(uri, resolved_addr);
|
195
|
+
} else if (strcmp("ipv6", uri->scheme) == 0) {
|
196
|
+
return grpc_parse_ipv6(uri, resolved_addr);
|
197
|
+
}
|
198
|
+
gpr_log(GPR_ERROR, "Can't parse scheme '%s'", uri->scheme);
|
199
|
+
return false;
|
200
|
+
}
|
@@ -39,16 +39,19 @@
|
|
39
39
|
#include "src/core/ext/filters/client_channel/uri_parser.h"
|
40
40
|
#include "src/core/lib/iomgr/resolve_address.h"
|
41
41
|
|
42
|
-
/** Populate \a
|
42
|
+
/** Populate \a resolved_addr from \a uri, whose path is expected to contain a
|
43
43
|
* unix socket path. Returns true upon success. */
|
44
|
-
|
44
|
+
bool grpc_parse_unix(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
|
45
45
|
|
46
|
-
/** Populate
|
47
|
-
* host:port pair. Returns true upon success. */
|
48
|
-
|
46
|
+
/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
|
47
|
+
* IPv4 host:port pair. Returns true upon success. */
|
48
|
+
bool grpc_parse_ipv4(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
|
49
49
|
|
50
|
-
/** Populate
|
51
|
-
* host:port pair. Returns true upon success. */
|
52
|
-
|
50
|
+
/** Populate \a resolved_addr from \a uri, whose path is expected to contain an
|
51
|
+
* IPv6 host:port pair. Returns true upon success. */
|
52
|
+
bool grpc_parse_ipv6(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
|
53
|
+
|
54
|
+
/** Populate \a resolved_addr from \a uri. Returns true upon success. */
|
55
|
+
bool grpc_parse_uri(const grpc_uri *uri, grpc_resolved_address *resolved_addr);
|
53
56
|
|
54
57
|
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */
|
@@ -157,8 +157,8 @@ static void do_nothing(void *ignored) {}
|
|
157
157
|
|
158
158
|
static grpc_resolver *sockaddr_create(grpc_exec_ctx *exec_ctx,
|
159
159
|
grpc_resolver_args *args,
|
160
|
-
|
161
|
-
|
160
|
+
bool parse(const grpc_uri *uri,
|
161
|
+
grpc_resolved_address *dst)) {
|
162
162
|
if (0 != strcmp(args->uri->authority, "")) {
|
163
163
|
gpr_log(GPR_ERROR, "authority based uri's not supported by the %s scheme",
|
164
164
|
args->uri->scheme);
|
@@ -209,7 +209,7 @@ static void sockaddr_factory_unref(grpc_resolver_factory *factory) {}
|
|
209
209
|
static grpc_resolver *name##_factory_create_resolver( \
|
210
210
|
grpc_exec_ctx *exec_ctx, grpc_resolver_factory *factory, \
|
211
211
|
grpc_resolver_args *args) { \
|
212
|
-
return sockaddr_create(exec_ctx, args,
|
212
|
+
return sockaddr_create(exec_ctx, args, grpc_parse_##name); \
|
213
213
|
} \
|
214
214
|
static const grpc_resolver_factory_vtable name##_factory_vtable = { \
|
215
215
|
sockaddr_factory_ref, sockaddr_factory_unref, \
|
@@ -59,9 +59,9 @@
|
|
59
59
|
#define INTERNAL_REF_BITS 16
|
60
60
|
#define STRONG_REF_MASK (~(gpr_atm)((1 << INTERNAL_REF_BITS) - 1))
|
61
61
|
|
62
|
-
#define GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS 20
|
63
62
|
#define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1
|
64
63
|
#define GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER 1.6
|
64
|
+
#define GRPC_SUBCHANNEL_RECONNECT_MIN_BACKOFF_SECONDS 20
|
65
65
|
#define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120
|
66
66
|
#define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2
|
67
67
|
|
@@ -353,8 +353,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
|
|
353
353
|
"subchannel");
|
354
354
|
int initial_backoff_ms =
|
355
355
|
GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS * 1000;
|
356
|
+
int min_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MIN_BACKOFF_SECONDS * 1000;
|
356
357
|
int max_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000;
|
357
|
-
int min_backoff_ms = GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS * 1000;
|
358
358
|
bool fixed_reconnect_backoff = false;
|
359
359
|
if (c->args) {
|
360
360
|
for (size_t i = 0; i < c->args->num_args; i++) {
|
@@ -365,6 +365,12 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
|
|
365
365
|
grpc_channel_arg_get_integer(
|
366
366
|
&c->args->args[i],
|
367
367
|
(grpc_integer_options){initial_backoff_ms, 100, INT_MAX});
|
368
|
+
} else if (0 == strcmp(c->args->args[i].key,
|
369
|
+
GRPC_ARG_MIN_RECONNECT_BACKOFF_MS)) {
|
370
|
+
fixed_reconnect_backoff = false;
|
371
|
+
min_backoff_ms = grpc_channel_arg_get_integer(
|
372
|
+
&c->args->args[i],
|
373
|
+
(grpc_integer_options){min_backoff_ms, 100, INT_MAX});
|
368
374
|
} else if (0 == strcmp(c->args->args[i].key,
|
369
375
|
GRPC_ARG_MAX_RECONNECT_BACKOFF_MS)) {
|
370
376
|
fixed_reconnect_backoff = false;
|
@@ -609,7 +615,7 @@ void grpc_connected_subchannel_ping(grpc_exec_ctx *exec_ctx,
|
|
609
615
|
elem->filter->start_transport_op(exec_ctx, elem, op);
|
610
616
|
}
|
611
617
|
|
612
|
-
static
|
618
|
+
static bool publish_transport_locked(grpc_exec_ctx *exec_ctx,
|
613
619
|
grpc_subchannel *c) {
|
614
620
|
grpc_connected_subchannel *con;
|
615
621
|
grpc_channel_stack *stk;
|
@@ -625,15 +631,16 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
|
|
625
631
|
if (!grpc_channel_init_create_stack(exec_ctx, builder,
|
626
632
|
GRPC_CLIENT_SUBCHANNEL)) {
|
627
633
|
grpc_channel_stack_builder_destroy(exec_ctx, builder);
|
628
|
-
|
634
|
+
return false;
|
629
635
|
}
|
630
636
|
grpc_error *error = grpc_channel_stack_builder_finish(
|
631
637
|
exec_ctx, builder, 0, 1, connection_destroy, NULL, (void **)&con);
|
632
638
|
if (error != GRPC_ERROR_NONE) {
|
639
|
+
grpc_transport_destroy(exec_ctx, c->connecting_result.transport);
|
633
640
|
gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
|
634
641
|
grpc_error_string(error));
|
635
642
|
GRPC_ERROR_UNREF(error);
|
636
|
-
|
643
|
+
return false;
|
637
644
|
}
|
638
645
|
stk = CHANNEL_STACK_FROM_CONNECTION(con);
|
639
646
|
memset(&c->connecting_result, 0, sizeof(c->connecting_result));
|
@@ -650,7 +657,7 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
|
|
650
657
|
grpc_channel_stack_destroy(exec_ctx, stk);
|
651
658
|
gpr_free(con);
|
652
659
|
GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
|
653
|
-
return;
|
660
|
+
return false;
|
654
661
|
}
|
655
662
|
|
656
663
|
/* publish */
|
@@ -672,6 +679,7 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
|
|
672
679
|
/* signal completion */
|
673
680
|
grpc_connectivity_state_set(exec_ctx, &c->state_tracker, GRPC_CHANNEL_READY,
|
674
681
|
GRPC_ERROR_NONE, "connected");
|
682
|
+
return true;
|
675
683
|
}
|
676
684
|
|
677
685
|
static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg,
|
@@ -682,8 +690,9 @@ static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg,
|
|
682
690
|
GRPC_SUBCHANNEL_WEAK_REF(c, "connected");
|
683
691
|
gpr_mu_lock(&c->mu);
|
684
692
|
c->connecting = false;
|
685
|
-
if (c->connecting_result.transport != NULL
|
686
|
-
|
693
|
+
if (c->connecting_result.transport != NULL &&
|
694
|
+
publish_transport_locked(exec_ctx, c)) {
|
695
|
+
/* do nothing, transport was published */
|
687
696
|
} else if (c->disconnected) {
|
688
697
|
GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
|
689
698
|
} else {
|
@@ -772,7 +781,7 @@ grpc_error *grpc_connected_subchannel_create_call(
|
|
772
781
|
(*call)->connection = GRPC_CONNECTED_SUBCHANNEL_REF(con, "subchannel_call");
|
773
782
|
const grpc_call_element_args call_args = {.call_stack = callstk,
|
774
783
|
.server_transport_data = NULL,
|
775
|
-
.context =
|
784
|
+
.context = args->context,
|
776
785
|
.path = args->path,
|
777
786
|
.start_time = args->start_time,
|
778
787
|
.deadline = args->deadline,
|
@@ -797,13 +806,7 @@ static void grpc_uri_to_sockaddr(grpc_exec_ctx *exec_ctx, const char *uri_str,
|
|
797
806
|
grpc_resolved_address *addr) {
|
798
807
|
grpc_uri *uri = grpc_uri_parse(exec_ctx, uri_str, 0 /* suppress_errors */);
|
799
808
|
GPR_ASSERT(uri != NULL);
|
800
|
-
if (
|
801
|
-
GPR_ASSERT(parse_ipv4(uri, addr));
|
802
|
-
} else if (strcmp(uri->scheme, "ipv6") == 0) {
|
803
|
-
GPR_ASSERT(parse_ipv6(uri, addr));
|
804
|
-
} else {
|
805
|
-
GPR_ASSERT(parse_unix(uri, addr));
|
806
|
-
}
|
809
|
+
if (!grpc_parse_uri(uri, addr)) memset(addr, 0, sizeof(*addr));
|
807
810
|
grpc_uri_destroy(uri);
|
808
811
|
}
|
809
812
|
|