From 6966c5408a070ba9c0f1df3d970f581eb635cf31 Mon Sep 17 00:00:00 2001 From: David Montgomery Date: Thu, 17 Mar 2022 12:58:40 -0700 Subject: [PATCH] Fix binary compatibility. Recreated ClientState as wrapper around GrpcChannel to preserve compatibility with generated clients from previous versions. --- .../akka/grpc/internal/ClientState.scala | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 runtime/src/main/scala/akka/grpc/internal/ClientState.scala diff --git a/runtime/src/main/scala/akka/grpc/internal/ClientState.scala b/runtime/src/main/scala/akka/grpc/internal/ClientState.scala new file mode 100644 index 000000000..92f16dcd4 --- /dev/null +++ b/runtime/src/main/scala/akka/grpc/internal/ClientState.scala @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018-2021 Lightbend Inc. + */ + +package akka.grpc.internal + +import java.util.concurrent.CompletionStage + +import scala.concurrent.Future + +import akka.Done +import akka.actor.ClassicActorSystemProvider +import akka.annotation.{InternalApi, InternalStableApi} +import akka.event.LoggingAdapter +import akka.grpc.{GrpcChannel, GrpcClientSettings} + +/** + * INTERNAL API + * + * Deprecated: This class wraps a GrpcChannel for compatibility with clients generated by previous versions. + */ +@deprecated("Kept for binary compatibility between generated code and runtime", "akka-grpc 2.1.4") +@InternalApi +final class ClientState(channel: GrpcChannel)( + implicit sys: ClassicActorSystemProvider) { + + @InternalStableApi + val internalChannel: InternalChannel = + channel.internalChannel + + @InternalStableApi + def this(settings: GrpcClientSettings, log: LoggingAdapter)(implicit sys: ClassicActorSystemProvider) = + this(GrpcChannel(settings)) + + def closedCS(): CompletionStage[Done] = channel.closedCS() + def closeCS(): CompletionStage[Done] = channel.closeCS() + + def closed(): Future[Done] = channel.closed() + + def close(): Future[Done] = channel.close() +} + +/** + * INTERNAL API + * Used from generated code so can't be private. + * + * Thrown if a withChannel call is called after closing the internal channel + */ +@InternalApi +final class ClientClosedException() extends RuntimeException("withChannel called after close()")