Skip to content

Commit

Permalink
Deprecate public gRPC API that is not used anymore by ST (#2300)
Browse files Browse the repository at this point in the history
Motivation:

#1893 removed support of gRPC Filters and stopped using some of the
public/protected API that were targeted for filters. Some of these APIs
were not marked as `@Deprecated` and were not removed before 0.42
release.

Modifications:

- Mark `GrpcRoutes#registerRoutes` and `GrpcRoutes#newServiceFromRoutes`
methods as deprecated;
- Mark `GrpcRoutes.AllGrpcRoutes` interface as deprecated;
- Add reminding `FIXME` comments to make sure we remove all deprecations
in 0.43;

Result:

Unused code is marked as deprecated and can be removed in the next
release.
  • Loading branch information
idelpivnitskiy authored Jul 29, 2022
1 parent 44c4343 commit 908a84f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public final BlockingClient newBlockingClientForCallFactory(GrpcClientCallFactor
*/
@Deprecated
public GrpcClientFactory<Client, BlockingClient>
supportedMessageCodings(List<ContentCodec> codings) {
supportedMessageCodings(List<ContentCodec> codings) { // FIXME: 0.43 - remove deprecated method
this.supportedCodings = unmodifiableList(new ArrayList<>(codings));
return this;
}
Expand All @@ -91,7 +91,7 @@ public final BlockingClient newBlockingClientForCallFactory(GrpcClientCallFactor
* {@link io.servicetalk.encoding.api.BufferEncoder}s and {@link io.servicetalk.encoding.api.BufferDecoderGroup}.
*/
@Deprecated
protected List<ContentCodec> supportedMessageCodings() {
protected List<ContentCodec> supportedMessageCodings() { // FIXME: 0.43 - remove deprecated method
return supportedCodings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
*/
public final class GrpcExecutionStrategies {

private static final GrpcExecutionStrategy NEVER_OFFLOAD_STRATEGY =
@Deprecated
private static final GrpcExecutionStrategy NEVER_OFFLOAD_STRATEGY = // FIXME: 0.43 - remove deprecated constant
new DefaultGrpcExecutionStrategy(HttpExecutionStrategies.offloadNever()) {
@Override
public HttpExecutionStrategy merge(final HttpExecutionStrategy other) {
return this;
}
};

// FIXME: 0.43 - remove deprecated method
@Deprecated
private static final GrpcExecutionStrategy DEFAULT_GRPC_EXECUTION_STRATEGY =
new DefaultGrpcExecutionStrategy(HttpExecutionStrategies.defaultStrategy()) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,24 @@ final Single<GrpcServerContext> bind(final ServerBinder binder, final GrpcExecut
* Register all routes contained in the passed {@link Service}.
*
* @param service {@link Service} for which routes have to be registered.
* @deprecated This method is not used starting from version 0.42.0 (see
* <a href="https://github.com/apple/servicetalk/pull/1893">PR#1893</a>), we plan to remove it in future releases.
* In case you have a use-case, let us know.
*/
protected abstract void registerRoutes(Service service);
@Deprecated
protected abstract void registerRoutes(Service service); // FIXME: 0.43 - remove deprecated method

/**
* Create a new {@link Service} from the passed {@link AllGrpcRoutes}.
*
* @param routes {@link AllGrpcRoutes} for which a {@link Service} has to be created.
* @return {@link Service} containing all the passed routes.
* @deprecated This method is not used starting from version 0.42.0 (see
* <a href="https://github.com/apple/servicetalk/pull/1893">PR#1893</a>), we plan to remove it in future releases.
* In case you have a use-case, let us know.
*/
protected abstract Service newServiceFromRoutes(AllGrpcRoutes routes);
@Deprecated
protected abstract Service newServiceFromRoutes(AllGrpcRoutes routes); // FIXME: 0.43 - remove deprecated method

static GrpcRoutes<?> merge(GrpcRoutes<?>... allRoutes) {
final GrpcRouter.Builder[] builders = new GrpcRouter.Builder[allRoutes.length];
Expand All @@ -127,11 +135,13 @@ static GrpcRoutes<?> merge(GrpcRoutes<?>... allRoutes) {
errors.addAll(allRoutes[i].errors);
}
return new GrpcRoutes<GrpcService>(GrpcRouter.Builder.merge(builders), errors) {
@Deprecated
@Override
protected void registerRoutes(final GrpcService service) {
throw new UnsupportedOperationException("Merged service factory can not register routes.");
}

@Deprecated
@Override
protected GrpcService newServiceFromRoutes(final AllGrpcRoutes routes) {
throw new UnsupportedOperationException("Merged service factory can not create new service.");
Expand Down Expand Up @@ -168,7 +178,7 @@ private GrpcExecutionStrategy executionStrategy(final String path, final Method
* @deprecated Use {@link #addRoute(Class, MethodDescriptor, BufferDecoderGroup, List, Route)}.
*/
@Deprecated
protected final <Req, Resp> void addRoute(
protected final <Req, Resp> void addRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName, final Route<Req, Resp> route,
final Class<Req> requestClass, final Class<Resp> responseClass,
final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -214,7 +224,7 @@ protected final <Req, Resp> void addRoute(
* @deprecated Use {@link #addRoute(GrpcExecutionStrategy, MethodDescriptor, BufferDecoderGroup, List, Route)}.
*/
@Deprecated
protected final <Req, Resp> void addRoute(
protected final <Req, Resp> void addRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy, final Route<Req, Resp> route,
final Class<Req> requestClass, final Class<Resp> responseClass,
final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -257,7 +267,7 @@ protected final <Req, Resp> void addRoute(
* @deprecated Use {@link #addStreamingRoute(Class, MethodDescriptor, BufferDecoderGroup, List, StreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addStreamingRoute(
protected final <Req, Resp> void addStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final StreamingRoute<Req, Resp> route, final Class<Req> requestClass, final Class<Resp> responseClass,
final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -304,7 +314,7 @@ protected final <Req, Resp> void addStreamingRoute(
* StreamingRoute)}
*/
@Deprecated
protected final <Req, Resp> void addStreamingRoute(
protected final <Req, Resp> void addStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy,
final StreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -348,7 +358,7 @@ protected final <Req, Resp> void addStreamingRoute(
* {@link #addRequestStreamingRoute(Class, MethodDescriptor, BufferDecoderGroup, List, RequestStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addRequestStreamingRoute(
protected final <Req, Resp> void addRequestStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final RequestStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -397,7 +407,7 @@ protected final <Req, Resp> void addRequestStreamingRoute(
* RequestStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addRequestStreamingRoute(
protected final <Req, Resp> void addRequestStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy,
final RequestStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -442,7 +452,7 @@ protected final <Req, Resp> void addRequestStreamingRoute(
* {@link #addResponseStreamingRoute(Class, MethodDescriptor, BufferDecoderGroup, List, ResponseStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addResponseStreamingRoute(
protected final <Req, Resp> void addResponseStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final ResponseStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -491,7 +501,7 @@ protected final <Req, Resp> void addResponseStreamingRoute(
* ResponseStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addResponseStreamingRoute(
protected final <Req, Resp> void addResponseStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy,
final ResponseStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -535,7 +545,7 @@ protected final <Req, Resp> void addResponseStreamingRoute(
* @deprecated Use {@link #addBlockingRoute(Class, MethodDescriptor, BufferDecoderGroup, List, BlockingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingRoute(
protected final <Req, Resp> void addBlockingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final BlockingRoute<Req, Resp> route, final Class<Req> requestClass, final Class<Resp> responseClass,
final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -583,7 +593,7 @@ protected final <Req, Resp> void addBlockingRoute(
* BlockingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingRoute(
protected final <Req, Resp> void addBlockingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy, final BlockingRoute<Req, Resp> route,
final Class<Req> requestClass, final Class<Resp> responseClass,
final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -628,7 +638,7 @@ protected final <Req, Resp> void addBlockingRoute(
* {@link #addBlockingStreamingRoute(Class, MethodDescriptor, BufferDecoderGroup, List, BlockingStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingStreamingRoute(
protected final <Req, Resp> void addBlockingStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final BlockingStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -677,7 +687,7 @@ protected final <Req, Resp> void addBlockingStreamingRoute(
* BlockingStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingStreamingRoute(
protected final <Req, Resp> void addBlockingStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy,
final BlockingStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -722,7 +732,7 @@ protected final <Req, Resp> void addBlockingStreamingRoute(
* {@link #addBlockingStreamingRoute(Class, MethodDescriptor, BufferDecoderGroup, List, BlockingStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingRequestStreamingRoute(
protected final <Req, Resp> void addBlockingRequestStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final BlockingRequestStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -771,7 +781,7 @@ protected final <Req, Resp> void addBlockingRequestStreamingRoute(
* BlockingRequestStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingRequestStreamingRoute(
protected final <Req, Resp> void addBlockingRequestStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy,
final BlockingRequestStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -818,7 +828,7 @@ protected final <Req, Resp> void addBlockingRequestStreamingRoute(
* BlockingResponseStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingResponseStreamingRoute(
protected final <Req, Resp> void addBlockingResponseStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final Class<?> serviceClass, final String methodName,
final BlockingResponseStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -867,7 +877,7 @@ protected final <Req, Resp> void addBlockingResponseStreamingRoute(
* BlockingResponseStreamingRoute)}.
*/
@Deprecated
protected final <Req, Resp> void addBlockingResponseStreamingRoute(
protected final <Req, Resp> void addBlockingResponseStreamingRoute(// FIXME: 0.43 - remove deprecated method
final String path, final GrpcExecutionStrategy executionStrategy,
final BlockingResponseStreamingRoute<Req, Resp> route, final Class<Req> requestClass,
final Class<Resp> responseClass, final GrpcSerializationProvider serializationProvider) {
Expand Down Expand Up @@ -1358,8 +1368,13 @@ public void closeGracefully() throws Exception {

/**
* A collection of route corresponding to the enclosing {@link GrpcRoutes}.
*
* @deprecated This class is not used starting from version 0.42.0 (see
* <a href="https://github.com/apple/servicetalk/pull/1893">PR#1893</a>), we plan to remove it in future releases.
* In case you have a use-case, let us know.
*/
protected interface AllGrpcRoutes extends AsyncCloseable {
@Deprecated
protected interface AllGrpcRoutes extends AsyncCloseable { // FIXME: 0.43 - remove deprecated interface

/**
* Returns the registered {@link StreamingRoute} for the passed {@code path}. If a route with a different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
@FunctionalInterface
@Deprecated
public interface GrpcServiceFilterFactory<Filter extends Service, Service> {
public interface GrpcServiceFilterFactory<Filter extends Service, Service> { // FIXME: 0.43-remove deprecated interface

/**
* Create a {@link Filter} using the provided {@link Service}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,10 @@ private TypeSpec.Builder addServiceFactory(final State state, final TypeSpec.Bui
.returns(state.serviceFactoryClass)
.addStatement("return new $T(this)", state.serviceFactoryClass)
.build())
.addMethod(methodBuilder("newServiceFromRoutes")
.addMethod(methodBuilder("newServiceFromRoutes") // FIXME: 0.43 - remove deprecated method
.addModifiers(PROTECTED)
.addAnnotation(Override.class)
.addAnnotation(Deprecated.class)
.returns(serviceFromRoutesClass)
.addParameter(AllGrpcRoutes, routes, FINAL)
.addStatement("return new $T($L)", serviceFromRoutesClass, routes)
Expand Down Expand Up @@ -632,6 +633,7 @@ private TypeSpec.Builder addServiceFactory(final State state, final TypeSpec.Bui
final MethodSpec.Builder registerRoutesMethodSpecBuilder = methodBuilder(registerRoutes)
.addModifiers(PROTECTED)
.addAnnotation(Override.class)
.addAnnotation(Deprecated.class) // FIXME: 0.43 - remove deprecated method
.addParameter(state.serviceClass, service, FINAL);

state.serviceProto.getMethodList().stream()
Expand Down Expand Up @@ -997,12 +999,14 @@ private TypeSpec.Builder addClientFactory(final State state, final TypeSpec.Buil
return serviceClassBuilder;
}

// FIXME: 0.43 - remove deprecated class
private TypeSpec newServiceFromRoutesClassSpec(final ClassName serviceFromRoutesClass,
final List<RpcInterface> rpcInterfaces,
final ClassName serviceClass) {
final TypeSpec.Builder serviceFromRoutesSpecBuilder = classBuilder(serviceFromRoutesClass)
.addModifiers(PRIVATE, STATIC, FINAL)
.addSuperinterface(serviceClass)
.addAnnotation(Deprecated.class)
.addField(AsyncCloseable, closeable, PRIVATE, FINAL);

final MethodSpec.Builder serviceFromRoutesConstructorBuilder = constructorBuilder()
Expand Down

0 comments on commit 908a84f

Please sign in to comment.