Package io.grpc.internal
Class MessageFramer
java.lang.Object
io.grpc.internal.MessageFramer
- All Implemented Interfaces:
Framer
Encodes gRPC messages to be delivered via the transport layer which implements
MessageFramer.Sink
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Sink implemented by the transport layer to receive frames and forward them to their destination. -
Constructor Summary
ConstructorsConstructorDescriptionMessageFramer
(MessageFramer.Sink sink, WritableBufferAllocator bufferAllocator, StatsTraceContext statsTraceCtx) Creates aMessageFramer
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Flushes and closes the framer and releases any buffers.void
dispose()
Closes the framer and releases any buffers, but does not flush.void
flush()
Flushes any buffered data in the framer to the sink.boolean
isClosed()
setCompressor
(Compressor compressor) Set the compressor used for compression.void
setMaxOutboundMessageSize
(int maxSize) Set a size limit for each outbound message.setMessageCompression
(boolean enable) Enable or disable compression.void
writePayload
(InputStream message) Writes out a payload message.
-
Constructor Details
-
MessageFramer
public MessageFramer(MessageFramer.Sink sink, WritableBufferAllocator bufferAllocator, StatsTraceContext statsTraceCtx) Creates aMessageFramer
.- Parameters:
sink
- the sink used to deliver frames to the transportbufferAllocator
- allocates buffers that the transport can commit to the wire.
-
-
Method Details
-
setCompressor
Description copied from interface:Framer
Set the compressor used for compression.- Specified by:
setCompressor
in interfaceFramer
-
setMessageCompression
Description copied from interface:Framer
Enable or disable compression.- Specified by:
setMessageCompression
in interfaceFramer
-
setMaxOutboundMessageSize
public void setMaxOutboundMessageSize(int maxSize) Description copied from interface:Framer
Set a size limit for each outbound message.- Specified by:
setMaxOutboundMessageSize
in interfaceFramer
-
writePayload
Writes out a payload message.- Specified by:
writePayload
in interfaceFramer
- Parameters:
message
- contains the message to be written out. It will be completely consumed.
-
flush
public void flush()Flushes any buffered data in the framer to the sink. -
isClosed
public boolean isClosed() -
close
public void close()Flushes and closes the framer and releases any buffers. After the framer is closed or disposed, additional calls to this method will have no affect. -
dispose
public void dispose()Closes the framer and releases any buffers, but does not flush. After the framer is closed or disposed, additional calls to this method will have no affect.
-