1 // Copyright 2023 gRPC authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H 16 #define GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H 17 18 #include <grpc/support/port_platform.h> 19 #include <stddef.h> 20 21 namespace grpc_core { 22 23 /////////////////////////////////////////////////////////////////////////////// 24 // Compression traits. 25 // 26 // Each metadata trait exposes exactly one compression trait. 27 // This type directs how transports might choose to compress the metadata. 28 // Adding a value here typically involves editing all transports to support the 29 // trait, and so should not be done lightly. 30 31 // No compression. 32 struct NoCompressionCompressor {}; 33 34 // Expect a single value for this metadata key, but we don't know apriori its 35 // value. 36 // It's ok if it changes over time, but it should be mostly stable. 37 // This is used for things like user-agent, which is expected to be the same 38 // for all requests. 39 struct StableValueCompressor {}; 40 41 // Expect a single value for this metadata key, and we know apriori its value. 42 template <typename T, T value> 43 struct KnownValueCompressor {}; 44 45 // Values are incompressable, but expect the key to be in most requests and try 46 // and compress that. 47 struct FrequentKeyWithNoValueCompressionCompressor {}; 48 49 // Expect a small set of values for this metadata key. 50 struct SmallSetOfValuesCompressor {}; 51 52 // Expect integral values up to N for this metadata key. 53 template <size_t N> 54 struct SmallIntegralValuesCompressor {}; 55 56 // Specialty compressor for grpc-timeout metadata. 57 struct TimeoutCompressor {}; 58 59 // Specialty compressors for HTTP/2 pseudo headers. 60 struct HttpSchemeCompressor {}; 61 struct HttpMethodCompressor {}; 62 struct HttpStatusCompressor {}; 63 64 } // namespace grpc_core 65 66 #endif // GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H 67