Class ArmeriaMessageFramer
java.lang.Object
com.linecorp.armeria.common.grpc.protocol.ArmeriaMessageFramer
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionArmeriaMessageFramer(ByteBufAllocator alloc, int maxMessageLength, boolean encodeBase64) Constructs anArmeriaMessageFramerto write messages to a gRPC request or response. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisClosed()Indicates whether or not this framer has been closed via a call to eitherclose().voidsetCompressor(@Nullable Compressor compressor) Sets theCompressor.voidsetMessageCompression(boolean messageCompression) Enables or disables message compression.com.linecorp.armeria.common.HttpDatawritePayload(ByteBuf message) Writes out a payload message.com.linecorp.armeria.common.HttpDatawritePayload(ByteBuf message, boolean webTrailers) Writes out a payload message.
-
Field Details
-
NO_MAX_OUTBOUND_MESSAGE_SIZE
public static final int NO_MAX_OUTBOUND_MESSAGE_SIZE- See Also:
-
-
Constructor Details
-
ArmeriaMessageFramer
Constructs anArmeriaMessageFramerto write messages to a gRPC request or response.
-
-
Method Details
-
writePayload
Writes out a payload message.- Parameters:
message- the message to be written out. Ownership is taken byArmeriaMessageFramer.- Returns:
- an
HttpDatawith the framed payload. Ownership is passed to caller.
-
writePayload
Writes out a payload message.- Parameters:
message- the message to be written out. Ownership is taken byArmeriaMessageFramer.webTrailers- tells whether the payload is web trailers- Returns:
- an
HttpDatawith the framed payload. Ownership is passed to caller. If the specifiedwebTrailersistrue,HttpObject.isEndOfStream()returnstrue.
-
setMessageCompression
public void setMessageCompression(boolean messageCompression) Enables or disables message compression.- Parameters:
messageCompression- whether to enable message compression.
-
setCompressor
Sets theCompressor. -
isClosed
public boolean isClosed()Indicates whether or not this framer has been closed via a call to eitherclose(). -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-