Class ArmeriaMessageFramer

java.lang.Object
com.linecorp.armeria.common.grpc.protocol.ArmeriaMessageFramer
All Implemented Interfaces:
AutoCloseable

@UnstableApi public class ArmeriaMessageFramer extends Object implements AutoCloseable
A framer of messages for transport with the gRPC wire protocol. See gRPC Wire Format for more detail on the protocol.

The logic has mostly been copied from io.grpc.internal.MessageFramer, while removing the buffer abstraction in favor of using ByteBuf directly. The code has been vastly simplified due to the lack of support for arbitrary InputStreams.

  • Field Details

    • NO_MAX_OUTBOUND_MESSAGE_SIZE

      public static final int NO_MAX_OUTBOUND_MESSAGE_SIZE
      See Also:
      Constant Field Values
  • Constructor Details

    • ArmeriaMessageFramer

      public ArmeriaMessageFramer(ByteBufAllocator alloc, int maxOutboundMessageSize, boolean encodeBase64)
      Constructs an ArmeriaMessageFramer to write messages to a gRPC request or response.
  • Method Details

    • writePayload

      public HttpData writePayload(ByteBuf message)
      Writes out a payload message.
      Parameters:
      message - the message to be written out. Ownership is taken by ArmeriaMessageFramer.
      Returns:
      an HttpData with the framed payload. Ownership is passed to caller.
    • writePayload

      public HttpData writePayload(ByteBuf message, boolean webTrailers)
      Writes out a payload message.
      Parameters:
      message - the message to be written out. Ownership is taken by ArmeriaMessageFramer.
      webTrailers - tells whether the payload is web trailers
      Returns:
      an HttpData with the framed payload. Ownership is passed to caller. If the specified webTrailers is true, HttpObject.isEndOfStream() returns true.
    • setMessageCompression

      public void setMessageCompression(boolean messageCompression)
      Enables or disables message compression.
      Parameters:
      messageCompression - whether to enable message compression.
    • setCompressor

      public void setCompressor(@Nullable @Nullable Compressor compressor)
      Sets the Compressor.
    • isClosed

      public boolean isClosed()
      Indicates whether or not this framer has been closed via a call to either close().
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable