类 OutputStreamPublisher<T>
java.lang.Object
cn.taketoday.http.client.OutputStreamPublisher<T>
- 类型参数:
T- the published item type
- 所有已实现的接口:
Flow.Publisher<T>
Bridges between
OutputStream and
Flow.Publisher<T>.- 从以下版本开始:
- 4.0
- 作者:
- Oleh Dokuka, Arjen Poutsma, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明static interfaceMaps bytes written to inOutputStreamPublisher.OutputStreamHandler.handle(OutputStream)to published items.static interfaceDefines the contract for handling theOutputStreamprovided by theOutputStreamPublisher.private static final class -
字段概要
字段修饰符和类型字段说明private final OutputStreamPublisher.ByteMapper<T>private final intprivate static final intprivate final Executorprivate final OutputStreamPublisher.OutputStreamHandler -
构造器概要
构造器限定符构造器说明privateOutputStreamPublisher(OutputStreamPublisher.OutputStreamHandler outputStreamHandler, OutputStreamPublisher.ByteMapper<T> byteMapper, Executor executor, int chunkSize) -
方法概要
修饰符和类型方法说明static <T> Flow.Publisher<T>create(OutputStreamPublisher.OutputStreamHandler outputStreamHandler, OutputStreamPublisher.ByteMapper<T> byteMapper, Executor executor) Creates a newPublisher<T>based on bytes written to aOutputStream.static <T> Flow.Publisher<T>create(OutputStreamPublisher.OutputStreamHandler outputStreamHandler, OutputStreamPublisher.ByteMapper<T> byteMapper, Executor executor, int chunkSize) Creates a newPublisher<T>based on bytes written to aOutputStream.voidsubscribe(Flow.Subscriber<? super T> subscriber)
-
字段详细资料
-
DEFAULT_CHUNK_SIZE
private static final int DEFAULT_CHUNK_SIZE- 另请参阅:
-
outputStreamHandler
-
byteMapper
-
executor
-
chunkSize
private final int chunkSize
-
-
构造器详细资料
-
OutputStreamPublisher
private OutputStreamPublisher(OutputStreamPublisher.OutputStreamHandler outputStreamHandler, OutputStreamPublisher.ByteMapper<T> byteMapper, Executor executor, int chunkSize)
-
-
方法详细资料
-
create
public static <T> Flow.Publisher<T> create(OutputStreamPublisher.OutputStreamHandler outputStreamHandler, OutputStreamPublisher.ByteMapper<T> byteMapper, Executor executor) Creates a newPublisher<T>based on bytes written to aOutputStream. The parameterbyteMapperis used to map from written bytes to the published type.- The parameter
outputStreamHandleris invoked once per subscription of the returnedPublisher, when the first item is requested. OutputStream.write()invocations made byoutputStreamHandlerare buffered until they exceed the default chunk size of 1024, and then result in a published item if there is demand.- If there is no demand,
OutputStream.write()will block until there is. - If the subscription is cancelled,
OutputStream.write()will throw aIOException. - The subscription is
completed when
outputStreamHandlercompletes. - Any
IOExceptions thrown fromoutputStreamHandlerwill be dispatched to the Subscriber.
- 类型参数:
T- the publisher type- 参数:
outputStreamHandler- invoked when the first buffer is requestedbyteMapper- maps written bytes toTexecutor- used to invoke theoutputStreamHandler- 返回:
- a
Publisher<T>based on bytes written byoutputStreamHandlermapped bybyteMapper
- The parameter
-
create
public static <T> Flow.Publisher<T> create(OutputStreamPublisher.OutputStreamHandler outputStreamHandler, OutputStreamPublisher.ByteMapper<T> byteMapper, Executor executor, int chunkSize) Creates a newPublisher<T>based on bytes written to aOutputStream. The parameterbyteMapperis used to map from written bytes to the published type.- The parameter
outputStreamHandleris invoked once per subscription of the returnedPublisher, when the first item is requested. OutputStream.write()invocations made byoutputStreamHandlerare buffered until they exceedchunkSize, and then result in a published item if there is demand.- If there is no demand,
OutputStream.write()will block until there is. - If the subscription is cancelled,
OutputStream.write()will throw aIOException. - The subscription is
completed when
outputStreamHandlercompletes. - Any
IOExceptions thrown fromoutputStreamHandlerwill be dispatched to the Subscriber.
- 类型参数:
T- the publisher type- 参数:
outputStreamHandler- invoked when the first buffer is requestedbyteMapper- maps written bytes toTexecutor- used to invoke theoutputStreamHandler- 返回:
- a
Publisher<T>based on bytes written byoutputStreamHandlermapped bybyteMapper
- The parameter
-
subscribe
- 指定者:
subscribe在接口中Flow.Publisher<T>
-