Class ReadableByteChunksFrameChannel

    • Method Detail

      • create

        public static ReadableByteChunksFrameChannel create​(String id,
                                                            boolean framesOnly)
        Create a channel that aims to limit its memory footprint to one frame. The channel exerts backpressure from addChunk(byte[]) immediately once a full frame has been buffered.
      • addChunk

        @Nullable
        public com.google.common.util.concurrent.ListenableFuture<?> addChunk​(byte[] chunk)
        Adds a chunk of bytes. If this chunk forms a full frame, it will immediately become available for reading. Otherwise, the bytes will be buffered until a full frame is encountered. Returns a backpressure future if the amount of queued bytes is at or above this channel's limit. If the return future is nonnull, callers are politely requested to wait for the future to resolve before adding additional chunks. (This is not enforced; addChunk will continue to accept new chunks even if the channel is over its limit.) When done adding chunks call doneWriting.
      • setError

        public void setError​(Throwable t)
        Clears the channel and replaces it with the given error. After calling this method, no additional chunks will be accepted.
      • doneWriting

        public void doneWriting()
        Call method when caller is done adding chunks.
      • isFinished

        public boolean isFinished()
        Description copied from interface: ReadableFrameChannel
        Returns whether this channel is finished. Finished channels will not generate any further frames or errors. Generally, once you discover that a channel is finished, you should call ReadableFrameChannel.close() and then discard it. Note that it is possible for a channel to be unfinished and also have no available frames or errors. This happens when it is not in a ready-for-reading state. See ReadableFrameChannel.readabilityFuture() for details.
        Specified by:
        isFinished in interface ReadableFrameChannel
      • getId

        public String getId()
      • getBytesAdded

        public long getBytesAdded()
      • isErrorOrFinished

        public boolean isErrorOrFinished()