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>
APayloadWriter
that can beconnected
to a sink such that any data written on thePayloadWriter
is eventually emitted to the connectedPublisher
PublisherSource.Subscriber
.
-
-
Constructor Summary
Constructors Constructor Description ConnectablePayloadWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
close(java.lang.Throwable cause)
This method shares the same characteristics asCloseable.close()
but propagatescause
to downstream consumer instead of propagating "successful" completion.Publisher<T>
connect()
Connects thisPayloadWriter
to the returnedPublisher
such that any data written to thisPayloadWriter
is eventually delivered to aPublisherSource.Subscriber
of the returnedPublisher
.void
flush()
void
write(T t)
Write an object of typePayloadWriter
.
-
-
-
Method Detail
-
write
public void write(T t) throws java.io.IOException
Description copied from interface:PayloadWriter
Write an object of typePayloadWriter
.- Specified by:
write
in interfacePayloadWriter<T>
- Parameters:
t
- the object to write.- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if this has been closed.
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
close
public void close(java.lang.Throwable cause) throws java.io.IOException
Description copied from interface:PayloadWriter
This method shares the same characteristics asCloseable.close()
but propagatescause
to 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
cause
propagated
- Specified by:
close
in 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 thisPayloadWriter
to the returnedPublisher
such that any data written to thisPayloadWriter
is eventually delivered to aPublisherSource.Subscriber
of the returnedPublisher
.- Returns:
Publisher
that will emit all data written to thisPayloadWriter
to itsPublisherSource.Subscriber
. Only a single activePublisherSource.Subscriber
is allowed for thisPublisher
.
-
-