Package io.micronaut.http.body
Class AbstractBodyAdapter
java.lang.Object
io.micronaut.http.body.AbstractBodyAdapter
- All Implemented Interfaces:
BufferConsumer.Upstream,org.reactivestreams.Subscriber<io.micronaut.core.io.buffer.ReadBuffer>
@Internal
public class AbstractBodyAdapter
extends Object
implements BufferConsumer.Upstream, org.reactivestreams.Subscriber<io.micronaut.core.io.buffer.ReadBuffer>
An adapter that transforms a
Publisher of buffers to a ByteBody. Called
AbstractBodyAdapter for historical reasons, but can be used as-is.- Since:
- 4.8.0
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractBodyAdapter(@NonNull org.reactivestreams.Publisher<io.micronaut.core.io.buffer.ReadBuffer> source, @Nullable Runnable onDiscard) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAllow the upstream to discard any further messages.final voidInstruct the upstream to ignore backpressure from this consumer.final voidonBytesConsumed(long bytesConsumed) Called when a number of bytes has been consumed by the downstream.voidvoidvoidonNext(io.micronaut.core.io.buffer.ReadBuffer buffer) final voidonSubscribe(org.reactivestreams.Subscription s) final voidsetSharedBuffer(BaseSharedBuffer sharedBuffer) final voidstart()Signal that we want to start consuming bytes.
-
Constructor Details
-
AbstractBodyAdapter
public AbstractBodyAdapter(@NonNull @NonNull org.reactivestreams.Publisher<io.micronaut.core.io.buffer.ReadBuffer> source, @Nullable @Nullable Runnable onDiscard)
-
-
Method Details
-
start
public final void start()Description copied from interface:BufferConsumer.UpstreamSignal that we want to start consuming bytes. This is an optional hint to the upstream, the upstream may ignore it and send bytes immediately. This is used for CONTINUE support.- Specified by:
startin interfaceBufferConsumer.Upstream
-
onBytesConsumed
public final void onBytesConsumed(long bytesConsumed) Description copied from interface:BufferConsumer.UpstreamCalled when a number of bytes has been consumed by the downstream. Note that this can exceed the actual number of bytes written so far, if the downstream wants to signal it is ready consume much more data.- Specified by:
onBytesConsumedin interfaceBufferConsumer.Upstream- Parameters:
bytesConsumed- The number of bytes that were consumed
-
allowDiscard
public final void allowDiscard()Description copied from interface:BufferConsumer.UpstreamAllow the upstream to discard any further messages. Note that this does not actually mean the messages must be discarded: If another consumer still needs the body data, it may continue to be read and continue to be forwarded to this consumer.- Specified by:
allowDiscardin interfaceBufferConsumer.Upstream
-
disregardBackpressure
public final void disregardBackpressure()Description copied from interface:BufferConsumer.UpstreamInstruct the upstream to ignore backpressure from this consumer. This is slightly different fromonBytesConsumed(Long.MAX_VALUE): If there are two consumers inByteBody.SplitBackpressureMode.FASTESTmode, a MAX_VALUE requests all data from the common upstream, while a disregardBackpressure removes this downstream from consideration.- Specified by:
disregardBackpressurein interfaceBufferConsumer.Upstream
-
onSubscribe
public final void onSubscribe(org.reactivestreams.Subscription s) - Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<io.micronaut.core.io.buffer.ReadBuffer>
-
onNext
public void onNext(io.micronaut.core.io.buffer.ReadBuffer buffer) - Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<io.micronaut.core.io.buffer.ReadBuffer>
-
onError
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<io.micronaut.core.io.buffer.ReadBuffer>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<io.micronaut.core.io.buffer.ReadBuffer>