T - the type of the stream elementpublic interface StreamWriter<T>
StreamMessage.
When the following methods are given with a ReferenceCounted object, such as ByteBuf and
ByteBufHttpData, or the Supplier that provides such an object:
false or raises an exception.Subscriber of the stream consumes it.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
StreamMessage successfully. |
default void |
close(T obj)
Deprecated.
Use
tryWrite(Object) and close(). |
void |
close(Throwable cause)
Closes the
StreamMessage exceptionally. |
boolean |
isOpen()
Returns
true if the StreamMessage is open. |
default CompletableFuture<Void> |
onDemand(Runnable task)
Deprecated.
|
default boolean |
tryWrite(Supplier<? extends T> o)
Writes the specified object
Supplier to the StreamMessage. |
boolean |
tryWrite(T o)
Writes the specified object to the
StreamMessage. |
CompletableFuture<Void> |
whenConsumed()
Returns a
CompletableFuture which is completed when all elements written so far have been
consumed by the Subscriber. |
default void |
write(Supplier<? extends T> o)
Writes the specified object
Supplier to the StreamMessage. |
default void |
write(T o)
Writes the specified object to the
StreamMessage. |
boolean isOpen()
true if the StreamMessage is open.default void write(T o)
StreamMessage. The written object will be transferred to the
Subscriber.ClosedStreamException - if the stream was already closedIllegalArgumentException - if the publication of the specified object has been rejecteddefault void write(Supplier<? extends T> o)
Supplier to the StreamMessage. The object provided by the
Supplier will be transferred to the Subscriber.ClosedStreamException - if the stream was already closed.boolean tryWrite(T o)
StreamMessage. The written object will be transferred to the
Subscriber.true if the specified object has been scheduled for publication. false if the
stream has been closed already.IllegalArgumentException - if the publication of the specified object has been rejecteddefault boolean tryWrite(Supplier<? extends T> o)
Supplier to the StreamMessage. The object provided by the
Supplier will be transferred to the Subscriber.true if the specified object has been scheduled for publication. false if the
stream has been closed already.@Deprecated default CompletableFuture<Void> onDemand(Runnable task)
whenConsumed() and CompletableFuture.thenRun(Runnable).task when there are enough demands from the Subscriber.task finishes or
exceptionally when the StreamMessage is closed unexpectedly.CompletableFuture<Void> whenConsumed()
CompletableFuture which is completed when all elements written so far have been
consumed by the Subscriber.StreamMessage has been closed unexpectedly.void close()
StreamMessage successfully. Subscriber.onComplete() will be invoked to
signal that the Subscriber has consumed the stream completely.void close(Throwable cause)
StreamMessage exceptionally. Subscriber.onError(Throwable) will be invoked to
signal that the Subscriber did not consume the stream completely.@Deprecated default void close(T obj)
tryWrite(Object) and close().Subscriber.ClosedStreamException - if the stream was already closed.Copyright © 2020 LeanCloud. All rights reserved.