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

Switch to Play 3 and Pekko #490

Merged
merged 6 commits into from
Dec 21, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![OpenCollective](https://img.shields.io/opencollective/all/playframework?label=financial%20contributors&logo=open-collective)](https://opencollective.com/playframework)

[![Build Status](https://github.com/playframework/play-grpc/actions/workflows/build-test.yml/badge.svg)](https://github.com/playframework/play-grpc/actions/workflows/build-test.yml)
[![Maven](https://img.shields.io/maven-central/v/com.typesafe.play/play-grpc-runtime_2.13.svg?logo=apache-maven)](https://mvnrepository.com/artifact/com.typesafe.play/play-grpc-runtime_2.13)
[![Maven](https://img.shields.io/maven-central/v/org.playframework/play-grpc-runtime_2.13.svg?logo=apache-maven)](https://mvnrepository.com/artifact/org.playframework/play-grpc-runtime_2.13)
[![Repository size](https://img.shields.io/github/repo-size/playframework/play-grpc.svg?logo=git)](https://github.com/playframework/play-grpc)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
[![Mergify Status](https://img.shields.io/endpoint.svg?url=https://api.mergify.com/v1/badges/playframework/play-grpc&style=flat)](https://mergify.com)
Expand Down
71 changes: 35 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import build.play.grpc.ProjectExtensions.AddPluginTest
// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
(ThisBuild / dynverVTagPrefix) := false

ThisBuild / organization := "com.typesafe.play"
ThisBuild / organization := "org.playframework"

ThisBuild / scalacOptions ++= List(
"-encoding",
Expand All @@ -29,7 +29,7 @@ ThisBuild / javacOptions ++= List(
"-Xlint:deprecation",
)

// Only needed for akka, akka-grpc ,... snapshots
// Only needed for snapshots
// See also projects/plugins.sbt
//ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots")

Expand All @@ -52,13 +52,12 @@ crossScalaVersions := Nil // https://github.com/sbt/sbt/i
val playRuntime = Project("play-grpc-runtime", file("play-runtime"))
.settings(
libraryDependencies ++= Seq(
Dependencies.Compile.akkaGrpcRuntime,
Dependencies.Compile.pekkoGrpcRuntime,
Dependencies.Compile.play,
Dependencies.Compile.playAkkaHttpServer,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.akkaHttp,
Dependencies.Compile.akkaHttp2Support,
Dependencies.Compile.akkaHttpSprayJson,
Dependencies.Compile.playPekkoHttpServer,
Dependencies.Compile.pekkoDiscovery,
Dependencies.Compile.pekkoHttp,
Dependencies.Compile.pekkoHttpSprayJson,
),
)

Expand All @@ -68,7 +67,7 @@ val playTestdata = Project("play-grpc-testdata", file("play-testdata"))
scalacOptions += "-Xlint:-unused,_", // can't do anything about unused things in generated code
javacOptions -= "-Xlint:deprecation", // can't do anything about deprecations in generated code
ReflectiveCodeGen.extraGenerators ++= List(
"akka.grpc.gen.scaladsl.ScalaMarshallersCodeGenerator",
"org.apache.pekko.grpc.gen.scaladsl.ScalaMarshallersCodeGenerator",
"play.grpc.gen.javadsl.PlayJavaClientCodeGenerator",
"play.grpc.gen.javadsl.PlayJavaServerCodeGenerator",
"play.grpc.gen.scaladsl.PlayScalaClientCodeGenerator",
Expand All @@ -77,9 +76,9 @@ val playTestdata = Project("play-grpc-testdata", file("play-testdata"))
libraryDependencies ++= Seq(
Dependencies.Compile.play,
Dependencies.Compile.grpcStub,
Dependencies.Compile.playAkkaHttpServer,
Dependencies.Compile.playAkkaHttp2Support,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.playPekkoHttpServer,
Dependencies.Compile.playPekkoHttp2Support,
Dependencies.Compile.pekkoDiscovery,
),
)
.enablePlugins(build.play.grpc.NoPublish)
Expand All @@ -96,9 +95,9 @@ val playActionsTestData = Project("play-grpc-actions-testdata", file("play-actio
libraryDependencies ++= Seq(
Dependencies.Compile.play,
Dependencies.Compile.grpcStub,
Dependencies.Compile.playAkkaHttpServer,
Dependencies.Compile.playAkkaHttp2Support,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.playPekkoHttpServer,
Dependencies.Compile.playPekkoHttp2Support,
Dependencies.Compile.pekkoDiscovery,
),
)
.enablePlugins(build.play.grpc.NoPublish)
Expand All @@ -108,12 +107,12 @@ val playGenerators = Project(id = "play-grpc-generators", file("play-generators"
.enablePlugins(SbtTwirl, BuildInfoPlugin)
.settings(
libraryDependencies ++= Seq(
Dependencies.Compile.akkaGrpcCodegen,
Dependencies.Compile.pekkoGrpcCodegen,
Dependencies.Test.scalaTest,
),
buildInfoKeys ++= Seq[BuildInfoKey](organization, name, version, scalaVersion, sbtVersion),
buildInfoKeys += "akkaGrpcVersion" → Dependencies.Versions.akkaGrpc,
buildInfoPackage := "play.grpc.gen",
buildInfoKeys += "pekkoGrpcVersion" → Dependencies.Versions.pekkoGrpc,
buildInfoPackage := "play.grpc.gen",
// Only used in build tools (like sbt), so only 2.12 is needed:
crossScalaVersions := Seq(scala212),
scalaVersion := scala212,
Expand All @@ -126,10 +125,10 @@ val playTestkit = Project("play-grpc-testkit", file("play-testkit"))
Dependencies.Compile.play,
Dependencies.Compile.playTest,
Dependencies.Test.playAhcWs,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.akkaActorTyped,
Dependencies.Compile.akkaStream,
Dependencies.Compile.akkaSerializationJackson,
Dependencies.Compile.pekkoDiscovery,
Dependencies.Compile.pekkoActorTyped,
Dependencies.Compile.pekkoStream,
Dependencies.Compile.pekkoSerializationJackson,
),
)
.pluginTestingSettings
Expand All @@ -139,10 +138,10 @@ val playSpecs2 = Project("play-grpc-specs2", file("play-specs2"))
.settings(
libraryDependencies ++= Seq(
Dependencies.Compile.playSpecs2,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.akkaActorTyped,
Dependencies.Compile.akkaStream,
Dependencies.Compile.akkaSerializationJackson,
Dependencies.Compile.pekkoDiscovery,
Dependencies.Compile.pekkoActorTyped,
Dependencies.Compile.pekkoStream,
Dependencies.Compile.pekkoSerializationJackson,
),
)
.pluginTestingSettings
Expand All @@ -157,9 +156,9 @@ val playScalaTest = Project("play-grpc-scalatest", file("play-scalatest"))
},
libraryDependencies ++= Seq(
Dependencies.Compile.scalaTestPlusPlay,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.akkaActorTyped,
Dependencies.Compile.akkaStream,
Dependencies.Compile.pekkoDiscovery,
Dependencies.Compile.pekkoActorTyped,
Dependencies.Compile.pekkoStream,
),
)
.pluginTestingSettings
Expand All @@ -168,7 +167,7 @@ val playInteropTestScala = Project("play-grpc-interop-test-scala", file("play-in
.dependsOn(playRuntime, playSpecs2 % Test, playScalaTest % Test)
.settings(
ReflectiveCodeGen.extraGenerators ++= List(
"akka.grpc.gen.scaladsl.ScalaMarshallersCodeGenerator",
"org.apache.pekko.grpc.gen.scaladsl.ScalaMarshallersCodeGenerator",
"play.grpc.gen.scaladsl.PlayScalaClientCodeGenerator",
"play.grpc.gen.scaladsl.PlayScalaServerCodeGenerator",
),
Expand All @@ -177,9 +176,9 @@ val playInteropTestScala = Project("play-grpc-interop-test-scala", file("play-in
Dependencies.Compile.grpcStub,
Dependencies.Compile.play,
Dependencies.Compile.playGuice,
Dependencies.Compile.playAkkaHttpServer,
Dependencies.Compile.playAkkaHttp2Support,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.playPekkoHttpServer,
Dependencies.Compile.playPekkoHttp2Support,
Dependencies.Compile.pekkoDiscovery,
Dependencies.Test.junit,
Dependencies.Test.playSpecs2,
Dependencies.Test.scalaTest,
Expand All @@ -201,10 +200,10 @@ val playInteropTestJava = Project("play-grpc-interop-test-java", file("play-inte
Dependencies.Compile.grpcStub,
Dependencies.Compile.play,
Dependencies.Compile.playGuice,
Dependencies.Compile.playAkkaHttpServer,
Dependencies.Compile.playAkkaHttp2Support,
Dependencies.Compile.playPekkoHttpServer,
Dependencies.Compile.playPekkoHttp2Support,
Dependencies.Compile.playJava,
Dependencies.Compile.akkaDiscovery,
Dependencies.Compile.pekkoDiscovery,
Dependencies.Test.junit,
Dependencies.Test.scalaTest,
),
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ nav:
- modules/ROOT/nav.adoc
asciidoc:
attributes:
akka-grpc-version: 2.1.5 # Sync with `sbt-akka-grpc` in project/plugins.sbt
pekko-grpc-version: 1.0.1 # Sync with `sbt-pekko-grpc` in project/plugins.sbt
6 changes: 3 additions & 3 deletions docs/modules/ROOT/pages/consuming-grpc.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
== Using a gRPC client in Play
:tabs-sync-option:

Akka gRPC has special support to allow for seamless injection of generated clients in Play. To enable this, you
Pekko gRPC has special support to allow for seamless injection of generated clients in Play. To enable this, you
need first to enable the gRPC plugin as described in the https://doc.akka.io/docs/akka-grpc/current/client/walkthrough.html[client docs] and then add a source generator in `build.sbt`:

[tabs]
Expand Down Expand Up @@ -33,8 +33,8 @@ You can then put the following `helloworld.proto` file in `app/protobuf`:
include::example$play-interop-test-scala/src/main/proto/helloworld.proto[tags=protoSources]
----

The module file is generated in `example.myapp.helloworld.grpc.helloworld.AkkaGrpcClientModule` by default for Scala
(or `example.myapp.helloworld.grpc.AkkaGrpcClientModule` by default for Java), which corresponds to the default value
The module file is generated in `example.myapp.helloworld.grpc.helloworld.PekkoGrpcClientModule` by default for Scala
(or `example.myapp.helloworld.grpc.PekkoGrpcClientModule` by default for Java), which corresponds to the default value
of `flat_package` for Java/Scala. You can read more about this in https://doc.akka.io/docs/akka-grpc/current/proto.html[Services].

The exact package of the module will be based on the package the proto files are generated in, configured through
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/gradle-support.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
== Gradle support in Play

To enable the Play support in a Gradle project you need to set the option `generatePlay` to true.
This will make sure play-specific code is generated in addition to plain Akka gRPC code:
This will make sure play-specific code is generated in addition to plain Pekko gRPC code:

[,groovy]
----
Expand All @@ -16,4 +16,4 @@ akkaGrpc {
}
----

See the https://doc.akka.io/docs/akka-grpc/current/buildtools/gradle.html[Akka gRPC Gradle support docs] for further details.
See the https://pekko.apache.org/docs/pekko-grpc/current/buildtools/gradle.html[Pekko gRPC Gradle support docs] for further details.
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= Play gRPC

https://doc.akka.io/docs/akka-grpc/current/[Akka gRPC] provides support for building streaming gRPC servers and clients on top of Akka Streams. Play gRPC provides examples and tools on embedding Akka gRPC endpoints on Play applications.
https://pekko.apache.org/docs/pekko-grpc/current/index.html[Pekko gRPC] provides support for building streaming gRPC servers and clients on top of Pekko Streams. Play gRPC provides examples and tools on embedding Pekko gRPC endpoints on Play applications.

For a full example project see the https://developer.lightbend.com/guides/play-java-grpc-example/[Quickstart Java project] or https://developer.lightbend.com/guides/play-scala-grpc-example/[Quickstart Scala project]
For a full example project see the https://github.com/playframework/play-samples/tree/3.0.x/play-java-grpc-example[Quickstart Java project] or https://github.com/playframework/play-samples/tree/3.0.x/play-scala-grpc-example[Quickstart Scala project]
10 changes: 5 additions & 5 deletions docs/modules/ROOT/pages/serving-grpc.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
== Serving gRPC from Play
:tabs-sync-option:

To be able to serve gRPC from a Play Framework app you must enable https://www.playframework.com/documentation/2.9.x/AkkaHttpServer#HTTP/2-support-(incubating)[HTTP/2 Support] with https://www.playframework.com/documentation/latest/ConfiguringHttps[HTTPS] and the ALPN agent.
To be able to serve gRPC from a Play Framework app you must enable https://www.playframework.com/documentation/3.0.x/PekkoHttpServer#HTTP/2-support-(incubating)[HTTP/2 Support] with https://www.playframework.com/documentation/latest/ConfiguringHttps[HTTPS] and the ALPN agent.

WARNING: To use gRPC in Play Framework you must enable https://www.playframework.com/documentation/2.9.x/AkkaHttpServer#HTTP/2-support-(incubating)[HTTP/2 Support].
WARNING: To use gRPC in Play Framework you must enable https://www.playframework.com/documentation/2.9.x/PekkoHttpServer#HTTP/2-support-(incubating)[HTTP/2 Support].

Generating classes from the gRPC service definition is done by adding the https://doc.akka.io/docs/akka-grpc/current/buildtools/sbt.html[Akka gRPC plugin to your sbt build] along with the Play gRPC generators:
Generating classes from the gRPC service definition is done by adding the https://doc.akka.io/docs/akka-grpc/current/buildtools/sbt.html[Pekko gRPC plugin to your sbt build] along with the Play gRPC generators:

[,scala,subs=attributes+]
----
Expand All @@ -23,7 +23,7 @@ Scala::
+
[,scala,subs=attributes+]
----
enablePlugins(AkkaGrpcPlugin)
enablePlugins(PekkoGrpcPlugin)
import play.grpc.gen.scaladsl.PlayScalaServerCodeGenerator
akkaGrpcExtraGenerators += PlayScalaServerCodeGenerator
libraryDependencies += "com.typesafe.play" %% "play-grpc-runtime" % "{page-component-version}"
Expand All @@ -32,7 +32,7 @@ Java::
+
[,scala,subs=attributes+]
----
enablePlugins(AkkaGrpcPlugin)
enablePlugins(PekkoGrpcPlugin)
import play.grpc.gen.javadsl.PlayJavaServerCodeGenerator
akkaGrpcExtraGenerators += PlayJavaServerCodeGenerator
libraryDependencies += "com.typesafe.play" %% "play-grpc-runtime" % "{page-component-version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ package play.grpc.gen.javadsl

import scala.collection.immutable

import akka.grpc.gen.javadsl.JavaCodeGenerator
import akka.grpc.gen.javadsl.Service
import akka.grpc.gen.Logger
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse
import org.apache.pekko.grpc.gen.javadsl.JavaCodeGenerator
import org.apache.pekko.grpc.gen.javadsl.Service
import org.apache.pekko.grpc.gen.Logger
import play.grpc.gen.scaladsl.PlayScalaClientCodeGenerator
import templates.PlayJava.txt.AkkaGrpcClientModule
import templates.PlayJava.txt.ClientProvider
import templates.PlayJava.txt.PekkoGrpcClientModule

object PlayJavaClientCodeGenerator extends PlayJavaClientCodeGenerator

Expand All @@ -33,12 +33,12 @@ class PlayJavaClientCodeGenerator extends JavaCodeGenerator {
if (allServices.nonEmpty) {
val packageName = packageForSharedModuleFile(allServices)
val b = CodeGeneratorResponse.File.newBuilder()
b.setContent(AkkaGrpcClientModule(packageName, allServices).body)
b.setContent(PekkoGrpcClientModule(packageName, allServices).body)
b.setName(s"${packageName.replace('.', '/')}/${PlayScalaClientCodeGenerator.ClientModuleName}.java")
val set = Set(b.build)
logger.info(
s"Generated [${packageName}.${PlayScalaClientCodeGenerator.ClientModuleName}] add it to play.modules.enabled and a section " +
"with Akka gRPC client config under akka.grpc.client.\"servicepackage.ServiceName\" to be able to inject " +
"with Pekko gRPC client config under org.apache.pekko.grpc.client.\"servicepackage.ServiceName\" to be able to inject " +
"client instances.",
)
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package play.grpc.gen.javadsl

import scala.collection.immutable

import akka.grpc.gen.javadsl.JavaCodeGenerator
import akka.grpc.gen.javadsl.Service
import akka.grpc.gen.Logger
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse
import org.apache.pekko.grpc.gen.javadsl.JavaCodeGenerator
import org.apache.pekko.grpc.gen.javadsl.Service
import org.apache.pekko.grpc.gen.Logger
import templates.PlayJavaServer.txt.Router
import templates.PlayJavaServer.txt.RouterUsingActions

Expand Down Expand Up @@ -38,7 +38,7 @@ class PlayJavaServerCodeGenerator extends JavaCodeGenerator {
else b.setContent(Router(service, powerApis = true).body)

b.setName(s"${service.packageDir}/Abstract${service.name}PowerApiRouter.java")
logger.info(s"Generating Akka gRPC service power API play router for ${service.packageName}.${service.name}")
logger.info(s"Generating Pekko gRPC service power API play router for ${service.packageName}.${service.name}")
immutable.Seq(b.build)
} else immutable.Seq.empty,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ package play.grpc.gen.scaladsl
import scala.annotation.tailrec
import scala.collection.immutable

import akka.grpc.gen.scaladsl.ScalaCodeGenerator
import akka.grpc.gen.scaladsl.Service
import akka.grpc.gen.Logger
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse
import templates.PlayScala.txt.AkkaGrpcClientModule
import org.apache.pekko.grpc.gen.scaladsl.ScalaCodeGenerator
import org.apache.pekko.grpc.gen.scaladsl.Service
import org.apache.pekko.grpc.gen.Logger
import templates.PlayScala.txt.ClientProvider
import templates.PlayScala.txt.PekkoGrpcClientModule

object PlayScalaClientCodeGenerator extends PlayScalaClientCodeGenerator

class PlayScalaClientCodeGenerator extends ScalaCodeGenerator {

val ClientModuleName = "AkkaGrpcClientModule"
val ClientModuleName = "PekkoGrpcClientModule"

override def name: String = "play-grpc-client-scala"

Expand All @@ -36,12 +36,12 @@ class PlayScalaClientCodeGenerator extends ScalaCodeGenerator {
if (allServices.nonEmpty) {
val packageName = packageForSharedModuleFile(allServices)
val b = CodeGeneratorResponse.File.newBuilder()
b.setContent(AkkaGrpcClientModule(packageName, allServices).body)
b.setContent(PekkoGrpcClientModule(packageName, allServices).body)
b.setName(s"${packageName.replace('.', '/')}/${ClientModuleName}.scala")
val set = Set(b.build)
logger.info(
s"Generated [${packageName}.${ClientModuleName}] add it to play.modules.enabled and a section " +
"with Akka gRPC client config under akka.grpc.client.\"servicepackage.ServiceName\" to be able to inject " +
"with Pekko gRPC client config under org.apache.pekko.grpc.client.\"servicepackage.ServiceName\" to be able to inject " +
"client instances.",
)
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package play.grpc.gen.scaladsl

import scala.collection.immutable

import akka.grpc.gen.scaladsl.ScalaCodeGenerator
import akka.grpc.gen.scaladsl.ScalaServerCodeGenerator
import akka.grpc.gen.scaladsl.Service
import akka.grpc.gen.Logger
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse
import org.apache.pekko.grpc.gen.scaladsl.ScalaCodeGenerator
import org.apache.pekko.grpc.gen.scaladsl.ScalaServerCodeGenerator
import org.apache.pekko.grpc.gen.scaladsl.Service
import org.apache.pekko.grpc.gen.Logger
import templates.PlayScala.txt._

class PlayScalaServerCodeGenerator extends ScalaCodeGenerator {
Expand Down Expand Up @@ -39,7 +39,7 @@ class PlayScalaServerCodeGenerator extends ScalaCodeGenerator {
else b.setContent(Router(service, powerApis = true).body)

b.setName(s"${service.packageDir}/Abstract${service.name}PowerApiRouter.scala")
logger.info(s"Generating Akka gRPC service power API play router for ${service.packageName}.${service.name}")
logger.info(s"Generating Pekko gRPC service power API play router for ${service.packageName}.${service.name}")
immutable.Seq(b.build)
} else immutable.Seq.empty,
}
Expand Down
Loading
Loading