grpc 1.16.0 → 1.17.0.pre1
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 +299 -133
- data/include/grpc/grpc.h +11 -1
- data/include/grpc/grpc_posix.h +0 -8
- data/include/grpc/impl/codegen/grpc_types.h +3 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +336 -345
- data/src/core/ext/filters/client_channel/client_channel.h +6 -2
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +3 -1
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -7
- data/src/core/ext/filters/client_channel/health/health.pb.c +23 -0
- data/src/core/ext/filters/client_channel/health/health.pb.h +73 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +652 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.h +173 -0
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -1
- data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +17 -14
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +15 -11
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +21 -15
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +18 -10
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +12 -9
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +19 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1832 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +36 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +36 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +107 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +85 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +72 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +307 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +89 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +4 -0
- data/src/core/ext/filters/client_channel/parse_address.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +19 -22
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +41 -39
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +3 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +15 -2
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +5 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +384 -0
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +146 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +361 -103
- data/src/core/ext/filters/client_channel/subchannel.h +14 -8
- data/src/core/ext/filters/deadline/deadline_filter.cc +19 -23
- data/src/core/ext/filters/deadline/deadline_filter.h +9 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +29 -19
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +28 -16
- data/src/core/ext/filters/http/server/http_server_filter.cc +31 -20
- data/src/core/ext/filters/message_size/message_size_filter.cc +50 -45
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +58 -8
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +175 -173
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -10
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +28 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +0 -12
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +12 -9
- data/src/core/ext/transport/chttp2/transport/internal.h +109 -94
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +280 -300
- data/src/core/lib/channel/channel_stack.cc +5 -4
- data/src/core/lib/channel/channel_stack.h +4 -4
- data/src/core/lib/channel/channel_stack_builder.cc +14 -2
- data/src/core/lib/channel/channel_stack_builder.h +8 -0
- data/src/core/lib/channel/channel_trace.cc +6 -2
- data/src/core/lib/channel/channelz.cc +137 -5
- data/src/core/lib/channel/channelz.h +32 -6
- data/src/core/lib/channel/channelz_registry.cc +134 -28
- data/src/core/lib/channel/channelz_registry.h +25 -3
- data/src/core/lib/channel/context.h +4 -4
- data/src/core/lib/channel/handshaker.cc +7 -6
- data/src/core/lib/channel/handshaker.h +7 -8
- data/src/core/lib/channel/handshaker_factory.cc +3 -2
- data/src/core/lib/channel/handshaker_factory.h +2 -0
- data/src/core/lib/channel/handshaker_registry.cc +6 -2
- data/src/core/lib/channel/handshaker_registry.h +1 -0
- data/src/core/lib/gpr/arena.cc +84 -37
- data/src/core/lib/gpr/arena.h +2 -0
- data/src/core/lib/gpr/mpscq.h +4 -2
- data/src/core/lib/gprpp/inlined_vector.h +8 -0
- data/src/core/lib/gprpp/ref_counted.h +105 -18
- data/src/core/lib/gprpp/ref_counted_ptr.h +11 -0
- data/src/core/lib/http/httpcli_security_connector.cc +7 -4
- data/src/core/lib/iomgr/call_combiner.cc +2 -0
- data/src/core/lib/iomgr/call_combiner.h +2 -2
- data/src/core/lib/iomgr/closure.h +1 -0
- data/src/core/lib/iomgr/error.cc +16 -31
- data/src/core/lib/iomgr/error.h +29 -4
- data/src/core/lib/iomgr/error_internal.h +0 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +7 -3
- data/src/core/lib/iomgr/ev_posix.cc +0 -2
- data/src/core/lib/iomgr/polling_entity.h +4 -4
- data/src/core/lib/iomgr/resource_quota.cc +64 -10
- data/src/core/lib/iomgr/resource_quota.h +21 -6
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -5
- data/src/core/lib/iomgr/tcp_client_custom.cc +14 -3
- data/src/core/lib/iomgr/tcp_client_posix.cc +2 -0
- data/src/core/lib/iomgr/tcp_posix.cc +4 -2
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -4
- data/src/core/lib/security/context/security_context.cc +20 -13
- data/src/core/lib/security/context/security_context.h +27 -19
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
- data/src/core/lib/security/credentials/credentials.h +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +39 -54
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +3 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -0
- data/src/core/lib/security/security_connector/{alts_security_connector.cc → alts/alts_security_connector.cc} +10 -9
- data/src/core/lib/security/security_connector/{alts_security_connector.h → alts/alts_security_connector.h} +3 -3
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +310 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.h +42 -0
- data/src/core/lib/security/security_connector/{local_security_connector.cc → local/local_security_connector.cc} +4 -3
- data/src/core/lib/security/security_connector/{local_security_connector.h → local/local_security_connector.h} +3 -3
- data/src/core/lib/security/security_connector/security_connector.cc +4 -1039
- data/src/core/lib/security/security_connector/security_connector.h +6 -114
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +474 -0
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +77 -0
- data/src/core/lib/security/security_connector/ssl_utils.cc +345 -0
- data/src/core/lib/security/security_connector/ssl_utils.h +93 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +28 -17
- data/src/core/lib/security/transport/secure_endpoint.cc +51 -41
- data/src/core/lib/security/transport/security_handshaker.cc +6 -7
- data/src/core/lib/security/transport/server_auth_filter.cc +39 -31
- data/src/core/lib/surface/call.cc +100 -80
- data/src/core/lib/surface/call.h +4 -0
- data/src/core/lib/surface/channel.cc +27 -13
- data/src/core/lib/surface/channel.h +4 -3
- data/src/core/lib/surface/completion_queue.cc +8 -1
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +111 -46
- data/src/core/lib/surface/server.h +16 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/error_utils.cc +4 -2
- data/src/core/lib/transport/metadata.cc +3 -2
- data/src/core/lib/transport/metadata.h +3 -2
- data/src/core/lib/transport/metadata_batch.cc +1 -0
- data/src/core/lib/transport/metadata_batch.h +4 -2
- data/src/core/lib/transport/static_metadata.cc +225 -221
- data/src/core/lib/transport/static_metadata.h +74 -71
- data/src/core/lib/transport/transport.h +44 -26
- data/src/core/{ext/filters/client_channel → lib/uri}/uri_parser.cc +1 -1
- data/src/core/{ext/filters/client_channel → lib/uri}/uri_parser.h +3 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -4
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +356 -77
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +46 -36
- data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +83 -0
- data/src/core/tsi/alts/handshaker/alts_shared_resource.h +73 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +122 -175
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +33 -22
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +38 -10
- data/src/core/tsi/transport_security.cc +18 -1
- data/src/core/tsi/transport_security.h +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +2 -3
- metadata +58 -40
- data/src/core/ext/filters/client_channel/method_params.cc +0 -178
- data/src/core/ext/filters/client_channel/method_params.h +0 -78
- data/src/core/tsi/alts/handshaker/alts_tsi_event.cc +0 -75
- data/src/core/tsi/alts/handshaker/alts_tsi_event.h +0 -93
- data/src/core/tsi/alts_transport_security.cc +0 -65
- data/src/core/tsi/alts_transport_security.h +0 -47
@@ -0,0 +1,173 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HEALTH_HEALTH_CHECK_CLIENT_H
|
20
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HEALTH_HEALTH_CHECK_CLIENT_H
|
21
|
+
|
22
|
+
#include <grpc/support/port_platform.h>
|
23
|
+
|
24
|
+
#include <grpc/grpc.h>
|
25
|
+
#include <grpc/support/atm.h>
|
26
|
+
#include <grpc/support/sync.h>
|
27
|
+
|
28
|
+
#include "src/core/ext/filters/client_channel/client_channel_channelz.h"
|
29
|
+
#include "src/core/ext/filters/client_channel/subchannel.h"
|
30
|
+
#include "src/core/lib/backoff/backoff.h"
|
31
|
+
#include "src/core/lib/gpr/arena.h"
|
32
|
+
#include "src/core/lib/gprpp/orphanable.h"
|
33
|
+
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
34
|
+
#include "src/core/lib/iomgr/call_combiner.h"
|
35
|
+
#include "src/core/lib/iomgr/closure.h"
|
36
|
+
#include "src/core/lib/iomgr/polling_entity.h"
|
37
|
+
#include "src/core/lib/iomgr/timer.h"
|
38
|
+
#include "src/core/lib/transport/byte_stream.h"
|
39
|
+
#include "src/core/lib/transport/metadata_batch.h"
|
40
|
+
#include "src/core/lib/transport/transport.h"
|
41
|
+
|
42
|
+
namespace grpc_core {
|
43
|
+
|
44
|
+
class HealthCheckClient
|
45
|
+
: public InternallyRefCountedWithTracing<HealthCheckClient> {
|
46
|
+
public:
|
47
|
+
HealthCheckClient(const char* service_name,
|
48
|
+
RefCountedPtr<ConnectedSubchannel> connected_subchannel,
|
49
|
+
grpc_pollset_set* interested_parties,
|
50
|
+
RefCountedPtr<channelz::SubchannelNode> channelz_node);
|
51
|
+
|
52
|
+
~HealthCheckClient();
|
53
|
+
|
54
|
+
// When the health state changes from *state, sets *state to the new
|
55
|
+
// value and schedules closure.
|
56
|
+
// Only one closure can be outstanding at a time.
|
57
|
+
void NotifyOnHealthChange(grpc_connectivity_state* state,
|
58
|
+
grpc_closure* closure);
|
59
|
+
|
60
|
+
void Orphan() override;
|
61
|
+
|
62
|
+
private:
|
63
|
+
// Contains a call to the backend and all the data related to the call.
|
64
|
+
class CallState : public InternallyRefCountedWithTracing<CallState> {
|
65
|
+
public:
|
66
|
+
CallState(RefCountedPtr<HealthCheckClient> health_check_client,
|
67
|
+
grpc_pollset_set* interested_parties_);
|
68
|
+
~CallState();
|
69
|
+
|
70
|
+
void Orphan() override;
|
71
|
+
|
72
|
+
void StartCall();
|
73
|
+
|
74
|
+
private:
|
75
|
+
void Cancel();
|
76
|
+
|
77
|
+
void StartBatch(grpc_transport_stream_op_batch* batch);
|
78
|
+
static void StartBatchInCallCombiner(void* arg, grpc_error* error);
|
79
|
+
|
80
|
+
static void CallEndedRetry(void* arg, grpc_error* error);
|
81
|
+
void CallEnded(bool retry);
|
82
|
+
|
83
|
+
static void OnComplete(void* arg, grpc_error* error);
|
84
|
+
static void RecvInitialMetadataReady(void* arg, grpc_error* error);
|
85
|
+
static void RecvMessageReady(void* arg, grpc_error* error);
|
86
|
+
static void RecvTrailingMetadataReady(void* arg, grpc_error* error);
|
87
|
+
static void StartCancel(void* arg, grpc_error* error);
|
88
|
+
static void OnCancelComplete(void* arg, grpc_error* error);
|
89
|
+
|
90
|
+
static void OnByteStreamNext(void* arg, grpc_error* error);
|
91
|
+
void ContinueReadingRecvMessage();
|
92
|
+
grpc_error* PullSliceFromRecvMessage();
|
93
|
+
void DoneReadingRecvMessage(grpc_error* error);
|
94
|
+
|
95
|
+
RefCountedPtr<HealthCheckClient> health_check_client_;
|
96
|
+
grpc_polling_entity pollent_;
|
97
|
+
|
98
|
+
gpr_arena* arena_;
|
99
|
+
grpc_call_combiner call_combiner_;
|
100
|
+
grpc_call_context_element context_[GRPC_CONTEXT_COUNT] = {};
|
101
|
+
|
102
|
+
// The streaming call to the backend. Always non-NULL.
|
103
|
+
grpc_subchannel_call* call_;
|
104
|
+
|
105
|
+
grpc_transport_stream_op_batch_payload payload_;
|
106
|
+
grpc_transport_stream_op_batch batch_;
|
107
|
+
grpc_transport_stream_op_batch recv_message_batch_;
|
108
|
+
grpc_transport_stream_op_batch recv_trailing_metadata_batch_;
|
109
|
+
|
110
|
+
grpc_closure on_complete_;
|
111
|
+
|
112
|
+
// send_initial_metadata
|
113
|
+
grpc_metadata_batch send_initial_metadata_;
|
114
|
+
grpc_linked_mdelem path_metadata_storage_;
|
115
|
+
|
116
|
+
// send_message
|
117
|
+
ManualConstructor<SliceBufferByteStream> send_message_;
|
118
|
+
|
119
|
+
// send_trailing_metadata
|
120
|
+
grpc_metadata_batch send_trailing_metadata_;
|
121
|
+
|
122
|
+
// recv_initial_metadata
|
123
|
+
grpc_metadata_batch recv_initial_metadata_;
|
124
|
+
grpc_closure recv_initial_metadata_ready_;
|
125
|
+
|
126
|
+
// recv_message
|
127
|
+
OrphanablePtr<ByteStream> recv_message_;
|
128
|
+
grpc_closure recv_message_ready_;
|
129
|
+
grpc_slice_buffer recv_message_buffer_;
|
130
|
+
gpr_atm seen_response_;
|
131
|
+
|
132
|
+
// recv_trailing_metadata
|
133
|
+
grpc_metadata_batch recv_trailing_metadata_;
|
134
|
+
grpc_transport_stream_stats collect_stats_;
|
135
|
+
grpc_closure recv_trailing_metadata_ready_;
|
136
|
+
};
|
137
|
+
|
138
|
+
void StartCall();
|
139
|
+
void StartCallLocked(); // Requires holding mu_.
|
140
|
+
|
141
|
+
void StartRetryTimer();
|
142
|
+
static void OnRetryTimer(void* arg, grpc_error* error);
|
143
|
+
|
144
|
+
void SetHealthStatus(grpc_connectivity_state state, grpc_error* error);
|
145
|
+
void SetHealthStatusLocked(grpc_connectivity_state state,
|
146
|
+
grpc_error* error); // Requires holding mu_.
|
147
|
+
|
148
|
+
const char* service_name_; // Do not own.
|
149
|
+
RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
|
150
|
+
grpc_pollset_set* interested_parties_; // Do not own.
|
151
|
+
RefCountedPtr<channelz::SubchannelNode> channelz_node_;
|
152
|
+
|
153
|
+
gpr_mu mu_;
|
154
|
+
grpc_connectivity_state state_ = GRPC_CHANNEL_CONNECTING;
|
155
|
+
grpc_error* error_ = GRPC_ERROR_NONE;
|
156
|
+
grpc_connectivity_state* notify_state_ = nullptr;
|
157
|
+
grpc_closure* on_health_changed_ = nullptr;
|
158
|
+
bool shutting_down_ = false;
|
159
|
+
|
160
|
+
// The data associated with the current health check call. It holds a ref
|
161
|
+
// to this HealthCheckClient object.
|
162
|
+
OrphanablePtr<CallState> call_state_;
|
163
|
+
|
164
|
+
// Call retry state.
|
165
|
+
BackOff retry_backoff_;
|
166
|
+
grpc_timer retry_timer_;
|
167
|
+
grpc_closure retry_timer_callback_;
|
168
|
+
bool retry_timer_callback_pending_ = false;
|
169
|
+
};
|
170
|
+
|
171
|
+
} // namespace grpc_core
|
172
|
+
|
173
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HEALTH_HEALTH_CHECK_CLIENT_H */
|
@@ -29,7 +29,6 @@
|
|
29
29
|
|
30
30
|
#include "src/core/ext/filters/client_channel/client_channel.h"
|
31
31
|
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
32
|
-
#include "src/core/ext/filters/client_channel/uri_parser.h"
|
33
32
|
#include "src/core/lib/channel/channel_args.h"
|
34
33
|
#include "src/core/lib/channel/handshaker_registry.h"
|
35
34
|
#include "src/core/lib/gpr/env.h"
|
@@ -37,6 +36,7 @@
|
|
37
36
|
#include "src/core/lib/http/format_request.h"
|
38
37
|
#include "src/core/lib/http/parser.h"
|
39
38
|
#include "src/core/lib/slice/slice_internal.h"
|
39
|
+
#include "src/core/lib/uri/uri_parser.h"
|
40
40
|
|
41
41
|
typedef struct http_connect_handshaker {
|
42
42
|
// Base class. Must be first.
|
@@ -351,6 +351,7 @@ static grpc_handshaker* grpc_http_connect_handshaker_create() {
|
|
351
351
|
|
352
352
|
static void handshaker_factory_add_handshakers(
|
353
353
|
grpc_handshaker_factory* factory, const grpc_channel_args* args,
|
354
|
+
grpc_pollset_set* interested_parties,
|
354
355
|
grpc_handshake_manager* handshake_mgr) {
|
355
356
|
grpc_handshake_manager_add(handshake_mgr,
|
356
357
|
grpc_http_connect_handshaker_create());
|
@@ -29,12 +29,12 @@
|
|
29
29
|
|
30
30
|
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
|
31
31
|
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
|
32
|
-
#include "src/core/ext/filters/client_channel/uri_parser.h"
|
33
32
|
#include "src/core/lib/channel/channel_args.h"
|
34
33
|
#include "src/core/lib/gpr/env.h"
|
35
34
|
#include "src/core/lib/gpr/host_port.h"
|
36
35
|
#include "src/core/lib/gpr/string.h"
|
37
36
|
#include "src/core/lib/slice/b64.h"
|
37
|
+
#include "src/core/lib/uri/uri_parser.h"
|
38
38
|
|
39
39
|
/**
|
40
40
|
* Parses the 'https_proxy' env var (fallback on 'http_proxy') and returns the
|
@@ -58,44 +58,47 @@ class LoadBalancingPolicy
|
|
58
58
|
/// Note that the LB policy gets the set of addresses from the
|
59
59
|
/// GRPC_ARG_LB_ADDRESSES channel arg.
|
60
60
|
grpc_channel_args* args = nullptr;
|
61
|
+
/// Load balancing config from the resolver.
|
62
|
+
grpc_json* lb_config = nullptr;
|
61
63
|
};
|
62
64
|
|
63
65
|
/// State used for an LB pick.
|
64
66
|
struct PickState {
|
65
67
|
/// Initial metadata associated with the picking call.
|
66
|
-
grpc_metadata_batch* initial_metadata;
|
68
|
+
grpc_metadata_batch* initial_metadata = nullptr;
|
67
69
|
/// Bitmask used for selective cancelling. See
|
68
70
|
/// \a CancelMatchingPicksLocked() and \a GRPC_INITIAL_METADATA_* in
|
69
71
|
/// grpc_types.h.
|
70
|
-
uint32_t initial_metadata_flags;
|
72
|
+
uint32_t initial_metadata_flags = 0;
|
71
73
|
/// Storage for LB token in \a initial_metadata, or nullptr if not used.
|
72
74
|
grpc_linked_mdelem lb_token_mdelem_storage;
|
73
75
|
/// Closure to run when pick is complete, if not completed synchronously.
|
74
76
|
/// If null, pick will fail if a result is not available synchronously.
|
75
|
-
grpc_closure* on_complete;
|
77
|
+
grpc_closure* on_complete = nullptr;
|
76
78
|
/// Will be set to the selected subchannel, or nullptr on failure or when
|
77
79
|
/// the LB policy decides to drop the call.
|
78
80
|
RefCountedPtr<ConnectedSubchannel> connected_subchannel;
|
79
81
|
/// Will be populated with context to pass to the subchannel call, if
|
80
82
|
/// needed.
|
81
|
-
grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
|
83
|
+
grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT] = {};
|
82
84
|
/// Upon success, \a *user_data will be set to whatever opaque information
|
83
85
|
/// may need to be propagated from the LB policy, or nullptr if not needed.
|
84
86
|
// TODO(roth): As part of revamping our metadata APIs, try to find a
|
85
87
|
// way to clean this up and C++-ify it.
|
86
|
-
void** user_data;
|
88
|
+
void** user_data = nullptr;
|
87
89
|
/// Next pointer. For internal use by LB policy.
|
88
|
-
PickState* next;
|
90
|
+
PickState* next = nullptr;
|
89
91
|
};
|
90
92
|
|
91
93
|
// Not copyable nor movable.
|
92
94
|
LoadBalancingPolicy(const LoadBalancingPolicy&) = delete;
|
93
95
|
LoadBalancingPolicy& operator=(const LoadBalancingPolicy&) = delete;
|
94
96
|
|
95
|
-
/// Updates the policy with a new set of \a args
|
96
|
-
/// Note that the LB policy gets the set of addresses from the
|
97
|
+
/// Updates the policy with a new set of \a args and a new \a lb_config from
|
98
|
+
/// the resolver. Note that the LB policy gets the set of addresses from the
|
97
99
|
/// GRPC_ARG_LB_ADDRESSES channel arg.
|
98
|
-
virtual void UpdateLocked(const grpc_channel_args& args
|
100
|
+
virtual void UpdateLocked(const grpc_channel_args& args,
|
101
|
+
grpc_json* lb_config) GRPC_ABSTRACT;
|
99
102
|
|
100
103
|
/// Finds an appropriate subchannel for a call, based on data in \a pick.
|
101
104
|
/// \a pick must remain alive until the pick is complete.
|
@@ -151,9 +154,9 @@ class LoadBalancingPolicy
|
|
151
154
|
/// LB policy's referenced children. This is not invoked from the
|
152
155
|
/// client_channel's combiner. The implementation is responsible for
|
153
156
|
/// providing its own synchronization.
|
154
|
-
virtual void FillChildRefsForChannelz(
|
155
|
-
|
156
|
-
GRPC_ABSTRACT;
|
157
|
+
virtual void FillChildRefsForChannelz(
|
158
|
+
channelz::ChildRefsList* child_subchannels,
|
159
|
+
channelz::ChildRefsList* child_channels) GRPC_ABSTRACT;
|
157
160
|
|
158
161
|
void Orphan() override {
|
159
162
|
// Invoke ShutdownAndUnrefLocked() inside of the combiner.
|
@@ -212,8 +215,8 @@ class LoadBalancingPolicy
|
|
212
215
|
// Dummy classes needed for alignment issues.
|
213
216
|
// See https://github.com/grpc/grpc/issues/16032 for context.
|
214
217
|
// TODO(ncteisen): remove this as soon as the issue is resolved.
|
215
|
-
ChildRefsList dummy_list_foo;
|
216
|
-
ChildRefsList dummy_list_bar;
|
218
|
+
channelz::ChildRefsList dummy_list_foo;
|
219
|
+
channelz::ChildRefsList dummy_list_bar;
|
217
220
|
};
|
218
221
|
|
219
222
|
} // namespace grpc_core
|
@@ -37,16 +37,27 @@ static void destroy_channel_elem(grpc_channel_element* elem) {}
|
|
37
37
|
namespace {
|
38
38
|
|
39
39
|
struct call_data {
|
40
|
+
call_data(const grpc_call_element_args& args) {
|
41
|
+
if (args.context[GRPC_GRPCLB_CLIENT_STATS].value != nullptr) {
|
42
|
+
// Get stats object from context and take a ref.
|
43
|
+
client_stats = static_cast<grpc_core::GrpcLbClientStats*>(
|
44
|
+
args.context[GRPC_GRPCLB_CLIENT_STATS].value)
|
45
|
+
->Ref();
|
46
|
+
// Record call started.
|
47
|
+
client_stats->AddCallStarted();
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
40
51
|
// Stats object to update.
|
41
52
|
grpc_core::RefCountedPtr<grpc_core::GrpcLbClientStats> client_stats;
|
42
53
|
// State for intercepting send_initial_metadata.
|
43
54
|
grpc_closure on_complete_for_send;
|
44
55
|
grpc_closure* original_on_complete_for_send;
|
45
|
-
bool send_initial_metadata_succeeded;
|
56
|
+
bool send_initial_metadata_succeeded = false;
|
46
57
|
// State for intercepting recv_initial_metadata.
|
47
58
|
grpc_closure recv_initial_metadata_ready;
|
48
59
|
grpc_closure* original_recv_initial_metadata_ready;
|
49
|
-
bool recv_initial_metadata_succeeded;
|
60
|
+
bool recv_initial_metadata_succeeded = false;
|
50
61
|
};
|
51
62
|
|
52
63
|
} // namespace
|
@@ -70,16 +81,8 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
|
|
70
81
|
|
71
82
|
static grpc_error* init_call_elem(grpc_call_element* elem,
|
72
83
|
const grpc_call_element_args* args) {
|
73
|
-
call_data* calld = static_cast<call_data*>(elem->call_data);
|
74
|
-
// Get stats object from context and take a ref.
|
75
84
|
GPR_ASSERT(args->context != nullptr);
|
76
|
-
|
77
|
-
calld->client_stats = static_cast<grpc_core::GrpcLbClientStats*>(
|
78
|
-
args->context[GRPC_GRPCLB_CLIENT_STATS].value)
|
79
|
-
->Ref();
|
80
|
-
// Record call started.
|
81
|
-
calld->client_stats->AddCallStarted();
|
82
|
-
}
|
85
|
+
new (elem->call_data) call_data(*args);
|
83
86
|
return GRPC_ERROR_NONE;
|
84
87
|
}
|
85
88
|
|
@@ -97,6 +100,7 @@ static void destroy_call_elem(grpc_call_element* elem,
|
|
97
100
|
// TODO(roth): Eliminate this once filter stack is converted to C++.
|
98
101
|
calld->client_stats.reset();
|
99
102
|
}
|
103
|
+
calld->~call_data();
|
100
104
|
}
|
101
105
|
|
102
106
|
static void start_transport_stream_op_batch(
|
@@ -123,7 +123,8 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
123
123
|
public:
|
124
124
|
GrpcLb(const grpc_lb_addresses* addresses, const Args& args);
|
125
125
|
|
126
|
-
void UpdateLocked(const grpc_channel_args& args
|
126
|
+
void UpdateLocked(const grpc_channel_args& args,
|
127
|
+
grpc_json* lb_config) override;
|
127
128
|
bool PickLocked(PickState* pick, grpc_error** error) override;
|
128
129
|
void CancelPickLocked(PickState* pick, grpc_error* error) override;
|
129
130
|
void CancelMatchingPicksLocked(uint32_t initial_metadata_flags_mask,
|
@@ -136,8 +137,9 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
136
137
|
void HandOffPendingPicksLocked(LoadBalancingPolicy* new_policy) override;
|
137
138
|
void ExitIdleLocked() override;
|
138
139
|
void ResetBackoffLocked() override;
|
139
|
-
void FillChildRefsForChannelz(
|
140
|
-
|
140
|
+
void FillChildRefsForChannelz(
|
141
|
+
channelz::ChildRefsList* child_subchannels,
|
142
|
+
channelz::ChildRefsList* child_channels) override;
|
141
143
|
|
142
144
|
private:
|
143
145
|
/// Linked list of pending pick requests. It stores all information needed to
|
@@ -1258,8 +1260,9 @@ bool GrpcLb::PickLocked(PickState* pick, grpc_error** error) {
|
|
1258
1260
|
return pick_done;
|
1259
1261
|
}
|
1260
1262
|
|
1261
|
-
void GrpcLb::FillChildRefsForChannelz(
|
1262
|
-
|
1263
|
+
void GrpcLb::FillChildRefsForChannelz(
|
1264
|
+
channelz::ChildRefsList* child_subchannels,
|
1265
|
+
channelz::ChildRefsList* child_channels) {
|
1263
1266
|
// delegate to the RoundRobin to fill the children subchannels.
|
1264
1267
|
rr_policy_->FillChildRefsForChannelz(child_subchannels, child_channels);
|
1265
1268
|
MutexLock lock(&lb_channel_mu_);
|
@@ -1329,13 +1332,10 @@ void GrpcLb::ProcessChannelArgsLocked(const grpc_channel_args& args) {
|
|
1329
1332
|
grpc_channel_args_destroy(lb_channel_args);
|
1330
1333
|
}
|
1331
1334
|
|
1332
|
-
void GrpcLb::UpdateLocked(const grpc_channel_args& args) {
|
1335
|
+
void GrpcLb::UpdateLocked(const grpc_channel_args& args, grpc_json* lb_config) {
|
1333
1336
|
ProcessChannelArgsLocked(args);
|
1334
|
-
//
|
1335
|
-
|
1336
|
-
if (lb_fallback_timeout_ms_ > 0 && rr_policy_ != nullptr) {
|
1337
|
-
CreateOrUpdateRoundRobinPolicyLocked();
|
1338
|
-
}
|
1337
|
+
// Update the existing RR policy.
|
1338
|
+
if (rr_policy_ != nullptr) CreateOrUpdateRoundRobinPolicyLocked();
|
1339
1339
|
// Start watching the LB channel connectivity for connection, if not
|
1340
1340
|
// already doing so.
|
1341
1341
|
if (!watching_lb_channel_) {
|
@@ -1489,7 +1489,7 @@ void GrpcLb::OnBalancerChannelConnectivityChangedLocked(void* arg,
|
|
1489
1489
|
grpclb_policy->lb_call_backoff_.Reset();
|
1490
1490
|
grpclb_policy->StartBalancerCallLocked();
|
1491
1491
|
}
|
1492
|
-
//
|
1492
|
+
// fallthrough
|
1493
1493
|
case GRPC_CHANNEL_SHUTDOWN:
|
1494
1494
|
done:
|
1495
1495
|
grpclb_policy->watching_lb_channel_ = false;
|
@@ -1697,7 +1697,7 @@ grpc_channel_args* GrpcLb::CreateRoundRobinPolicyArgsLocked() {
|
|
1697
1697
|
// Replace the LB addresses in the channel args that we pass down to
|
1698
1698
|
// the subchannel.
|
1699
1699
|
static const char* keys_to_remove[] = {GRPC_ARG_LB_ADDRESSES};
|
1700
|
-
|
1700
|
+
grpc_arg args_to_add[3] = {
|
1701
1701
|
grpc_lb_addresses_create_channel_arg(addresses),
|
1702
1702
|
// A channel arg indicating if the target is a backend inferred from a
|
1703
1703
|
// grpclb load balancer.
|
@@ -1706,9 +1706,15 @@ grpc_channel_args* GrpcLb::CreateRoundRobinPolicyArgsLocked() {
|
|
1706
1706
|
GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER),
|
1707
1707
|
is_backend_from_grpclb_load_balancer),
|
1708
1708
|
};
|
1709
|
+
size_t num_args_to_add = 2;
|
1710
|
+
if (is_backend_from_grpclb_load_balancer) {
|
1711
|
+
args_to_add[2] = grpc_channel_arg_integer_create(
|
1712
|
+
const_cast<char*>(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1);
|
1713
|
+
++num_args_to_add;
|
1714
|
+
}
|
1709
1715
|
grpc_channel_args* args = grpc_channel_args_copy_and_add_and_remove(
|
1710
1716
|
args_, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add,
|
1711
|
-
|
1717
|
+
num_args_to_add);
|
1712
1718
|
grpc_lb_addresses_destroy(addresses);
|
1713
1719
|
return args;
|
1714
1720
|
}
|
@@ -1722,7 +1728,7 @@ void GrpcLb::CreateOrUpdateRoundRobinPolicyLocked() {
|
|
1722
1728
|
gpr_log(GPR_INFO, "[grpclb %p] Updating RR policy %p", this,
|
1723
1729
|
rr_policy_.get());
|
1724
1730
|
}
|
1725
|
-
rr_policy_->UpdateLocked(*args);
|
1731
|
+
rr_policy_->UpdateLocked(*args, nullptr);
|
1726
1732
|
} else {
|
1727
1733
|
LoadBalancingPolicy::Args lb_policy_args;
|
1728
1734
|
lb_policy_args.combiner = combiner();
|
@@ -46,7 +46,8 @@ class PickFirst : public LoadBalancingPolicy {
|
|
46
46
|
public:
|
47
47
|
explicit PickFirst(const Args& args);
|
48
48
|
|
49
|
-
void UpdateLocked(const grpc_channel_args& args
|
49
|
+
void UpdateLocked(const grpc_channel_args& args,
|
50
|
+
grpc_json* lb_config) override;
|
50
51
|
bool PickLocked(PickState* pick, grpc_error** error) override;
|
51
52
|
void CancelPickLocked(PickState* pick, grpc_error* error) override;
|
52
53
|
void CancelMatchingPicksLocked(uint32_t initial_metadata_flags_mask,
|
@@ -59,8 +60,8 @@ class PickFirst : public LoadBalancingPolicy {
|
|
59
60
|
void HandOffPendingPicksLocked(LoadBalancingPolicy* new_policy) override;
|
60
61
|
void ExitIdleLocked() override;
|
61
62
|
void ResetBackoffLocked() override;
|
62
|
-
void FillChildRefsForChannelz(ChildRefsList* child_subchannels,
|
63
|
-
ChildRefsList* ignored) override;
|
63
|
+
void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels,
|
64
|
+
channelz::ChildRefsList* ignored) override;
|
64
65
|
|
65
66
|
private:
|
66
67
|
~PickFirst();
|
@@ -147,8 +148,8 @@ class PickFirst : public LoadBalancingPolicy {
|
|
147
148
|
/// Lock and data used to capture snapshots of this channels child
|
148
149
|
/// channels and subchannels. This data is consumed by channelz.
|
149
150
|
gpr_mu child_refs_mu_;
|
150
|
-
ChildRefsList child_subchannels_;
|
151
|
-
ChildRefsList child_channels_;
|
151
|
+
channelz::ChildRefsList child_subchannels_;
|
152
|
+
channelz::ChildRefsList child_channels_;
|
152
153
|
};
|
153
154
|
|
154
155
|
PickFirst::PickFirst(const Args& args) : LoadBalancingPolicy(args) {
|
@@ -159,7 +160,7 @@ PickFirst::PickFirst(const Args& args) : LoadBalancingPolicy(args) {
|
|
159
160
|
if (grpc_lb_pick_first_trace.enabled()) {
|
160
161
|
gpr_log(GPR_INFO, "Pick First %p created.", this);
|
161
162
|
}
|
162
|
-
UpdateLocked(*args.args);
|
163
|
+
UpdateLocked(*args.args, args.lb_config);
|
163
164
|
grpc_subchannel_index_ref();
|
164
165
|
}
|
165
166
|
|
@@ -300,7 +301,8 @@ void PickFirst::NotifyOnStateChangeLocked(grpc_connectivity_state* current,
|
|
300
301
|
}
|
301
302
|
|
302
303
|
void PickFirst::FillChildRefsForChannelz(
|
303
|
-
ChildRefsList* child_subchannels_to_fill,
|
304
|
+
channelz::ChildRefsList* child_subchannels_to_fill,
|
305
|
+
channelz::ChildRefsList* ignored) {
|
304
306
|
MutexLock lock(&child_refs_mu_);
|
305
307
|
for (size_t i = 0; i < child_subchannels_.size(); ++i) {
|
306
308
|
// TODO(ncteisen): implement a de dup loop that is not O(n^2). Might
|
@@ -320,7 +322,7 @@ void PickFirst::FillChildRefsForChannelz(
|
|
320
322
|
}
|
321
323
|
|
322
324
|
void PickFirst::UpdateChildRefsLocked() {
|
323
|
-
ChildRefsList cs;
|
325
|
+
channelz::ChildRefsList cs;
|
324
326
|
if (subchannel_list_ != nullptr) {
|
325
327
|
subchannel_list_->PopulateChildRefsList(&cs);
|
326
328
|
}
|
@@ -332,7 +334,8 @@ void PickFirst::UpdateChildRefsLocked() {
|
|
332
334
|
child_subchannels_ = std::move(cs);
|
333
335
|
}
|
334
336
|
|
335
|
-
void PickFirst::UpdateLocked(const grpc_channel_args& args
|
337
|
+
void PickFirst::UpdateLocked(const grpc_channel_args& args,
|
338
|
+
grpc_json* lb_config) {
|
336
339
|
AutoChildRefsUpdater guard(this);
|
337
340
|
const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES);
|
338
341
|
if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
|
@@ -358,9 +361,14 @@ void PickFirst::UpdateLocked(const grpc_channel_args& args) {
|
|
358
361
|
"Pick First %p received update with %" PRIuPTR " addresses", this,
|
359
362
|
addresses->num_addresses);
|
360
363
|
}
|
364
|
+
grpc_arg new_arg = grpc_channel_arg_integer_create(
|
365
|
+
const_cast<char*>(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1);
|
366
|
+
grpc_channel_args* new_args =
|
367
|
+
grpc_channel_args_copy_and_add(&args, &new_arg, 1);
|
361
368
|
auto subchannel_list = MakeOrphanable<PickFirstSubchannelList>(
|
362
369
|
this, &grpc_lb_pick_first_trace, addresses, combiner(),
|
363
|
-
client_channel_factory(),
|
370
|
+
client_channel_factory(), *new_args);
|
371
|
+
grpc_channel_args_destroy(new_args);
|
364
372
|
if (subchannel_list->num_subchannels() == 0) {
|
365
373
|
// Empty update or no valid subchannels. Unsubscribe from all current
|
366
374
|
// subchannels and put the channel in TRANSIENT_FAILURE.
|