Skip to content

Commit

Permalink
Fixed bug with fixed channel name
Browse files Browse the repository at this point in the history
  • Loading branch information
jendakol committed Sep 5, 2018
1 parent dd0f8a6 commit 7af95d5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/src/main/scala/com/avast/grpc/jsonbridge/Macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class Macros(val c: blackbox.Context) {
}
.getOrElse(c.abort(c.enclosingPosition, s"Could not extract SERVICE_NAME from $serviceImplBaseTypeParent"))

val channelName = UUID.randomUUID().toString

val stub = {
q" ${clientType.typeSymbol.owner}.newFutureStub(clientsChannel) "
}
Expand All @@ -60,8 +58,10 @@ class Macros(val c: blackbox.Context) {

private val serviceInstance: _root_.io.grpc.ServerServiceDefinition = { _root_.io.grpc.ServerInterceptors.intercept($getVariable, Seq[_root_.io.grpc.ServerInterceptor](..$interceptors): _*) }

private val clientsChannel: _root_.io.grpc.ManagedChannel = ${createClientsChannel(channelName)}
private val server: _root_.io.grpc.Server = ${startServer(channelName)}
private val channelName = _root_.java.util.UUID.randomUUID().toString

private val clientsChannel: _root_.io.grpc.ManagedChannel = ${createClientsChannel()}
private val server: _root_.io.grpc.Server = ${startServer()}

override protected def newFutureStub: $clientType = $stub

Expand Down Expand Up @@ -117,21 +117,21 @@ class Macros(val c: blackbox.Context) {
}
}

private def startServer(channelName: String): c.Tree = {
private def startServer(): c.Tree = {
q"""
_root_.io.grpc.inprocess.InProcessServerBuilder
.forName($channelName)
.forName(channelName)
.executor(executor)
.addService(serviceInstance)
.build
.start
"""
}

private def createClientsChannel(channelName: String): c.Tree = {
private def createClientsChannel(): c.Tree = {
q"""
_root_.io.grpc.inprocess.InProcessChannelBuilder
.forName($channelName)
.forName(channelName)
.executor(executor)
.build()
"""
Expand Down

0 comments on commit 7af95d5

Please sign in to comment.