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 
20 #include <stddef.h>
21 
22 namespace grpc_core {
23 
24 ///////////////////////////////////////////////////////////////////////////////
25 // Compression traits.
26 //
27 // Each metadata trait exposes exactly one compression trait.
28 // This type directs how transports might choose to compress the metadata.
29 // Adding a value here typically involves editing all transports to support the
30 // trait, and so should not be done lightly.
31 
32 // No compression.
33 struct NoCompressionCompressor {};
34 
35 // Expect a single value for this metadata key, but we don't know apriori its
36 // value.
37 // It's ok if it changes over time, but it should be mostly stable.
38 // This is used for things like user-agent, which is expected to be the same
39 // for all requests.
40 struct StableValueCompressor {};
41 
42 // Expect a single value for this metadata key, and we know apriori its value.
43 template <typename T, T value>
44 struct KnownValueCompressor {};
45 
46 // Values are uncompressible, but expect the key to be in most requests and try
47 // and compress that.
48 struct FrequentKeyWithNoValueCompressionCompressor {};
49 
50 // Expect a small set of values for this metadata key.
51 struct SmallSetOfValuesCompressor {};
52 
53 // Expect integral values up to N for this metadata key.
54 template <size_t N>
55 struct SmallIntegralValuesCompressor {};
56 
57 // Specialty compressor for grpc-timeout metadata.
58 struct TimeoutCompressor {};
59 
60 // Specialty compressors for HTTP/2 psuedo headers.
61 struct HttpSchemeCompressor {};
62 struct HttpMethodCompressor {};
63 struct HttpStatusCompressor {};
64 
65 }  // namespace grpc_core
66 
67 #endif  // GRPC_SRC_CORE_LIB_TRANSPORT_METADATA_COMPRESSION_TRAITS_H
68