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
@@ -1,178 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 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
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#include <stdio.h>
|
22
|
-
#include <string.h>
|
23
|
-
|
24
|
-
#include <grpc/support/alloc.h>
|
25
|
-
#include <grpc/support/log.h>
|
26
|
-
#include <grpc/support/string_util.h>
|
27
|
-
|
28
|
-
#include "src/core/ext/filters/client_channel/method_params.h"
|
29
|
-
#include "src/core/lib/channel/status_util.h"
|
30
|
-
#include "src/core/lib/gpr/string.h"
|
31
|
-
#include "src/core/lib/gprpp/memory.h"
|
32
|
-
|
33
|
-
// As per the retry design, we do not allow more than 5 retry attempts.
|
34
|
-
#define MAX_MAX_RETRY_ATTEMPTS 5
|
35
|
-
|
36
|
-
namespace grpc_core {
|
37
|
-
namespace internal {
|
38
|
-
|
39
|
-
namespace {
|
40
|
-
|
41
|
-
bool ParseWaitForReady(
|
42
|
-
grpc_json* field, ClientChannelMethodParams::WaitForReady* wait_for_ready) {
|
43
|
-
if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) {
|
44
|
-
return false;
|
45
|
-
}
|
46
|
-
*wait_for_ready = field->type == GRPC_JSON_TRUE
|
47
|
-
? ClientChannelMethodParams::WAIT_FOR_READY_TRUE
|
48
|
-
: ClientChannelMethodParams::WAIT_FOR_READY_FALSE;
|
49
|
-
return true;
|
50
|
-
}
|
51
|
-
|
52
|
-
// Parses a JSON field of the form generated for a google.proto.Duration
|
53
|
-
// proto message, as per:
|
54
|
-
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
55
|
-
bool ParseDuration(grpc_json* field, grpc_millis* duration) {
|
56
|
-
if (field->type != GRPC_JSON_STRING) return false;
|
57
|
-
size_t len = strlen(field->value);
|
58
|
-
if (field->value[len - 1] != 's') return false;
|
59
|
-
UniquePtr<char> buf(gpr_strdup(field->value));
|
60
|
-
*(buf.get() + len - 1) = '\0'; // Remove trailing 's'.
|
61
|
-
char* decimal_point = strchr(buf.get(), '.');
|
62
|
-
int nanos = 0;
|
63
|
-
if (decimal_point != nullptr) {
|
64
|
-
*decimal_point = '\0';
|
65
|
-
nanos = gpr_parse_nonnegative_int(decimal_point + 1);
|
66
|
-
if (nanos == -1) {
|
67
|
-
return false;
|
68
|
-
}
|
69
|
-
int num_digits = static_cast<int>(strlen(decimal_point + 1));
|
70
|
-
if (num_digits > 9) { // We don't accept greater precision than nanos.
|
71
|
-
return false;
|
72
|
-
}
|
73
|
-
for (int i = 0; i < (9 - num_digits); ++i) {
|
74
|
-
nanos *= 10;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
int seconds =
|
78
|
-
decimal_point == buf.get() ? 0 : gpr_parse_nonnegative_int(buf.get());
|
79
|
-
if (seconds == -1) return false;
|
80
|
-
*duration = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS;
|
81
|
-
return true;
|
82
|
-
}
|
83
|
-
|
84
|
-
UniquePtr<ClientChannelMethodParams::RetryPolicy> ParseRetryPolicy(
|
85
|
-
grpc_json* field) {
|
86
|
-
auto retry_policy = MakeUnique<ClientChannelMethodParams::RetryPolicy>();
|
87
|
-
if (field->type != GRPC_JSON_OBJECT) return nullptr;
|
88
|
-
for (grpc_json* sub_field = field->child; sub_field != nullptr;
|
89
|
-
sub_field = sub_field->next) {
|
90
|
-
if (sub_field->key == nullptr) return nullptr;
|
91
|
-
if (strcmp(sub_field->key, "maxAttempts") == 0) {
|
92
|
-
if (retry_policy->max_attempts != 0) return nullptr; // Duplicate.
|
93
|
-
if (sub_field->type != GRPC_JSON_NUMBER) return nullptr;
|
94
|
-
retry_policy->max_attempts = gpr_parse_nonnegative_int(sub_field->value);
|
95
|
-
if (retry_policy->max_attempts <= 1) return nullptr;
|
96
|
-
if (retry_policy->max_attempts > MAX_MAX_RETRY_ATTEMPTS) {
|
97
|
-
gpr_log(GPR_ERROR,
|
98
|
-
"service config: clamped retryPolicy.maxAttempts at %d",
|
99
|
-
MAX_MAX_RETRY_ATTEMPTS);
|
100
|
-
retry_policy->max_attempts = MAX_MAX_RETRY_ATTEMPTS;
|
101
|
-
}
|
102
|
-
} else if (strcmp(sub_field->key, "initialBackoff") == 0) {
|
103
|
-
if (retry_policy->initial_backoff > 0) return nullptr; // Duplicate.
|
104
|
-
if (!ParseDuration(sub_field, &retry_policy->initial_backoff)) {
|
105
|
-
return nullptr;
|
106
|
-
}
|
107
|
-
if (retry_policy->initial_backoff == 0) return nullptr;
|
108
|
-
} else if (strcmp(sub_field->key, "maxBackoff") == 0) {
|
109
|
-
if (retry_policy->max_backoff > 0) return nullptr; // Duplicate.
|
110
|
-
if (!ParseDuration(sub_field, &retry_policy->max_backoff)) {
|
111
|
-
return nullptr;
|
112
|
-
}
|
113
|
-
if (retry_policy->max_backoff == 0) return nullptr;
|
114
|
-
} else if (strcmp(sub_field->key, "backoffMultiplier") == 0) {
|
115
|
-
if (retry_policy->backoff_multiplier != 0) return nullptr; // Duplicate.
|
116
|
-
if (sub_field->type != GRPC_JSON_NUMBER) return nullptr;
|
117
|
-
if (sscanf(sub_field->value, "%f", &retry_policy->backoff_multiplier) !=
|
118
|
-
1) {
|
119
|
-
return nullptr;
|
120
|
-
}
|
121
|
-
if (retry_policy->backoff_multiplier <= 0) return nullptr;
|
122
|
-
} else if (strcmp(sub_field->key, "retryableStatusCodes") == 0) {
|
123
|
-
if (!retry_policy->retryable_status_codes.Empty()) {
|
124
|
-
return nullptr; // Duplicate.
|
125
|
-
}
|
126
|
-
if (sub_field->type != GRPC_JSON_ARRAY) return nullptr;
|
127
|
-
for (grpc_json* element = sub_field->child; element != nullptr;
|
128
|
-
element = element->next) {
|
129
|
-
if (element->type != GRPC_JSON_STRING) return nullptr;
|
130
|
-
grpc_status_code status;
|
131
|
-
if (!grpc_status_code_from_string(element->value, &status)) {
|
132
|
-
return nullptr;
|
133
|
-
}
|
134
|
-
retry_policy->retryable_status_codes.Add(status);
|
135
|
-
}
|
136
|
-
if (retry_policy->retryable_status_codes.Empty()) return nullptr;
|
137
|
-
}
|
138
|
-
}
|
139
|
-
// Make sure required fields are set.
|
140
|
-
if (retry_policy->max_attempts == 0 || retry_policy->initial_backoff == 0 ||
|
141
|
-
retry_policy->max_backoff == 0 || retry_policy->backoff_multiplier == 0 ||
|
142
|
-
retry_policy->retryable_status_codes.Empty()) {
|
143
|
-
return nullptr;
|
144
|
-
}
|
145
|
-
return retry_policy;
|
146
|
-
}
|
147
|
-
|
148
|
-
} // namespace
|
149
|
-
|
150
|
-
RefCountedPtr<ClientChannelMethodParams>
|
151
|
-
ClientChannelMethodParams::CreateFromJson(const grpc_json* json) {
|
152
|
-
RefCountedPtr<ClientChannelMethodParams> method_params =
|
153
|
-
MakeRefCounted<ClientChannelMethodParams>();
|
154
|
-
for (grpc_json* field = json->child; field != nullptr; field = field->next) {
|
155
|
-
if (field->key == nullptr) continue;
|
156
|
-
if (strcmp(field->key, "waitForReady") == 0) {
|
157
|
-
if (method_params->wait_for_ready_ != WAIT_FOR_READY_UNSET) {
|
158
|
-
return nullptr; // Duplicate.
|
159
|
-
}
|
160
|
-
if (!ParseWaitForReady(field, &method_params->wait_for_ready_)) {
|
161
|
-
return nullptr;
|
162
|
-
}
|
163
|
-
} else if (strcmp(field->key, "timeout") == 0) {
|
164
|
-
if (method_params->timeout_ > 0) return nullptr; // Duplicate.
|
165
|
-
if (!ParseDuration(field, &method_params->timeout_)) return nullptr;
|
166
|
-
} else if (strcmp(field->key, "retryPolicy") == 0) {
|
167
|
-
if (method_params->retry_policy_ != nullptr) {
|
168
|
-
return nullptr; // Duplicate.
|
169
|
-
}
|
170
|
-
method_params->retry_policy_ = ParseRetryPolicy(field);
|
171
|
-
if (method_params->retry_policy_ == nullptr) return nullptr;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
return method_params;
|
175
|
-
}
|
176
|
-
|
177
|
-
} // namespace internal
|
178
|
-
} // namespace grpc_core
|
@@ -1,78 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 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_METHOD_PARAMS_H
|
20
|
-
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_METHOD_PARAMS_H
|
21
|
-
|
22
|
-
#include <grpc/support/port_platform.h>
|
23
|
-
|
24
|
-
#include "src/core/lib/channel/status_util.h"
|
25
|
-
#include "src/core/lib/gprpp/ref_counted.h"
|
26
|
-
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
27
|
-
#include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis
|
28
|
-
#include "src/core/lib/json/json.h"
|
29
|
-
|
30
|
-
namespace grpc_core {
|
31
|
-
namespace internal {
|
32
|
-
|
33
|
-
class ClientChannelMethodParams : public RefCounted<ClientChannelMethodParams> {
|
34
|
-
public:
|
35
|
-
enum WaitForReady {
|
36
|
-
WAIT_FOR_READY_UNSET = 0,
|
37
|
-
WAIT_FOR_READY_FALSE,
|
38
|
-
WAIT_FOR_READY_TRUE
|
39
|
-
};
|
40
|
-
|
41
|
-
struct RetryPolicy {
|
42
|
-
int max_attempts = 0;
|
43
|
-
grpc_millis initial_backoff = 0;
|
44
|
-
grpc_millis max_backoff = 0;
|
45
|
-
float backoff_multiplier = 0;
|
46
|
-
StatusCodeSet retryable_status_codes;
|
47
|
-
};
|
48
|
-
|
49
|
-
/// Creates a method_parameters object from \a json.
|
50
|
-
/// Intended for use with ServiceConfig::CreateMethodConfigTable().
|
51
|
-
static RefCountedPtr<ClientChannelMethodParams> CreateFromJson(
|
52
|
-
const grpc_json* json);
|
53
|
-
|
54
|
-
grpc_millis timeout() const { return timeout_; }
|
55
|
-
WaitForReady wait_for_ready() const { return wait_for_ready_; }
|
56
|
-
const RetryPolicy* retry_policy() const { return retry_policy_.get(); }
|
57
|
-
|
58
|
-
private:
|
59
|
-
// So New() can call our private ctor.
|
60
|
-
template <typename T, typename... Args>
|
61
|
-
friend T* grpc_core::New(Args&&... args);
|
62
|
-
|
63
|
-
// So Delete() can call our private dtor.
|
64
|
-
template <typename T>
|
65
|
-
friend void grpc_core::Delete(T*);
|
66
|
-
|
67
|
-
ClientChannelMethodParams() {}
|
68
|
-
virtual ~ClientChannelMethodParams() {}
|
69
|
-
|
70
|
-
grpc_millis timeout_ = 0;
|
71
|
-
WaitForReady wait_for_ready_ = WAIT_FOR_READY_UNSET;
|
72
|
-
UniquePtr<RetryPolicy> retry_policy_;
|
73
|
-
};
|
74
|
-
|
75
|
-
} // namespace internal
|
76
|
-
} // namespace grpc_core
|
77
|
-
|
78
|
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_METHOD_PARAMS_H */
|
@@ -1,75 +0,0 @@
|
|
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
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#include "src/core/tsi/alts/handshaker/alts_tsi_event.h"
|
22
|
-
|
23
|
-
#include <grpc/grpc.h>
|
24
|
-
#include <grpc/support/alloc.h>
|
25
|
-
#include <grpc/support/log.h>
|
26
|
-
|
27
|
-
#include "src/core/lib/slice/slice_internal.h"
|
28
|
-
|
29
|
-
tsi_result alts_tsi_event_create(alts_tsi_handshaker* handshaker,
|
30
|
-
tsi_handshaker_on_next_done_cb cb,
|
31
|
-
void* user_data,
|
32
|
-
grpc_alts_credentials_options* options,
|
33
|
-
grpc_slice target_name,
|
34
|
-
alts_tsi_event** event) {
|
35
|
-
if (event == nullptr || handshaker == nullptr || cb == nullptr) {
|
36
|
-
gpr_log(GPR_ERROR, "Invalid arguments to alts_tsi_event_create()");
|
37
|
-
return TSI_INVALID_ARGUMENT;
|
38
|
-
}
|
39
|
-
alts_tsi_event* e = static_cast<alts_tsi_event*>(gpr_zalloc(sizeof(*e)));
|
40
|
-
e->handshaker = handshaker;
|
41
|
-
e->cb = cb;
|
42
|
-
e->user_data = user_data;
|
43
|
-
e->options = grpc_alts_credentials_options_copy(options);
|
44
|
-
e->target_name = grpc_slice_copy(target_name);
|
45
|
-
grpc_metadata_array_init(&e->initial_metadata);
|
46
|
-
grpc_metadata_array_init(&e->trailing_metadata);
|
47
|
-
*event = e;
|
48
|
-
return TSI_OK;
|
49
|
-
}
|
50
|
-
|
51
|
-
void alts_tsi_event_dispatch_to_handshaker(alts_tsi_event* event, bool is_ok) {
|
52
|
-
if (event == nullptr) {
|
53
|
-
gpr_log(
|
54
|
-
GPR_ERROR,
|
55
|
-
"ALTS TSI event is nullptr in alts_tsi_event_dispatch_to_handshaker()");
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
alts_tsi_handshaker_handle_response(event->handshaker, event->recv_buffer,
|
59
|
-
event->status, &event->details, event->cb,
|
60
|
-
event->user_data, is_ok);
|
61
|
-
}
|
62
|
-
|
63
|
-
void alts_tsi_event_destroy(alts_tsi_event* event) {
|
64
|
-
if (event == nullptr) {
|
65
|
-
return;
|
66
|
-
}
|
67
|
-
grpc_byte_buffer_destroy(event->send_buffer);
|
68
|
-
grpc_byte_buffer_destroy(event->recv_buffer);
|
69
|
-
grpc_metadata_array_destroy(&event->initial_metadata);
|
70
|
-
grpc_metadata_array_destroy(&event->trailing_metadata);
|
71
|
-
grpc_slice_unref_internal(event->details);
|
72
|
-
grpc_slice_unref_internal(event->target_name);
|
73
|
-
grpc_alts_credentials_options_destroy(event->options);
|
74
|
-
gpr_free(event);
|
75
|
-
}
|
@@ -1,93 +0,0 @@
|
|
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_TSI_ALTS_HANDSHAKER_ALTS_TSI_EVENT_H
|
20
|
-
#define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_EVENT_H
|
21
|
-
|
22
|
-
#include <grpc/support/port_platform.h>
|
23
|
-
|
24
|
-
#include <grpc/byte_buffer.h>
|
25
|
-
#include <grpc/byte_buffer_reader.h>
|
26
|
-
|
27
|
-
#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h"
|
28
|
-
#include "src/core/tsi/transport_security_interface.h"
|
29
|
-
|
30
|
-
/**
|
31
|
-
* A ALTS TSI event interface. In asynchronous implementation of
|
32
|
-
* tsi_handshaker_next(), the function will exit after scheduling a handshaker
|
33
|
-
* request to ALTS handshaker service without waiting for response to return.
|
34
|
-
* The event is used to link the scheduled handshaker request with the
|
35
|
-
* corresponding response so that enough context information can be inferred
|
36
|
-
* from it to handle the response. All APIs in the header are thread-compatible.
|
37
|
-
*/
|
38
|
-
|
39
|
-
/**
|
40
|
-
* Main struct for ALTS TSI event. It retains ownership on send_buffer and
|
41
|
-
* recv_buffer, but not on handshaker.
|
42
|
-
*/
|
43
|
-
typedef struct alts_tsi_event {
|
44
|
-
alts_tsi_handshaker* handshaker;
|
45
|
-
grpc_byte_buffer* send_buffer;
|
46
|
-
grpc_byte_buffer* recv_buffer;
|
47
|
-
grpc_status_code status;
|
48
|
-
grpc_slice details;
|
49
|
-
grpc_metadata_array initial_metadata;
|
50
|
-
grpc_metadata_array trailing_metadata;
|
51
|
-
tsi_handshaker_on_next_done_cb cb;
|
52
|
-
void* user_data;
|
53
|
-
grpc_alts_credentials_options* options;
|
54
|
-
grpc_slice target_name;
|
55
|
-
} alts_tsi_event;
|
56
|
-
|
57
|
-
/**
|
58
|
-
* This method creates a ALTS TSI event.
|
59
|
-
*
|
60
|
-
* - handshaker: ALTS TSI handshaker instance associated with the event to be
|
61
|
-
* created. The created event does not own the handshaker instance.
|
62
|
-
* - cb: callback function to be called when handling data received from ALTS
|
63
|
-
* handshaker service.
|
64
|
-
* - user_data: argument to callback function.
|
65
|
-
* - options: ALTS credentials options.
|
66
|
-
* - target_name: name of endpoint used for secure naming check.
|
67
|
-
* - event: address of ALTS TSI event instance to be returned from the method.
|
68
|
-
*
|
69
|
-
* It returns TSI_OK on success and an error status code on failure.
|
70
|
-
*/
|
71
|
-
tsi_result alts_tsi_event_create(alts_tsi_handshaker* handshaker,
|
72
|
-
tsi_handshaker_on_next_done_cb cb,
|
73
|
-
void* user_data,
|
74
|
-
grpc_alts_credentials_options* options,
|
75
|
-
grpc_slice target_name,
|
76
|
-
alts_tsi_event** event);
|
77
|
-
|
78
|
-
/**
|
79
|
-
* This method dispatches a ALTS TSI event received from the handshaker service,
|
80
|
-
* and a boolean flag indicating if the event is valid to read to ALTS TSI
|
81
|
-
* handshaker to process. It is called by TSI thread.
|
82
|
-
*
|
83
|
-
* - event: ALTS TSI event instance.
|
84
|
-
* - is_ok: a boolean value indicating if the event is valid to read.
|
85
|
-
*/
|
86
|
-
void alts_tsi_event_dispatch_to_handshaker(alts_tsi_event* event, bool is_ok);
|
87
|
-
|
88
|
-
/**
|
89
|
-
* This method destroys the ALTS TSI event.
|
90
|
-
*/
|
91
|
-
void alts_tsi_event_destroy(alts_tsi_event* event);
|
92
|
-
|
93
|
-
#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_EVENT_H */
|
@@ -1,65 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2017 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
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#include "src/core/tsi/alts_transport_security.h"
|
22
|
-
|
23
|
-
#include <string.h>
|
24
|
-
|
25
|
-
static alts_shared_resource g_alts_resource;
|
26
|
-
|
27
|
-
alts_shared_resource* alts_get_shared_resource(void) {
|
28
|
-
return &g_alts_resource;
|
29
|
-
}
|
30
|
-
|
31
|
-
static void grpc_tsi_alts_wait_for_cq_drain() {
|
32
|
-
gpr_mu_lock(&g_alts_resource.mu);
|
33
|
-
while (!g_alts_resource.is_cq_drained) {
|
34
|
-
gpr_cv_wait(&g_alts_resource.cv, &g_alts_resource.mu,
|
35
|
-
gpr_inf_future(GPR_CLOCK_REALTIME));
|
36
|
-
}
|
37
|
-
gpr_mu_unlock(&g_alts_resource.mu);
|
38
|
-
}
|
39
|
-
|
40
|
-
void grpc_tsi_alts_signal_for_cq_destroy() {
|
41
|
-
gpr_mu_lock(&g_alts_resource.mu);
|
42
|
-
g_alts_resource.is_cq_drained = true;
|
43
|
-
gpr_cv_signal(&g_alts_resource.cv);
|
44
|
-
gpr_mu_unlock(&g_alts_resource.mu);
|
45
|
-
}
|
46
|
-
|
47
|
-
void grpc_tsi_alts_init() {
|
48
|
-
g_alts_resource.channel = nullptr;
|
49
|
-
g_alts_resource.cq = nullptr;
|
50
|
-
g_alts_resource.is_cq_drained = false;
|
51
|
-
gpr_mu_init(&g_alts_resource.mu);
|
52
|
-
gpr_cv_init(&g_alts_resource.cv);
|
53
|
-
}
|
54
|
-
|
55
|
-
void grpc_tsi_alts_shutdown() {
|
56
|
-
if (g_alts_resource.cq != nullptr) {
|
57
|
-
grpc_completion_queue_shutdown(g_alts_resource.cq);
|
58
|
-
grpc_tsi_alts_wait_for_cq_drain();
|
59
|
-
grpc_completion_queue_destroy(g_alts_resource.cq);
|
60
|
-
grpc_channel_destroy(g_alts_resource.channel);
|
61
|
-
g_alts_resource.thread.Join();
|
62
|
-
}
|
63
|
-
gpr_cv_destroy(&g_alts_resource.cv);
|
64
|
-
gpr_mu_destroy(&g_alts_resource.mu);
|
65
|
-
}
|