You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New Serializer APIs, consolidation of ContentCodec, and gRPC MethodDescriptor (#1673)
Motivation:
Supporting a custom transport for gRPC currently requires
reflection and special knowledge of types for serialization. The
generated code has information related to types and serialization that
can be exposed to the runtime which also allows supporting custom
transports.
This task requires exposing serializer APIs into the public
API. Our existing serializer APIs were heavily influced by streaming use
cases and JSON serialization which can serialize any type and generally
doesn't have type restrictions. This lead to a general
SerializationProvider API which is impossible to constrain types due to
the generics being at the method level, which doesn't account for
implementing serialization for type constrained approached (protobuf
MessageLite). Also the serialization APIs couple scalar and streaming
use cases which in practice are more commonly decoupled into scalar
(individual objects) and streaming (which applies some framing around
individual objects). These concepts are coupled which leads to confusing
specializations (deserializeAggregatedSingle, deserializeAggregated)
which are easy to misuse and lead to invalid serialization in practice
(streaming {form url, string} encoding are not properly framed and may
not be deserialized correctly). The existing Serializer APIs also do not
promote composability in that if you can serialize one object you should
be able to re-use that serialization for a stream of objects with some
frameing applied on top (required for gRPC).
Modifications:
- Introduce a new servicetalk-serializer-api package with new
Serializer APIs.
- Introduce a new servicetalk-serializer-utils package with common
utilities for serialization such as streaming framing (fixed and
varint length prefixed)
- Introduce BufferEncoder APIs in servicetalk-encoding-api for
compression and decompression. This also comes with
NettyBufferEncoders and NettyCompression to create Netty backed
implementations.
- Introduce HttpStreamingSerializer and new HttpSerializer APIs in
servicetalk-http-api, and modify all request/response APIs to use the
new serializer APIs. Introduce new methods to deserialize and process
trailers.
- Introduce HttpSerializers in servicetalk-http-api for implementations
of the new APIs.
- Introduce JacksonSerializerCache in servicetalk-http-api as the new
entry point to create/cache serializers for JSON.
- Introduce ProtobufSerializerCache in servicetalk-data-protobuf as the
new entry point to create/cache serializers for protobuf.
- Introduce MethodDescriptor API into servicetalk-grpc-api and update
code generation to use this new API.
- Update all examples avoid usage of deprecated APIs and leverage new
APIs.
- Deprecate the following APIs and related methods in favor of the new
types descrbied above:
- SerializationProvider, JacksonSerializationProvider,
ProtobufSerializationProvider, GrpcSerializationProvider,
HttpSerializationProvider
- ContentCodec, CodecDecodingException, CodecEncodingException,
ContentCodings
- GrpcMetadata#path(), code generated types that extend
DefaultGrpcClientMetadata
Result:
gRPC API supports MethodDescriptor, which uses new Serializer APIs, and
the entire code base has been updated to use the new APIs consistently.
Copy file name to clipboardExpand all lines: servicetalk-data-jackson-jersey/src/main/java/io/servicetalk/data/jackson/jersey/JacksonSerializationProviderContextResolver.java
+4
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,10 @@
20
20
importjavax.annotation.Nullable;
21
21
importjavax.ws.rs.ext.ContextResolver;
22
22
23
+
/**
24
+
* @deprecated Use {@link JacksonSerializerFactoryContextResolver}.
Copy file name to clipboardExpand all lines: servicetalk-data-jackson-jersey/src/main/java/io/servicetalk/data/jackson/jersey/JacksonSerializerMessageBodyReaderWriter.java
0 commit comments