gorros
gorros

Reputation: 1461

Unable to build gRPC ManagedChannel with scala

I try to create a gRPC client. For

val channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build

I get this compile time error

Error:(18, 87) value build is not a member of ?0
    val channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build

gRPC is built for Java. My project is multi-module maven project, where for protobuf files and generated code is in a separate module.

Upvotes: 2

Views: 1451

Answers (2)

gorros
gorros

Reputation: 1461

I managed to solve this issue by adding redundant casting

 val channel = ManagedChannelBuilder
    .forAddress(host, port)
    .usePlaintext(true)
    .asInstanceOf[ManagedChannelBuilder[_]].build

Upvotes: 7

nickburris
nickburris

Reputation: 11

Did you try '.build()'? I'm not too familiar with scala but perhaps the parentheses are required for a library written in Java. If it's recognizing up to usePlaintext, then .build() should indeed be valid for the returned ManagedChannelBuilder: http://www.grpc.io/grpc-java/javadoc/io/grpc/ManagedChannelBuilder.html#build--

Upvotes: 0

Related Questions