Class ArmeriaMessageDeframer

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

@UnstableApi
public class ArmeriaMessageDeframer
extends Object
implements AutoCloseable
A deframer of messages transported in the gRPC wire format. See gRPC Wire Format for more detail on the protocol.

The logic has been mostly copied from io.grpc.internal.MessageDeframer, while removing the buffer abstraction in favor of using ByteBuf directly, and allowing the delivery of uncompressed frames as a ByteBuf to optimize message parsing.

  • Field Details

  • Constructor Details

  • Method Details

    • request

      public void request​(int numMessages)
      Requests up to the given number of messages from the call to be delivered to ArmeriaMessageDeframer.Listener.messageRead(DeframedMessage). No additional messages will be delivered.

      If close() has been called, this method will have no effect.

      Parameters:
      numMessages - the requested number of messages to be delivered to the listener.
    • isStalled

      public boolean isStalled()
      Indicates whether delivery is currently stalled, pending receipt of more data. This means that no additional data can be delivered to the application.
    • deframe

      public void deframe​(HttpData data, boolean endOfStream)
      Adds the given data to this deframer and attempts delivery to the listener.
      Parameters:
      data - the raw data read from the remote endpoint. Must be non-null.
      endOfStream - if true, indicates that data is the end of the stream from the remote endpoint. End of stream should not be used in the event of a transport error, such as a stream reset.
      Throws:
      IllegalStateException - if close() has been called previously or if this method has previously been called with endOfStream=true.
    • closeWhenComplete

      public void closeWhenComplete()
      Requests closing this deframer when any messages currently queued have been requested and delivered.
    • close

      public void close()
      Closes this deframer and frees any resources. After this method is called, additional calls will have no effect.
      Specified by:
      close in interface AutoCloseable
    • whenClosed

      public CompletableFuture<Void> whenClosed()
      Returns a CompletableFuture which will be completed when this deframer has been closed.
    • isClosing

      public boolean isClosing()
      Indicates whether or not this deframer is closing.
    • isClosed

      public boolean isClosed()
      Indicates whether or not this deframer has been closed.
    • decompressor

      public ArmeriaMessageDeframer decompressor​(@Nullable Decompressor decompressor)
      Sets the Decompressor for this deframer.