Package io.servicetalk.grpc.protobuf
Class ProtoBufSerializationProviderBuilder
- java.lang.Object
-
- io.servicetalk.grpc.protobuf.ProtoBufSerializationProviderBuilder
-
public final class ProtoBufSerializationProviderBuilder extends java.lang.ObjectA builder for building aGrpcSerializationProviderthat can serialize and deserialize pre-registered protocol buffer objects.registerMessageType(Class, Parser)is used to add one or moreMessageLitemessage types. ResultingGrpcSerializationProviderfrombuild()will only serialize and deserialize those message types.
-
-
Constructor Summary
Constructors Constructor Description ProtoBufSerializationProviderBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GrpcSerializationProviderbuild()Builds a newGrpcSerializationProvidercontaining all the message types registered with this builder.<T extends com.google.protobuf.MessageLite>
ProtoBufSerializationProviderBuilderregisterMessageType(java.lang.Class<T> messageType, com.google.protobuf.Parser<T> parser)Register the passedmessageTypewith the providedParser.<T extends com.google.protobuf.MessageLite>
ProtoBufSerializationProviderBuildersupportedMessageCodings(java.util.List<ContentCodec> supportedCodings)Set the supported message encodings for the serializers and deserializers.
-
-
-
Method Detail
-
supportedMessageCodings
public <T extends com.google.protobuf.MessageLite> ProtoBufSerializationProviderBuilder supportedMessageCodings(java.util.List<ContentCodec> supportedCodings)
Set the supported message encodings for the serializers and deserializers. The encodings will be advertised on the endpoint's headers and also used to validate each encoded messageIdentity.identity()is always supported regardless of the config passed- Type Parameters:
T- Type ofMessageLiteto register.- Parameters:
supportedCodings- the set of allowed encodings- Returns:
this
-
registerMessageType
public <T extends com.google.protobuf.MessageLite> ProtoBufSerializationProviderBuilder registerMessageType(java.lang.Class<T> messageType, com.google.protobuf.Parser<T> parser)
Register the passedmessageTypewith the providedParser.- Type Parameters:
T- Type ofMessageLiteto register.- Parameters:
messageType-Classof the type of message to register.parser-Parserfor this message type.- Returns:
this
-
build
public GrpcSerializationProvider build()
Builds a newGrpcSerializationProvidercontaining all the message types registered with this builder.- Returns:
- New
GrpcSerializationProviderthat will serialize and deserialize message types that were registered to this builder.
-
-