Package io.servicetalk.oio.api
Interface PayloadWriter<T>
-
- Type Parameters:
T
- The type of Objects to write.
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
,java.io.Flushable
- All Known Subinterfaces:
GrpcPayloadWriter<T>
,HttpPayloadWriter<T>
- All Known Implementing Classes:
ConnectablePayloadWriter
public interface PayloadWriter<T> extends java.io.Closeable, java.io.Flushable
An interface which mimics behavior likeOutputStream
, but allows for writing of objects of typePayloadWriter
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close(java.lang.Throwable cause)
This method shares the same characteristics asCloseable.close()
but propagatescause
to downstream consumer instead of propagating "successful" completion.void
write(T t)
Write an object of typePayloadWriter
.
-
-
-
Method Detail
-
write
void write(T t) throws java.io.IOException
Write an object of typePayloadWriter
.- 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.
-
close
void close(java.lang.Throwable cause) throws java.io.IOException
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
write(Object)
are expected to fail - Before any exception is thrown, all resources must be reclaimed and
cause
propagated
- Parameters:
cause
- Indicate the close is a result of a failure.- Throws:
java.io.IOException
- if an input/output error occurs.
-
-