Package io.servicetalk.serializer.utils
Class FramedDeserializerOperator<T>
java.lang.Object
io.servicetalk.serializer.utils.FramedDeserializerOperator<T>
- Type Parameters:
T
- The type to serialize/deserialize.
- All Implemented Interfaces:
PublisherOperator<Buffer,
,Iterable<T>> Function<PublisherSource.Subscriber<? super Iterable<T>>,
PublisherSource.Subscriber<? super Buffer>>
public final class FramedDeserializerOperator<T>
extends Object
implements PublisherOperator<Buffer,Iterable<T>>
Utility which helps implementations of
StreamingDeserializer
leverage a Deserializer
and apply a
framing to define the boundaries of each object.-
Constructor Summary
ConstructorsConstructorDescriptionFramedDeserializerOperator
(Deserializer<T> deserializer, Supplier<BiFunction<Buffer, BufferAllocator, Buffer>> deframerSupplier, BufferAllocator allocator) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionPublisherSource.Subscriber<? super Buffer>
apply
(PublisherSource.Subscriber<? super Iterable<T>> subscriber) Implementation of this operator.
-
Constructor Details
-
FramedDeserializerOperator
public FramedDeserializerOperator(Deserializer<T> deserializer, Supplier<BiFunction<Buffer, BufferAllocator, Buffer>> deframerSupplier, BufferAllocator allocator) Create a new instance.- Parameters:
deserializer
- TheDeserializer
to deserialize each individual item.deframerSupplier
- Provides aFunction
for eachsubscribe
which is invoked each time aBuffer
arrives. TheFunction
is expected to return the aBuffer
with enough data that theDeserializer
can deserialize, ornull
if there isn't enough data.allocator
- Used to allocateBuffer
s to aggregate data across deserialization calls if necessary.
-
-
Method Details
-
apply
public PublisherSource.Subscriber<? super Buffer> apply(PublisherSource.Subscriber<? super Iterable<T>> subscriber) Description copied from interface:PublisherOperator
Implementation of this operator. SeePublisherOperator
for definition of an operator.- Specified by:
apply
in interfaceFunction<PublisherSource.Subscriber<? super Iterable<T>>,
PublisherSource.Subscriber<? super Buffer>> - Specified by:
apply
in interfacePublisherOperator<Buffer,
Iterable<T>> - Parameters:
subscriber
-PublisherSource.Subscriber
that subscribed to this operator.- Returns:
PublisherSource.Subscriber
that is used to subscribe to thePublisher
that this operator is applied to.
-