-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow messages with the same name from different packages (#1643)
Fixes #1625 This allows messages with the same name but different packages to be used by the same service by prefixing the messages generated serializer names with the underscore separated package name if they came from if they come frome a different package to the package the service is declared in.
- Loading branch information
Showing
19 changed files
with
150 additions
and
19 deletions.
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
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
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
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
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
9 changes: 9 additions & 0 deletions
9
sbt-plugin/src/sbt-test/gen-java/05-duplicate-messages-different-packages/build.sbt
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,9 @@ | ||
// Can be removed when we move to 2.12.14 | ||
// https://github.com/akka/akka-grpc/pull/1279 | ||
scalaVersion := "2.12.16" | ||
|
||
resolvers += Resolver.sonatypeRepo("staging") | ||
|
||
enablePlugins(AkkaGrpcPlugin) | ||
|
||
akkaGrpcGeneratedLanguages := Seq(AkkaGrpc.Java) |
1 change: 1 addition & 0 deletions
1
...plugin/src/sbt-test/gen-java/05-duplicate-messages-different-packages/project/plugins.sbt
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 @@ | ||
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version")) |
18 changes: 18 additions & 0 deletions
18
...05-duplicate-messages-different-packages/src/main/java/helloworld/GreeterServiceImpl.java
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,18 @@ | ||
package helloworld; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
import akka.NotUsed; | ||
import akka.stream.javadsl.Source; | ||
import helloworld.Helloworld.*; | ||
|
||
class GreeterServiceImpl implements GreeterService { | ||
public CompletionStage<HelloReply> sayHello(HelloRequest request) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
public CompletionStage<HelloReply> sayHelloA(a.Other.HelloRequest request) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
public CompletionStage<HelloReply> sayHelloB(b.Other.HelloRequest request) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...bt-test/gen-java/05-duplicate-messages-different-packages/src/main/protobuf/a/other.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,3 @@ | ||
package a; | ||
|
||
message HelloRequest {} |
3 changes: 3 additions & 0 deletions
3
...bt-test/gen-java/05-duplicate-messages-different-packages/src/main/protobuf/b/other.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,3 @@ | ||
package b; | ||
|
||
message HelloRequest {} |
24 changes: 24 additions & 0 deletions
24
...test/gen-java/05-duplicate-messages-different-packages/src/main/protobuf/helloworld.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,24 @@ | ||
syntax = "proto3"; | ||
|
||
package helloworld; | ||
|
||
import "a/other.proto"; | ||
import "b/other.proto"; | ||
|
||
// The greeting service definition. | ||
service GreeterService { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
rpc SayHelloA (a.HelloRequest) returns (HelloReply) {} | ||
rpc SayHelloB (b.HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
3 changes: 3 additions & 0 deletions
3
sbt-plugin/src/sbt-test/gen-java/05-duplicate-messages-different-packages/test
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,3 @@ | ||
> compile | ||
|
||
$ exists target/scala-2.12/akka-grpc/main/helloworld/Helloworld.java |
7 changes: 7 additions & 0 deletions
7
sbt-plugin/src/sbt-test/gen-scala-server/11-duplicate-messages-different-packages/build.sbt
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,7 @@ | ||
// Can be removed when we move to 2.12.14 | ||
// https://github.com/akka/akka-grpc/pull/1279 | ||
scalaVersion := "2.12.16" | ||
|
||
resolvers += Resolver.sonatypeRepo("staging") | ||
|
||
enablePlugins(AkkaGrpcPlugin) |
1 change: 1 addition & 0 deletions
1
...rc/sbt-test/gen-scala-server/11-duplicate-messages-different-packages/project/plugins.sbt
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 @@ | ||
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version")) |
3 changes: 3 additions & 0 deletions
3
...gen-scala-server/11-duplicate-messages-different-packages/src/main/protobuf/a/other.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,3 @@ | ||
package a; | ||
|
||
message HelloRequest {} |
3 changes: 3 additions & 0 deletions
3
...gen-scala-server/11-duplicate-messages-different-packages/src/main/protobuf/b/other.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,3 @@ | ||
package b; | ||
|
||
message HelloRequest {} |
24 changes: 24 additions & 0 deletions
24
...-scala-server/11-duplicate-messages-different-packages/src/main/protobuf/helloworld.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,24 @@ | ||
syntax = "proto3"; | ||
|
||
package helloworld; | ||
|
||
import "a/other.proto"; | ||
import "b/other.proto"; | ||
|
||
// The greeting service definition. | ||
service GreeterService { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
rpc SayHelloA (a.HelloRequest) returns (HelloReply) {} | ||
rpc SayHelloB (b.HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
12 changes: 12 additions & 0 deletions
12
...-duplicate-messages-different-packages/src/main/scala/helloworld/GreeterServiceImpl.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,12 @@ | ||
package helloworld | ||
|
||
import scala.concurrent.Future | ||
|
||
import akka.NotUsed | ||
import akka.stream.scaladsl.Source | ||
|
||
class GreeterServiceImpl extends GreeterService { | ||
override def sayHello(in: HelloRequest): Future[HelloReply] = ??? | ||
override def sayHelloA(in: a.HelloRequest): Future[HelloReply] = ??? | ||
override def sayHelloB(in: b.HelloRequest): Future[HelloReply] = ??? | ||
} |
6 changes: 6 additions & 0 deletions
6
sbt-plugin/src/sbt-test/gen-scala-server/11-duplicate-messages-different-packages/test
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,6 @@ | ||
> compile | ||
|
||
$ exists target/scala-2.12/akka-grpc | ||
$ exists target/scala-2.12/akka-grpc/main/helloworld/HelloRequest.scala | ||
$ exists target/scala-2.12/akka-grpc/main/helloworld/HelloworldProto.scala | ||
$ exists target/scala-2.12/akka-grpc/main/helloworld/GreeterService.scala |