Skip to content

Commit

Permalink
Fix binary compatibility.
Browse files Browse the repository at this point in the history
Recreated ClientState as wrapper around GrpcChannel to preserve
compatibility with generated clients from previous versions.
  • Loading branch information
drmontgomery committed Mar 17, 2022
1 parent 57308a4 commit 6966c54
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions runtime/src/main/scala/akka/grpc/internal/ClientState.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2018-2021 Lightbend Inc. <https://www.lightbend.com>
*/

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()")

0 comments on commit 6966c54

Please sign in to comment.