T
- type of the messagepublic abstract class DataMessageMarshaller<T> extends Object implements io.grpc.MethodDescriptor.Marshaller<T>, BufferRepository<T,DataBuffer>
Constructor and Description |
---|
DataMessageMarshaller(io.grpc.MethodDescriptor.Marshaller<T> originalMarshaller)
Creates a data marshaller.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the repository and all its buffers.
|
abstract T |
combineData(DataMessage<T,DataBuffer> message)
Combines the data buffer into the message.
|
protected abstract T |
deserialize(io.grpc.internal.ReadableBuffer buffer)
Deserialize data buffer to the message.
|
void |
offerBuffer(DataBuffer buffer,
T message)
Stores a buffer in the repository.
|
T |
parse(InputStream message) |
DataBuffer |
pollBuffer(T message)
Retrieves and removes a buffer from the store.
|
protected abstract io.netty.buffer.ByteBuf[] |
serialize(T message)
Serialize the message to buffers.
|
InputStream |
stream(T message) |
public DataMessageMarshaller(io.grpc.MethodDescriptor.Marshaller<T> originalMarshaller)
originalMarshaller
- the original marshaller for the messagepublic InputStream stream(T message)
stream
in interface io.grpc.MethodDescriptor.Marshaller<T>
public T parse(InputStream message)
parse
in interface io.grpc.MethodDescriptor.Marshaller<T>
public void close()
BufferRepository
close
in interface BufferRepository<T,DataBuffer>
close
in interface Closeable
close
in interface AutoCloseable
public void offerBuffer(DataBuffer buffer, T message)
BufferRepository
offerBuffer
in interface BufferRepository<T,DataBuffer>
buffer
- the buffer to storemessage
- the associated messagepublic DataBuffer pollBuffer(T message)
BufferRepository
pollBuffer
in interface BufferRepository<T,DataBuffer>
message
- the message that associated with the bufferpublic abstract T combineData(@Nullable DataMessage<T,DataBuffer> message)
message
- the message to be combinedprotected abstract io.netty.buffer.ByteBuf[] serialize(T message) throws IOException
message
- the message to be serializedByteBuf
s containing the serialized messageIOException
- if the marshaller fails to serialize the messageprotected abstract T deserialize(io.grpc.internal.ReadableBuffer buffer) throws IOException
buffer
- the buffer that contains the message dataIOException
- if the marshaller fails to deserialize the dataCopyright © 2023. All Rights Reserved.