[transport] Move compression traits into a separate header. (#32895)

We get a circular dependency problem otherwise if these are needed in
`custom_metadata.h` (which they always are for that file to be useful).
pull/32897/head
Craig Tiller 2 years ago committed by GitHub
parent c523bdac1e
commit 5cae7abd31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      BUILD
  2. 4
      build_autogenerated.yaml
  3. 2
      gRPC-C++.podspec
  4. 2
      gRPC-Core.podspec
  5. 1
      grpc.gemspec
  6. 1
      package.xml
  7. 8
      src/core/BUILD
  8. 1
      src/core/ext/transport/chttp2/transport/hpack_encoder.h
  9. 42
      src/core/lib/transport/metadata_batch.h
  10. 67
      src/core/lib/transport/metadata_compression_traits.h
  11. 1
      tools/doxygen/Doxyfile.c++.internal
  12. 1
      tools/doxygen/Doxyfile.core.internal

@ -1517,6 +1517,7 @@ grpc_cc_library(
"//src/core:map",
"//src/core:match",
"//src/core:memory_quota",
"//src/core:metadata_compression_traits",
"//src/core:no_destruct",
"//src/core:notification",
"//src/core:packed_table",
@ -3672,6 +3673,7 @@ grpc_cc_library(
"http_trace",
"//src/core:hpack_constants",
"//src/core:hpack_encoder_table",
"//src/core:metadata_compression_traits",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:time",

@ -953,6 +953,7 @@ libs:
- src/core/lib/transport/http2_errors.h
- src/core/lib/transport/http_connect_handshaker.h
- src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/metadata_compression_traits.h
- src/core/lib/transport/parsed_metadata.h
- src/core/lib/transport/pid_controller.h
- src/core/lib/transport/simple_slice_based_metadata.h
@ -2279,6 +2280,7 @@ libs:
- src/core/lib/transport/http2_errors.h
- src/core/lib/transport/http_connect_handshaker.h
- src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/metadata_compression_traits.h
- src/core/lib/transport/parsed_metadata.h
- src/core/lib/transport/pid_controller.h
- src/core/lib/transport/simple_slice_based_metadata.h
@ -3748,6 +3750,7 @@ libs:
- src/core/lib/transport/handshaker_registry.h
- src/core/lib/transport/http2_errors.h
- src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/metadata_compression_traits.h
- src/core/lib/transport/parsed_metadata.h
- src/core/lib/transport/simple_slice_based_metadata.h
- src/core/lib/transport/status_conversion.h
@ -7658,6 +7661,7 @@ targets:
- src/core/lib/transport/handshaker_registry.h
- src/core/lib/transport/http2_errors.h
- src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/metadata_compression_traits.h
- src/core/lib/transport/parsed_metadata.h
- src/core/lib/transport/simple_slice_based_metadata.h
- src/core/lib/transport/status_conversion.h

2
gRPC-C++.podspec generated

@ -1048,6 +1048,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/metadata_compression_traits.h',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/simple_slice_based_metadata.h',
@ -2070,6 +2071,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/metadata_compression_traits.h',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/simple_slice_based_metadata.h',

2
gRPC-Core.podspec generated

@ -1740,6 +1740,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.cc',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/metadata_compression_traits.h',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.cc',
@ -2788,6 +2789,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/metadata_compression_traits.h',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/simple_slice_based_metadata.h',

1
grpc.gemspec generated

@ -1646,6 +1646,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/transport/http_connect_handshaker.h )
s.files += %w( src/core/lib/transport/metadata_batch.cc )
s.files += %w( src/core/lib/transport/metadata_batch.h )
s.files += %w( src/core/lib/transport/metadata_compression_traits.h )
s.files += %w( src/core/lib/transport/parsed_metadata.cc )
s.files += %w( src/core/lib/transport/parsed_metadata.h )
s.files += %w( src/core/lib/transport/pid_controller.cc )

1
package.xml generated

@ -1628,6 +1628,7 @@
<file baseinstalldir="/" name="src/core/lib/transport/http_connect_handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_compression_traits.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/parsed_metadata.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/parsed_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/pid_controller.cc" role="src" />

@ -98,6 +98,14 @@ grpc_cc_library(
deps = ["//:gpr"],
)
grpc_cc_library(
name = "metadata_compression_traits",
hdrs = [
"lib/transport/metadata_compression_traits.h",
],
deps = ["//:gpr_platform"],
)
grpc_cc_library(
name = "experiments",
srcs = [

@ -40,6 +40,7 @@
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/metadata_compression_traits.h"
#include "src/core/lib/transport/timeout_encoding.h"
#include "src/core/lib/transport/transport.h"

@ -46,52 +46,12 @@
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/transport/custom_metadata.h"
#include "src/core/lib/transport/metadata_compression_traits.h"
#include "src/core/lib/transport/parsed_metadata.h"
#include "src/core/lib/transport/simple_slice_based_metadata.h"
namespace grpc_core {
///////////////////////////////////////////////////////////////////////////////
// Compression traits.
//
// Each metadata trait exposes exactly one compression trait.
// This type directs how transports might choose to compress the metadata.
// Adding a value here typically involves editing all transports to support the
// trait, and so should not be done lightly.
// No compression.
struct NoCompressionCompressor {};
// Expect a single value for this metadata key, but we don't know apriori its
// value.
// It's ok if it changes over time, but it should be mostly stable.
// This is used for things like user-agent, which is expected to be the same
// for all requests.
struct StableValueCompressor {};
// Expect a single value for this metadata key, and we know apriori its value.
template <typename T, T value>
struct KnownValueCompressor {};
// Values are uncompressible, but expect the key to be in most requests and try
// and compress that.
struct FrequentKeyWithNoValueCompressionCompressor {};
// Expect a small set of values for this metadata key.
struct SmallSetOfValuesCompressor {};
// Expect integral values up to N for this metadata key.
template <size_t N>
struct SmallIntegralValuesCompressor {};
// Specialty compressor for grpc-timeout metadata.
struct TimeoutCompressor {};
// Specialty compressors for HTTP/2 psuedo headers.
struct HttpSchemeCompressor {};
struct HttpMethodCompressor {};
struct HttpStatusCompressor {};
///////////////////////////////////////////////////////////////////////////////
// Metadata traits

@ -0,0 +1,67 @@
// Copyright 2023 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H
#define GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
namespace grpc_core {
///////////////////////////////////////////////////////////////////////////////
// Compression traits.
//
// Each metadata trait exposes exactly one compression trait.
// This type directs how transports might choose to compress the metadata.
// Adding a value here typically involves editing all transports to support the
// trait, and so should not be done lightly.
// No compression.
struct NoCompressionCompressor {};
// Expect a single value for this metadata key, but we don't know apriori its
// value.
// It's ok if it changes over time, but it should be mostly stable.
// This is used for things like user-agent, which is expected to be the same
// for all requests.
struct StableValueCompressor {};
// Expect a single value for this metadata key, and we know apriori its value.
template <typename T, T value>
struct KnownValueCompressor {};
// Values are uncompressible, but expect the key to be in most requests and try
// and compress that.
struct FrequentKeyWithNoValueCompressionCompressor {};
// Expect a small set of values for this metadata key.
struct SmallSetOfValuesCompressor {};
// Expect integral values up to N for this metadata key.
template <size_t N>
struct SmallIntegralValuesCompressor {};
// Specialty compressor for grpc-timeout metadata.
struct TimeoutCompressor {};
// Specialty compressors for HTTP/2 psuedo headers.
struct HttpSchemeCompressor {};
struct HttpMethodCompressor {};
struct HttpStatusCompressor {};
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H

@ -2641,6 +2641,7 @@ src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/http_connect_handshaker.h \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/metadata_batch.h \
src/core/lib/transport/metadata_compression_traits.h \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/parsed_metadata.h \
src/core/lib/transport/pid_controller.cc \

@ -2425,6 +2425,7 @@ src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/http_connect_handshaker.h \
src/core/lib/transport/metadata_batch.cc \
src/core/lib/transport/metadata_batch.h \
src/core/lib/transport/metadata_compression_traits.h \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/parsed_metadata.h \
src/core/lib/transport/pid_controller.cc \

Loading…
Cancel
Save