Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix codegen for services with multiple RPCs #166

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class TwinagleServicePrinter(
s"""
|object $serviceName {
| implicit val asProtoService: $AsProtoService[$serviceName] = (service: $serviceName) => $ProtoService(Seq(
|${m.methods.map(protoRpc).mkString("\n")}
|${m.methods.map(protoRpc).mkString(",\n")}
| ))
|
| def server(service: $serviceName,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package proto.test;

message MMRequest {}

message MMResponse {}

service MultiMethod {
rpc Rpc1(MMRequest) returns (MMResponse);
rpc Rpc2(MMRequest) returns (MMResponse);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package proto.test

import com.twitter.util.Future
import com.soundcloud.twinagle.ServerBuilder

import org.specs2.mutable.Specification

class MultiMethodServiceSpec extends Specification {

// if this compiles, we're good
"ServerBuilder allows building services that contain multiple RPCs" in {
val svc = new MultiMethodService {
override def rpc1(req: MMRequest): Future[MMResponse] = Future.value(MMResponse())
override def rpc2(req: MMRequest): Future[MMResponse] = Future.value(MMResponse())
}


val httpService = ServerBuilder()
.register(svc)
.build

new MultiMethodClientProtobuf(httpService)
new MultiMethodClientJson(httpService)
ok
}
}