Class StreamingNettyByteBody.SharedBuffer
java.lang.Object
io.micronaut.http.body.stream.BaseSharedBuffer
io.micronaut.http.netty.body.StreamingNettyByteBody.SharedBuffer
- All Implemented Interfaces:
BufferConsumer
- Enclosing class:
StreamingNettyByteBody
This class buffers input data and distributes it to multiple
StreamingNettyByteBody
instances.
Thread safety: The BufferConsumer methods must only be called from one
thread, the eventLoop thread. The other methods (subscribe, reserve) can be
called from any thread.
- Since:
- 4.5.0
- Author:
- Jonas Konrad
-
Nested Class Summary
Nested classes/interfaces inherited from class BaseSharedBuffer
BaseSharedBuffer.AsFlux, BaseSharedBuffer.IncorrectContentLengthExceptionNested classes/interfaces inherited from interface BufferConsumer
BufferConsumer.Upstream -
Constructor Summary
ConstructorsConstructorDescriptionSharedBuffer(io.netty.channel.EventLoop loop, NettyByteBodyFactory byteBodyFactory, BodySizeLimits limits, BufferConsumer.Upstream rootUpstream) -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable List<ReadBuffer> addGuarded(ReadBuffer rb, boolean completeAfter) Hook for subclasses that need to apply a concurrency guard around theBaseSharedBuffer.add(ReadBuffer)portion ofBaseSharedBuffer.add(ReadBuffer)andBaseSharedBuffer.addAndComplete(ReadBuffer).protected voidafterSubscribe(boolean last) Called after a subscribe operation.io.netty.channel.EventLoopprotected voidreserve0()Reserve a spot for a future subscribe operation.
Not thread safe, caller must handle concurrency.voidsetExpectedLengthFrom(io.netty.handler.codec.http.HttpHeaders headers) Methods inherited from class BaseSharedBuffer
add, addAndComplete, addSizeLimitTrackers, complete, error, getExpectedLength, getRootUpstream, logClaim, setExpectedLength, setExpectedLengthFrom, subscribe0, subscribeFull0Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BufferConsumer
discard
-
Constructor Details
-
SharedBuffer
public SharedBuffer(io.netty.channel.EventLoop loop, NettyByteBodyFactory byteBodyFactory, BodySizeLimits limits, BufferConsumer.Upstream rootUpstream)
-
-
Method Details
-
eventLoop
public io.netty.channel.EventLoop eventLoop() -
setExpectedLengthFrom
public void setExpectedLengthFrom(io.netty.handler.codec.http.HttpHeaders headers) -
reserve0
protected void reserve0()Description copied from class:BaseSharedBufferReserve a spot for a future subscribe operation.
Not thread safe, caller must handle concurrency.- Overrides:
reserve0in classBaseSharedBuffer
-
afterSubscribe
protected void afterSubscribe(boolean last) Description copied from class:BaseSharedBufferCalled after a subscribe operation. Used for leak detection.- Overrides:
afterSubscribein classBaseSharedBuffer- Parameters:
last-trueiff this was the last reservation
-
addGuarded
Description copied from class:BaseSharedBufferHook for subclasses that need to apply a concurrency guard around theBaseSharedBuffer.add(ReadBuffer)portion ofBaseSharedBuffer.add(ReadBuffer)andBaseSharedBuffer.addAndComplete(ReadBuffer). Subclasses must callsuper.addGuarded(rb, completeAfter)and return its result.- Overrides:
addGuardedin classBaseSharedBuffer- Parameters:
rb- The buffer to addcompleteAfter- Whether the subscribers should be completed together with this buffer- Returns:
- With
completeAfter, the copies ofrbstill to be delivered to the streaming subscribers together with their completion, one per subscriber in order, ornullif there are none to deliver. AlwaysnullwithoutcompleteAfter.
-