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>
,Closeable
,Flushable
,AutoCloseable
A
PayloadWriter
that can be connected
to a sink such that any data written on the
PayloadWriter
is eventually emitted to the connected Publisher
PublisherSource.Subscriber
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
This method shares the same characteristics asCloseable.close()
but propagatescause
to downstream consumer instead of propagating "successful" completion.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 an object of typePayloadWriter
.
-
Constructor Details
-
ConnectablePayloadWriter
public ConnectablePayloadWriter()
-
-
Method Details
-
write
Description copied from interface:PayloadWriter
Write an object of typePayloadWriter
.- Specified by:
write
in interfacePayloadWriter<T>
- Parameters:
t
- the object to write.- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if this has been closed.
-
flush
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
close
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:
IOException
- if an input/output error occurs.
-
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
.
-