grpc 1.53.0 → 1.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +4 -2
- data/include/grpc/impl/grpc_types.h +11 -2
- data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +12 -8
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +5 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +33 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +118 -222
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +295 -113
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +466 -273
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +7 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +14 -12
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +9 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +6 -0
- data/src/core/lib/backoff/random_early_detection.cc +31 -0
- data/src/core/lib/backoff/random_early_detection.h +59 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
- data/src/core/lib/surface/validate_metadata.cc +43 -42
- data/src/core/lib/surface/validate_metadata.h +9 -0
- data/src/core/lib/transport/metadata_batch.cc +4 -4
- data/src/core/lib/transport/metadata_batch.h +153 -15
- data/src/core/lib/transport/parsed_metadata.h +19 -9
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +5 -3
@@ -49,6 +49,50 @@
|
|
49
49
|
|
50
50
|
namespace grpc_core {
|
51
51
|
|
52
|
+
///////////////////////////////////////////////////////////////////////////////
|
53
|
+
// Compression traits.
|
54
|
+
//
|
55
|
+
// Each metadata trait exposes exactly one compression trait.
|
56
|
+
// This type directs how transports might choose to compress the metadata.
|
57
|
+
// Adding a value here typically involves editing all transports to support the
|
58
|
+
// trait, and so should not be done lightly.
|
59
|
+
|
60
|
+
// No compression.
|
61
|
+
struct NoCompressionCompressor {};
|
62
|
+
|
63
|
+
// Expect a single value for this metadata key, but we don't know apriori its
|
64
|
+
// value.
|
65
|
+
// It's ok if it changes over time, but it should be mostly stable.
|
66
|
+
// This is used for things like user-agent, which is expected to be the same
|
67
|
+
// for all requests.
|
68
|
+
struct StableValueCompressor {};
|
69
|
+
|
70
|
+
// Expect a single value for this metadata key, and we know apriori its value.
|
71
|
+
template <typename T, T value>
|
72
|
+
struct KnownValueCompressor {};
|
73
|
+
|
74
|
+
// Values are uncompressible, but expect the key to be in most requests and try
|
75
|
+
// and compress that.
|
76
|
+
struct FrequentKeyWithNoValueCompressionCompressor {};
|
77
|
+
|
78
|
+
// Expect a small set of values for this metadata key.
|
79
|
+
struct SmallSetOfValuesCompressor {};
|
80
|
+
|
81
|
+
// Expect integral values up to N for this metadata key.
|
82
|
+
template <size_t N>
|
83
|
+
struct SmallIntegralValuesCompressor {};
|
84
|
+
|
85
|
+
// Specialty compressor for grpc-timeout metadata.
|
86
|
+
struct TimeoutCompressor {};
|
87
|
+
|
88
|
+
// Specialty compressors for HTTP/2 psuedo headers.
|
89
|
+
struct HttpSchemeCompressor {};
|
90
|
+
struct HttpMethodCompressor {};
|
91
|
+
struct HttpStatusCompressor {};
|
92
|
+
|
93
|
+
///////////////////////////////////////////////////////////////////////////////
|
94
|
+
// Metadata traits
|
95
|
+
|
52
96
|
// Given a metadata key and a value, return the encoded size.
|
53
97
|
// Defaults to calling the key's Encode() method and then calculating the size
|
54
98
|
// of that, but can be overridden for specific keys if there's a better way of
|
@@ -70,11 +114,13 @@ struct GrpcTimeoutMetadata {
|
|
70
114
|
static constexpr bool kRepeatable = false;
|
71
115
|
using ValueType = Timestamp;
|
72
116
|
using MementoType = Duration;
|
117
|
+
using CompressionTraits = TimeoutCompressor;
|
73
118
|
static absl::string_view key() { return "grpc-timeout"; }
|
74
119
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn on_error);
|
75
120
|
static ValueType MementoToValue(MementoType timeout);
|
76
121
|
static Slice Encode(ValueType x);
|
77
|
-
static std::string DisplayValue(
|
122
|
+
static std::string DisplayValue(ValueType x) { return x.ToString(); }
|
123
|
+
static std::string DisplayMemento(MementoType x) { return x.ToString(); }
|
78
124
|
};
|
79
125
|
|
80
126
|
// TE metadata trait.
|
@@ -88,6 +134,7 @@ struct TeMetadata {
|
|
88
134
|
kInvalid,
|
89
135
|
};
|
90
136
|
using MementoType = ValueType;
|
137
|
+
using CompressionTraits = KnownValueCompressor<ValueType, kTrailers>;
|
91
138
|
static absl::string_view key() { return "te"; }
|
92
139
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn on_error);
|
93
140
|
static ValueType MementoToValue(MementoType te) { return te; }
|
@@ -95,7 +142,8 @@ struct TeMetadata {
|
|
95
142
|
GPR_ASSERT(x == kTrailers);
|
96
143
|
return StaticSlice::FromStaticString("trailers");
|
97
144
|
}
|
98
|
-
static const char* DisplayValue(
|
145
|
+
static const char* DisplayValue(ValueType te);
|
146
|
+
static const char* DisplayMemento(MementoType te) { return DisplayValue(te); }
|
99
147
|
};
|
100
148
|
|
101
149
|
inline size_t EncodedSizeOfKey(TeMetadata, TeMetadata::ValueType x) {
|
@@ -114,6 +162,7 @@ struct ContentTypeMetadata {
|
|
114
162
|
kInvalid,
|
115
163
|
};
|
116
164
|
using MementoType = ValueType;
|
165
|
+
using CompressionTraits = KnownValueCompressor<ValueType, kApplicationGrpc>;
|
117
166
|
static absl::string_view key() { return "content-type"; }
|
118
167
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn on_error);
|
119
168
|
static ValueType MementoToValue(MementoType content_type) {
|
@@ -121,7 +170,10 @@ struct ContentTypeMetadata {
|
|
121
170
|
}
|
122
171
|
|
123
172
|
static StaticSlice Encode(ValueType x);
|
124
|
-
static const char* DisplayValue(
|
173
|
+
static const char* DisplayValue(ValueType content_type);
|
174
|
+
static const char* DisplayMemento(ValueType content_type) {
|
175
|
+
return DisplayValue(content_type);
|
176
|
+
}
|
125
177
|
};
|
126
178
|
|
127
179
|
// scheme metadata trait.
|
@@ -133,6 +185,7 @@ struct HttpSchemeMetadata {
|
|
133
185
|
kInvalid,
|
134
186
|
};
|
135
187
|
using MementoType = ValueType;
|
188
|
+
using CompressionTraits = HttpSchemeCompressor;
|
136
189
|
static absl::string_view key() { return ":scheme"; }
|
137
190
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn on_error) {
|
138
191
|
return Parse(value.as_string_view(), on_error);
|
@@ -143,7 +196,10 @@ struct HttpSchemeMetadata {
|
|
143
196
|
return content_type;
|
144
197
|
}
|
145
198
|
static StaticSlice Encode(ValueType x);
|
146
|
-
static const char* DisplayValue(
|
199
|
+
static const char* DisplayValue(ValueType content_type);
|
200
|
+
static const char* DisplayMemento(MementoType content_type) {
|
201
|
+
return DisplayValue(content_type);
|
202
|
+
}
|
147
203
|
};
|
148
204
|
|
149
205
|
size_t EncodedSizeOfKey(HttpSchemeMetadata, HttpSchemeMetadata::ValueType x);
|
@@ -158,13 +214,17 @@ struct HttpMethodMetadata {
|
|
158
214
|
kInvalid,
|
159
215
|
};
|
160
216
|
using MementoType = ValueType;
|
217
|
+
using CompressionTraits = HttpMethodCompressor;
|
161
218
|
static absl::string_view key() { return ":method"; }
|
162
219
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn on_error);
|
163
220
|
static ValueType MementoToValue(MementoType content_type) {
|
164
221
|
return content_type;
|
165
222
|
}
|
166
223
|
static StaticSlice Encode(ValueType x);
|
167
|
-
static const char* DisplayValue(
|
224
|
+
static const char* DisplayValue(ValueType content_type);
|
225
|
+
static const char* DisplayMemento(MementoType content_type) {
|
226
|
+
return DisplayValue(content_type);
|
227
|
+
}
|
168
228
|
};
|
169
229
|
|
170
230
|
// Base type for metadata pertaining to a single compression algorithm
|
@@ -178,24 +238,28 @@ struct CompressionAlgorithmBasedMetadata {
|
|
178
238
|
GPR_ASSERT(x != GRPC_COMPRESS_ALGORITHMS_COUNT);
|
179
239
|
return Slice::FromStaticString(CompressionAlgorithmAsString(x));
|
180
240
|
}
|
181
|
-
static const char* DisplayValue(
|
241
|
+
static const char* DisplayValue(ValueType x) {
|
182
242
|
if (const char* p = CompressionAlgorithmAsString(x)) {
|
183
243
|
return p;
|
184
244
|
} else {
|
185
245
|
return "<discarded-invalid-value>";
|
186
246
|
}
|
187
247
|
}
|
248
|
+
static const char* DisplayMemento(MementoType x) { return DisplayValue(x); }
|
188
249
|
};
|
189
250
|
|
190
251
|
// grpc-encoding metadata trait.
|
191
252
|
struct GrpcEncodingMetadata : public CompressionAlgorithmBasedMetadata {
|
192
253
|
static constexpr bool kRepeatable = false;
|
254
|
+
using CompressionTraits =
|
255
|
+
SmallIntegralValuesCompressor<GRPC_COMPRESS_ALGORITHMS_COUNT>;
|
193
256
|
static absl::string_view key() { return "grpc-encoding"; }
|
194
257
|
};
|
195
258
|
|
196
259
|
// grpc-internal-encoding-request metadata trait.
|
197
260
|
struct GrpcInternalEncodingRequest : public CompressionAlgorithmBasedMetadata {
|
198
261
|
static constexpr bool kRepeatable = false;
|
262
|
+
using CompressionTraits = NoCompressionCompressor;
|
199
263
|
static absl::string_view key() { return "grpc-internal-encoding-request"; }
|
200
264
|
};
|
201
265
|
|
@@ -205,12 +269,16 @@ struct GrpcAcceptEncodingMetadata {
|
|
205
269
|
static absl::string_view key() { return "grpc-accept-encoding"; }
|
206
270
|
using ValueType = CompressionAlgorithmSet;
|
207
271
|
using MementoType = ValueType;
|
272
|
+
using CompressionTraits = StableValueCompressor;
|
208
273
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn) {
|
209
274
|
return CompressionAlgorithmSet::FromString(value.as_string_view());
|
210
275
|
}
|
211
276
|
static ValueType MementoToValue(MementoType x) { return x; }
|
212
277
|
static Slice Encode(ValueType x) { return x.ToSlice(); }
|
213
|
-
static absl::string_view DisplayValue(
|
278
|
+
static absl::string_view DisplayValue(ValueType x) { return x.ToString(); }
|
279
|
+
static absl::string_view DisplayMemento(MementoType x) {
|
280
|
+
return DisplayValue(x);
|
281
|
+
}
|
214
282
|
};
|
215
283
|
|
216
284
|
struct SimpleSliceBasedMetadata {
|
@@ -221,7 +289,10 @@ struct SimpleSliceBasedMetadata {
|
|
221
289
|
}
|
222
290
|
static ValueType MementoToValue(MementoType value) { return value; }
|
223
291
|
static Slice Encode(const ValueType& x) { return x.Ref(); }
|
224
|
-
static absl::string_view DisplayValue(const
|
292
|
+
static absl::string_view DisplayValue(const ValueType& value) {
|
293
|
+
return value.as_string_view();
|
294
|
+
}
|
295
|
+
static absl::string_view DisplayMemento(const MementoType& value) {
|
225
296
|
return value.as_string_view();
|
226
297
|
}
|
227
298
|
};
|
@@ -229,54 +300,63 @@ struct SimpleSliceBasedMetadata {
|
|
229
300
|
// user-agent metadata trait.
|
230
301
|
struct UserAgentMetadata : public SimpleSliceBasedMetadata {
|
231
302
|
static constexpr bool kRepeatable = false;
|
303
|
+
using CompressionTraits = StableValueCompressor;
|
232
304
|
static absl::string_view key() { return "user-agent"; }
|
233
305
|
};
|
234
306
|
|
235
307
|
// grpc-message metadata trait.
|
236
308
|
struct GrpcMessageMetadata : public SimpleSliceBasedMetadata {
|
237
309
|
static constexpr bool kRepeatable = false;
|
310
|
+
using CompressionTraits = NoCompressionCompressor;
|
238
311
|
static absl::string_view key() { return "grpc-message"; }
|
239
312
|
};
|
240
313
|
|
241
314
|
// host metadata trait.
|
242
315
|
struct HostMetadata : public SimpleSliceBasedMetadata {
|
243
316
|
static constexpr bool kRepeatable = false;
|
317
|
+
using CompressionTraits = NoCompressionCompressor;
|
244
318
|
static absl::string_view key() { return "host"; }
|
245
319
|
};
|
246
320
|
|
247
321
|
// endpoint-load-metrics-bin metadata trait.
|
248
322
|
struct EndpointLoadMetricsBinMetadata : public SimpleSliceBasedMetadata {
|
249
323
|
static constexpr bool kRepeatable = false;
|
324
|
+
using CompressionTraits = NoCompressionCompressor;
|
250
325
|
static absl::string_view key() { return "endpoint-load-metrics-bin"; }
|
251
326
|
};
|
252
327
|
|
253
328
|
// grpc-server-stats-bin metadata trait.
|
254
329
|
struct GrpcServerStatsBinMetadata : public SimpleSliceBasedMetadata {
|
255
330
|
static constexpr bool kRepeatable = false;
|
331
|
+
using CompressionTraits = NoCompressionCompressor;
|
256
332
|
static absl::string_view key() { return "grpc-server-stats-bin"; }
|
257
333
|
};
|
258
334
|
|
259
335
|
// grpc-trace-bin metadata trait.
|
260
336
|
struct GrpcTraceBinMetadata : public SimpleSliceBasedMetadata {
|
261
337
|
static constexpr bool kRepeatable = false;
|
338
|
+
using CompressionTraits = FrequentKeyWithNoValueCompressionCompressor;
|
262
339
|
static absl::string_view key() { return "grpc-trace-bin"; }
|
263
340
|
};
|
264
341
|
|
265
342
|
// grpc-tags-bin metadata trait.
|
266
343
|
struct GrpcTagsBinMetadata : public SimpleSliceBasedMetadata {
|
267
344
|
static constexpr bool kRepeatable = false;
|
345
|
+
using CompressionTraits = FrequentKeyWithNoValueCompressionCompressor;
|
268
346
|
static absl::string_view key() { return "grpc-tags-bin"; }
|
269
347
|
};
|
270
348
|
|
271
349
|
// :authority metadata trait.
|
272
350
|
struct HttpAuthorityMetadata : public SimpleSliceBasedMetadata {
|
273
351
|
static constexpr bool kRepeatable = false;
|
352
|
+
using CompressionTraits = SmallSetOfValuesCompressor;
|
274
353
|
static absl::string_view key() { return ":authority"; }
|
275
354
|
};
|
276
355
|
|
277
356
|
// :path metadata trait.
|
278
357
|
struct HttpPathMetadata : public SimpleSliceBasedMetadata {
|
279
358
|
static constexpr bool kRepeatable = false;
|
359
|
+
using CompressionTraits = SmallSetOfValuesCompressor;
|
280
360
|
static absl::string_view key() { return ":path"; }
|
281
361
|
};
|
282
362
|
|
@@ -289,7 +369,8 @@ struct SimpleIntBasedMetadataBase {
|
|
289
369
|
using MementoType = Int;
|
290
370
|
static ValueType MementoToValue(MementoType value) { return value; }
|
291
371
|
static Slice Encode(ValueType x) { return Slice::FromInt64(x); }
|
292
|
-
static Int DisplayValue(
|
372
|
+
static Int DisplayValue(ValueType x) { return x; }
|
373
|
+
static Int DisplayMemento(MementoType x) { return x; }
|
293
374
|
};
|
294
375
|
|
295
376
|
template <typename Int, Int kInvalidValue>
|
@@ -309,6 +390,7 @@ struct SimpleIntBasedMetadata : public SimpleIntBasedMetadataBase<Int> {
|
|
309
390
|
struct GrpcStatusMetadata
|
310
391
|
: public SimpleIntBasedMetadata<grpc_status_code, GRPC_STATUS_UNKNOWN> {
|
311
392
|
static constexpr bool kRepeatable = false;
|
393
|
+
using CompressionTraits = SmallIntegralValuesCompressor<16>;
|
312
394
|
static absl::string_view key() { return "grpc-status"; }
|
313
395
|
};
|
314
396
|
|
@@ -316,6 +398,7 @@ struct GrpcStatusMetadata
|
|
316
398
|
struct GrpcPreviousRpcAttemptsMetadata
|
317
399
|
: public SimpleIntBasedMetadata<uint32_t, 0> {
|
318
400
|
static constexpr bool kRepeatable = false;
|
401
|
+
using CompressionTraits = NoCompressionCompressor;
|
319
402
|
static absl::string_view key() { return "grpc-previous-rpc-attempts"; }
|
320
403
|
};
|
321
404
|
|
@@ -325,9 +408,11 @@ struct GrpcRetryPushbackMsMetadata {
|
|
325
408
|
static absl::string_view key() { return "grpc-retry-pushback-ms"; }
|
326
409
|
using ValueType = Duration;
|
327
410
|
using MementoType = Duration;
|
411
|
+
using CompressionTraits = NoCompressionCompressor;
|
328
412
|
static ValueType MementoToValue(MementoType x) { return x; }
|
329
413
|
static Slice Encode(Duration x) { return Slice::FromInt64(x.millis()); }
|
330
414
|
static int64_t DisplayValue(Duration x) { return x.millis(); }
|
415
|
+
static int64_t DisplayMemento(Duration x) { return DisplayValue(x); }
|
331
416
|
static Duration ParseMemento(Slice value, MetadataParseErrorFn on_error);
|
332
417
|
};
|
333
418
|
|
@@ -335,6 +420,7 @@ struct GrpcRetryPushbackMsMetadata {
|
|
335
420
|
// TODO(ctiller): consider moving to uint16_t
|
336
421
|
struct HttpStatusMetadata : public SimpleIntBasedMetadata<uint32_t, 0> {
|
337
422
|
static constexpr bool kRepeatable = false;
|
423
|
+
using CompressionTraits = HttpStatusCompressor;
|
338
424
|
static absl::string_view key() { return ":status"; }
|
339
425
|
};
|
340
426
|
|
@@ -347,9 +433,13 @@ struct GrpcLbClientStatsMetadata {
|
|
347
433
|
static absl::string_view key() { return "grpclb_client_stats"; }
|
348
434
|
using ValueType = GrpcLbClientStats*;
|
349
435
|
using MementoType = ValueType;
|
436
|
+
using CompressionTraits = NoCompressionCompressor;
|
350
437
|
static ValueType MementoToValue(MementoType value) { return value; }
|
351
438
|
static Slice Encode(ValueType) { abort(); }
|
352
|
-
static const char* DisplayValue(
|
439
|
+
static const char* DisplayValue(ValueType) { return "<internal-lb-stats>"; }
|
440
|
+
static const char* DisplayMemento(MementoType) {
|
441
|
+
return "<internal-lb-stats>";
|
442
|
+
}
|
353
443
|
static MementoType ParseMemento(Slice, MetadataParseErrorFn) {
|
354
444
|
return nullptr;
|
355
445
|
}
|
@@ -363,6 +453,7 @@ inline size_t EncodedSizeOfKey(GrpcLbClientStatsMetadata,
|
|
363
453
|
// lb-token metadata
|
364
454
|
struct LbTokenMetadata : public SimpleSliceBasedMetadata {
|
365
455
|
static constexpr bool kRepeatable = false;
|
456
|
+
using CompressionTraits = NoCompressionCompressor;
|
366
457
|
static absl::string_view key() { return "lb-token"; }
|
367
458
|
};
|
368
459
|
|
@@ -375,9 +466,11 @@ struct LbCostBinMetadata {
|
|
375
466
|
std::string name;
|
376
467
|
};
|
377
468
|
using MementoType = ValueType;
|
469
|
+
using CompressionTraits = NoCompressionCompressor;
|
378
470
|
static ValueType MementoToValue(MementoType value) { return value; }
|
379
471
|
static Slice Encode(const ValueType& x);
|
380
|
-
static std::string DisplayValue(
|
472
|
+
static std::string DisplayValue(ValueType x);
|
473
|
+
static std::string DisplayMemento(MementoType x) { return DisplayValue(x); }
|
381
474
|
static MementoType ParseMemento(Slice value, MetadataParseErrorFn on_error);
|
382
475
|
};
|
383
476
|
|
@@ -542,8 +635,9 @@ class ParseHelper {
|
|
542
635
|
|
543
636
|
GPR_ATTRIBUTE_NOINLINE ParsedMetadata<Container> NotFound(
|
544
637
|
absl::string_view key) {
|
545
|
-
return ParsedMetadata<Container>(
|
546
|
-
|
638
|
+
return ParsedMetadata<Container>(
|
639
|
+
typename ParsedMetadata<Container>::FromSlicePair{},
|
640
|
+
Slice::FromCopiedString(key), std::move(value_), transport_size_);
|
547
641
|
}
|
548
642
|
|
549
643
|
private:
|
@@ -698,6 +792,11 @@ struct AdaptDisplayValueToLog<Slice> {
|
|
698
792
|
}
|
699
793
|
};
|
700
794
|
|
795
|
+
template <>
|
796
|
+
struct AdaptDisplayValueToLog<const char*> {
|
797
|
+
static std::string ToString(const char* value) { return std::string(value); }
|
798
|
+
};
|
799
|
+
|
701
800
|
template <>
|
702
801
|
struct AdaptDisplayValueToLog<StaticSlice> {
|
703
802
|
static absl::string_view ToString(StaticSlice value) {
|
@@ -739,7 +838,7 @@ struct Value<Which, absl::enable_if_t<Which::kRepeatable == false &&
|
|
739
838
|
return EncodeTo(encoder);
|
740
839
|
}
|
741
840
|
void LogTo(LogFn log_fn) const {
|
742
|
-
LogKeyValueTo(Which::key(), value, Which::
|
841
|
+
LogKeyValueTo(Which::key(), value, Which::DisplayValue, log_fn);
|
743
842
|
}
|
744
843
|
using StorageType = typename Which::ValueType;
|
745
844
|
GPR_NO_UNIQUE_ADDRESS StorageType value;
|
@@ -954,6 +1053,35 @@ class UnknownMap {
|
|
954
1053
|
ChunkedVector<std::pair<Slice, Slice>, 10> unknown_;
|
955
1054
|
};
|
956
1055
|
|
1056
|
+
// Given a factory template Factory, construct a type that derives from
|
1057
|
+
// Factory<MetadataTrait, MetadataTrait::CompressionTraits> for all
|
1058
|
+
// MetadataTraits. Useful for transports in defining the stateful parts of their
|
1059
|
+
// compression algorithm.
|
1060
|
+
template <template <typename, typename> class Factory,
|
1061
|
+
typename... MetadataTraits>
|
1062
|
+
struct StatefulCompressor;
|
1063
|
+
|
1064
|
+
template <template <typename, typename> class Factory, typename MetadataTrait,
|
1065
|
+
bool kEncodable = IsEncodableTrait<MetadataTrait>::value>
|
1066
|
+
struct SpecificStatefulCompressor;
|
1067
|
+
|
1068
|
+
template <template <typename, typename> class Factory, typename MetadataTrait>
|
1069
|
+
struct SpecificStatefulCompressor<Factory, MetadataTrait, true>
|
1070
|
+
: public Factory<MetadataTrait, typename MetadataTrait::CompressionTraits> {
|
1071
|
+
};
|
1072
|
+
|
1073
|
+
template <template <typename, typename> class Factory, typename MetadataTrait>
|
1074
|
+
struct SpecificStatefulCompressor<Factory, MetadataTrait, false> {};
|
1075
|
+
|
1076
|
+
template <template <typename, typename> class Factory, typename MetadataTrait,
|
1077
|
+
typename... MetadataTraits>
|
1078
|
+
struct StatefulCompressor<Factory, MetadataTrait, MetadataTraits...>
|
1079
|
+
: public SpecificStatefulCompressor<Factory, MetadataTrait>,
|
1080
|
+
public StatefulCompressor<Factory, MetadataTraits...> {};
|
1081
|
+
|
1082
|
+
template <template <typename, typename> class Factory>
|
1083
|
+
struct StatefulCompressor<Factory> {};
|
1084
|
+
|
957
1085
|
} // namespace metadata_detail
|
958
1086
|
|
959
1087
|
// Helper function for encoders
|
@@ -1025,7 +1153,8 @@ MetadataValueAsSlice(typename Which::ValueType value) {
|
|
1025
1153
|
// // Convert a value to something that can be passed to StrCat and
|
1026
1154
|
// displayed
|
1027
1155
|
// // for debugging
|
1028
|
-
// static SomeStrCatableType DisplayValue(
|
1156
|
+
// static SomeStrCatableType DisplayValue(ValueType value) { ... }
|
1157
|
+
// static SomeStrCatableType DisplayMemento(MementoType value) { ... }
|
1029
1158
|
// };
|
1030
1159
|
//
|
1031
1160
|
// Non-encodable traits are determined by missing the key() method, and have
|
@@ -1071,6 +1200,15 @@ class MetadataMap {
|
|
1071
1200
|
explicit MetadataMap(Arena* arena);
|
1072
1201
|
~MetadataMap();
|
1073
1202
|
|
1203
|
+
// Given a compressor factory - template taking <MetadataTrait,
|
1204
|
+
// CompressionTrait>, StatefulCompressor<Factory> provides a type
|
1205
|
+
// derived from all Encodable traits in this MetadataMap.
|
1206
|
+
// This can be used by transports to delegate compression to the appropriate
|
1207
|
+
// compression algorithm.
|
1208
|
+
template <template <typename, typename> class Factory>
|
1209
|
+
using StatefulCompressor =
|
1210
|
+
metadata_detail::StatefulCompressor<Factory, Traits...>;
|
1211
|
+
|
1074
1212
|
MetadataMap(const MetadataMap&) = delete;
|
1075
1213
|
MetadataMap& operator=(const MetadataMap&) = delete;
|
1076
1214
|
MetadataMap(MetadataMap&&) noexcept;
|
@@ -26,6 +26,7 @@
|
|
26
26
|
|
27
27
|
#include "absl/functional/function_ref.h"
|
28
28
|
#include "absl/meta/type_traits.h"
|
29
|
+
#include "absl/strings/escaping.h"
|
29
30
|
#include "absl/strings/match.h"
|
30
31
|
#include "absl/strings/str_cat.h"
|
31
32
|
#include "absl/strings/string_view.h"
|
@@ -151,9 +152,14 @@ class ParsedMetadata {
|
|
151
152
|
value_.slice = value.TakeCSlice();
|
152
153
|
}
|
153
154
|
// Construct metadata from a string key, slice value pair.
|
154
|
-
|
155
|
+
// FromSlicePair() is used to adjust the overload set so that we don't
|
156
|
+
// inadvertently match against any of the previous overloads.
|
157
|
+
// TODO(ctiller): re-evaluate the overload functions here so and maybe
|
158
|
+
// introduce some factory functions?
|
159
|
+
struct FromSlicePair {};
|
160
|
+
ParsedMetadata(FromSlicePair, Slice key, Slice value, uint32_t transport_size)
|
155
161
|
: vtable_(ParsedMetadata::KeyValueVTable(key.as_string_view())),
|
156
|
-
transport_size_(
|
162
|
+
transport_size_(transport_size) {
|
157
163
|
value_.pointer =
|
158
164
|
new std::pair<Slice, Slice>(std::move(key), std::move(value));
|
159
165
|
}
|
@@ -187,14 +193,13 @@ class ParsedMetadata {
|
|
187
193
|
// HTTP2 defined storage size of this metadatum.
|
188
194
|
uint32_t transport_size() const { return transport_size_; }
|
189
195
|
// Create a new parsed metadata with the same key but a different value.
|
190
|
-
ParsedMetadata WithNewValue(Slice value,
|
196
|
+
ParsedMetadata WithNewValue(Slice value, uint32_t value_wire_size,
|
191
197
|
MetadataParseErrorFn on_error) const {
|
192
198
|
ParsedMetadata result;
|
193
199
|
result.vtable_ = vtable_;
|
194
200
|
result.value_ = value_;
|
195
201
|
result.transport_size_ =
|
196
|
-
TransportSize(static_cast<uint32_t>(key().length()),
|
197
|
-
static_cast<uint32_t>(value.length()));
|
202
|
+
TransportSize(static_cast<uint32_t>(key().length()), value_wire_size);
|
198
203
|
vtable_->with_new_value(&value, on_error, &result);
|
199
204
|
return result;
|
200
205
|
}
|
@@ -300,7 +305,7 @@ ParsedMetadata<MetadataContainer>::TrivialTraitVTable() {
|
|
300
305
|
return metadata_detail::MakeDebugStringPipeline(
|
301
306
|
Which::key(), value,
|
302
307
|
metadata_detail::FieldFromTrivial<typename Which::MementoType>,
|
303
|
-
Which::
|
308
|
+
Which::DisplayMemento);
|
304
309
|
},
|
305
310
|
// key
|
306
311
|
Which::key(),
|
@@ -334,7 +339,7 @@ ParsedMetadata<MetadataContainer>::NonTrivialTraitVTable() {
|
|
334
339
|
return metadata_detail::MakeDebugStringPipeline(
|
335
340
|
Which::key(), value,
|
336
341
|
metadata_detail::FieldFromPointer<typename Which::MementoType>,
|
337
|
-
Which::
|
342
|
+
Which::DisplayMemento);
|
338
343
|
},
|
339
344
|
// key
|
340
345
|
Which::key(),
|
@@ -362,7 +367,7 @@ ParsedMetadata<MetadataContainer>::SliceTraitVTable() {
|
|
362
367
|
[](const Buffer& value) {
|
363
368
|
return metadata_detail::MakeDebugStringPipeline(
|
364
369
|
Which::key(), value, metadata_detail::SliceFromBuffer,
|
365
|
-
Which::
|
370
|
+
Which::DisplayMemento);
|
366
371
|
},
|
367
372
|
// key
|
368
373
|
Which::key(),
|
@@ -395,12 +400,17 @@ ParsedMetadata<MetadataContainer>::KeyValueVTable(absl::string_view key) {
|
|
395
400
|
return absl::StrCat(p->first.as_string_view(), ": ",
|
396
401
|
p->second.as_string_view());
|
397
402
|
};
|
403
|
+
static const auto binary_debug_string = [](const Buffer& value) {
|
404
|
+
auto* p = static_cast<KV*>(value.pointer);
|
405
|
+
return absl::StrCat(p->first.as_string_view(), ": \"",
|
406
|
+
absl::CEscape(p->second.as_string_view()), "\"");
|
407
|
+
};
|
398
408
|
static const auto key_fn = [](const Buffer& value) {
|
399
409
|
return static_cast<KV*>(value.pointer)->first.as_string_view();
|
400
410
|
};
|
401
411
|
static const VTable vtable[2] = {
|
402
412
|
{false, destroy, set, with_new_value, debug_string, "", key_fn},
|
403
|
-
{true, destroy, set, with_new_value,
|
413
|
+
{true, destroy, set, with_new_value, binary_debug_string, "", key_fn},
|
404
414
|
};
|
405
415
|
return &vtable[absl::EndsWith(key, "-bin")];
|
406
416
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.53.
|
4
|
+
version: 1.53.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -1157,6 +1157,8 @@ files:
|
|
1157
1157
|
- src/core/lib/avl/avl.h
|
1158
1158
|
- src/core/lib/backoff/backoff.cc
|
1159
1159
|
- src/core/lib/backoff/backoff.h
|
1160
|
+
- src/core/lib/backoff/random_early_detection.cc
|
1161
|
+
- src/core/lib/backoff/random_early_detection.h
|
1160
1162
|
- src/core/lib/channel/call_finalization.h
|
1161
1163
|
- src/core/lib/channel/call_tracer.h
|
1162
1164
|
- src/core/lib/channel/channel_args.cc
|
@@ -3058,7 +3060,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
3058
3060
|
- !ruby/object:Gem::Version
|
3059
3061
|
version: '0'
|
3060
3062
|
requirements: []
|
3061
|
-
rubygems_version: 3.4.
|
3063
|
+
rubygems_version: 3.4.13
|
3062
3064
|
signing_key:
|
3063
3065
|
specification_version: 4
|
3064
3066
|
summary: GRPC system in Ruby
|