@ -49,6 +49,16 @@
namespace grpc_core {
namespace grpc_core {
// Given a metadata key and a value, return the encoded size.
// Defaults to calling the key's Encode() method and then calculating the size
// of that, but can be overridden for specific keys if there's a better way of
// doing this.
// May return 0 if the size is unknown/unknowable.
template < typename Key >
size_t EncodedSizeOfKey ( Key , const typename Key : : ValueType & value ) {
return Key : : Encode ( value ) . size ( ) ;
}
// grpc-timeout metadata trait.
// grpc-timeout metadata trait.
// ValueType is defined as Timestamp - an absolute timestamp (i.e. a
// ValueType is defined as Timestamp - an absolute timestamp (i.e. a
// deadline!), that is converted to a duration by transports before being
// deadline!), that is converted to a duration by transports before being
@ -90,6 +100,10 @@ struct TeMetadata {
static const char * DisplayMemento ( MementoType te ) { return DisplayValue ( te ) ; }
static const char * DisplayMemento ( MementoType te ) { return DisplayValue ( te ) ; }
} ;
} ;
inline size_t EncodedSizeOfKey ( TeMetadata , TeMetadata : : ValueType x ) {
return x = = TeMetadata : : kTrailers ? 8 : 0 ;
}
// content-type metadata trait.
// content-type metadata trait.
struct ContentTypeMetadata {
struct ContentTypeMetadata {
static constexpr bool kRepeatable = false ;
static constexpr bool kRepeatable = false ;
@ -140,6 +154,8 @@ struct HttpSchemeMetadata {
}
}
} ;
} ;
size_t EncodedSizeOfKey ( HttpSchemeMetadata , HttpSchemeMetadata : : ValueType x ) ;
// method metadata trait.
// method metadata trait.
struct HttpMethodMetadata {
struct HttpMethodMetadata {
static constexpr bool kRepeatable = false ;
static constexpr bool kRepeatable = false ;
@ -362,6 +378,11 @@ struct GrpcLbClientStatsMetadata {
}
}
} ;
} ;
inline size_t EncodedSizeOfKey ( GrpcLbClientStatsMetadata ,
GrpcLbClientStatsMetadata : : ValueType ) {
return 0 ;
}
// lb-token metadata
// lb-token metadata
struct LbTokenMetadata : public SimpleSliceBasedMetadata {
struct LbTokenMetadata : public SimpleSliceBasedMetadata {
static constexpr bool kRepeatable = false ;
static constexpr bool kRepeatable = false ;