Class ConnectablePayloadWriter<T>
- java.lang.Object
-
- io.servicetalk.concurrent.api.internal.ConnectablePayloadWriter<T>
-
- Type Parameters:
T- The type of data for thePayloadWriter.
- All Implemented Interfaces:
PayloadWriter<T>,java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public final class ConnectablePayloadWriter<T> extends java.lang.Object implements PayloadWriter<T>
APayloadWriterthat can beconnectedto a sink such that any data written on thePayloadWriteris eventually emitted to the connectedPublisherPublisherSource.Subscriber.
-
-
Constructor Summary
Constructors Constructor Description ConnectablePayloadWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidclose(java.lang.Throwable cause)This method shares the same characteristics asCloseable.close()but propagatescauseto downstream consumer instead of propagating "successful" completion.Publisher<T>connect()Connects thisPayloadWriterto the returnedPublishersuch that any data written to thisPayloadWriteris eventually delivered to aPublisherSource.Subscriberof the returnedPublisher.voidflush()voidwrite(T t)Write an object of typePayloadWriter.
-
-
-
Method Detail
-
write
public void write(T t) throws java.io.IOException
Description copied from interface:PayloadWriterWrite an object of typePayloadWriter.- Specified by:
writein interfacePayloadWriter<T>- Parameters:
t- the object to write.- Throws:
java.io.IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if this has been closed.
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
close
public void close(java.lang.Throwable cause) throws java.io.IOExceptionDescription copied from interface:PayloadWriterThis method shares the same characteristics asCloseable.close()but propagatescauseto downstream consumer instead of propagating "successful" completion. Here are notable characteristics shared withCloseable.close():- Resources are reclaimed
- This method is idempotent
- Subsequent calls to
PayloadWriter.write(Object)are expected to fail - Before any exception is thrown, all resources must be reclaimed and
causepropagated
- Specified by:
closein interfacePayloadWriter<T>- Parameters:
cause- Indicate the close is a result of a failure.- Throws:
java.io.IOException- if an input/output error occurs.
-
connect
public Publisher<T> connect()
Connects thisPayloadWriterto the returnedPublishersuch that any data written to thisPayloadWriteris eventually delivered to aPublisherSource.Subscriberof the returnedPublisher.- Returns:
Publisherthat will emit all data written to thisPayloadWriterto itsPublisherSource.Subscriber. Only a single activePublisherSource.Subscriberis allowed for thisPublisher.
-
-