java.lang.Object
io.helidon.grpc.core.GrpcHeadersUtil
Utility class for gRPC metadata and timeout headers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longdecodeTimeout(String timeout) Decodes a gRPCgrpc-timeoutheader value.static StringencodeTimeout(long timeoutNanos) Encodes a timeout as a gRPCgrpc-timeoutheader value.static io.grpc.MetadatatoMetadata(Http2Headers headers) Converts a set of HTTP/2 headers into a Metadata instance.static voidupdateHeaders(WritableHeaders<?> headers, io.grpc.Metadata metadata) Updates headers with metadata.
-
Method Details
-
encodeTimeout
Encodes a timeout as a gRPCgrpc-timeoutheader value. The value uses at most eight decimal digits and the finest unit that fits, rounding up when conversion to a coarser unit is necessary.- Parameters:
timeoutNanos- nonnegative timeout in nanoseconds- Returns:
- encoded timeout
- Throws:
IllegalArgumentException- if the timeout is negative
-
decodeTimeout
Decodes a gRPCgrpc-timeoutheader value. The value must contain one to eight ASCII decimal digits followed byH,M,S,m,u, orn. Timeouts exceeding the nanosecond range are saturated atLong.MAX_VALUE.- Parameters:
timeout- encoded timeout- Returns:
- nonnegative timeout in nanoseconds
- Throws:
IllegalArgumentException- if the timeout is malformed
-
updateHeaders
Updates headers with metadata.- Parameters:
headers- the headers to updatemetadata- the metadata
-
toMetadata
Converts a set of HTTP/2 headers into a Metadata instance.- Parameters:
headers- the headers to convert- Returns:
- the new metadata
-