Class GrpcUtil.TimeoutMarshaller

java.lang.Object
io.grpc.internal.GrpcUtil.TimeoutMarshaller
All Implemented Interfaces:
Metadata.AsciiMarshaller<Long>
Enclosing class:
GrpcUtil

static class GrpcUtil.TimeoutMarshaller extends Object implements Metadata.AsciiMarshaller<Long>
Marshals a nanoseconds representation of the timeout to and from a string representation, consisting of an ASCII decimal representation of a number with at most 8 digits, followed by a unit. Available units: n = nanoseconds u = microseconds m = milliseconds S = seconds M = minutes H = hours

The representation is greedy with respect to precision. That is, 2 seconds will be represented as `2000000u`.

See the request header definition

  • Constructor Details

    • TimeoutMarshaller

      TimeoutMarshaller()
  • Method Details

    • toAsciiString

      public String toAsciiString(Long timeoutNanos)
      Description copied from interface: Metadata.AsciiMarshaller
      Serialize a metadata value to a ASCII string that contains only the characters listed in the class comment of Metadata.AsciiMarshaller. Otherwise the output may be considered invalid and discarded by the transport, or the call may fail.
      Specified by:
      toAsciiString in interface Metadata.AsciiMarshaller<Long>
      Parameters:
      timeoutNanos - to serialize
      Returns:
      serialized version of value, or null if value cannot be transmitted.
    • parseAsciiString

      public Long parseAsciiString(String serialized)
      Description copied from interface: Metadata.AsciiMarshaller
      Parse a serialized metadata value from an ASCII string.
      Specified by:
      parseAsciiString in interface Metadata.AsciiMarshaller<Long>
      Parameters:
      serialized - value of metadata to parse
      Returns:
      a parsed instance of type T