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- TheDeserializerto deserialize each individual item.deframerSupplier- Provides aFunctionfor eachsubscribewhich is invoked each time aBufferarrives. TheFunctionis expected to return the aBufferwith enough data that theDeserializercan deserialize, ornullif there isn't enough data.allocator- Used to allocateBuffers 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:PublisherOperatorImplementation of this operator. SeePublisherOperatorfor definition of an operator.- Specified by:
applyin interfaceFunction<PublisherSource.Subscriber<? super Iterable<T>>,PublisherSource.Subscriber<? super Buffer>> - Specified by:
applyin interfacePublisherOperator<Buffer,Iterable<T>> - Parameters:
subscriber-PublisherSource.Subscriberthat subscribed to this operator.- Returns:
PublisherSource.Subscriberthat is used to subscribe to thePublisherthat this operator is applied to.
-