-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix codegen for services with multiple RPCs (#166)
#132 introduced a bug that caused the code generator to emit bad code for services that expose multiple RPCs. This change fixes the error and adds a test case to avoid future regressions.
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
codegen/src/sbt-test/generator/e2e/src/main/protobuf/multi_method_service.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
26 changes: 26 additions & 0 deletions
26
codegen/src/sbt-test/generator/e2e/src/test/scala/proto/test/MultiMethodServiceSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |