You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by md...@apache.org on 2022/11/10 09:09:23 UTC
[incubator-pekko-grpc] 03/03: format source with scalafmt, #3
This is an automated email from the ASF dual-hosted git repository.
mdedetrich pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-grpc.git
commit 3b6138ee4093ae6c451d03e48d2bc085b3239731
Author: Auto Format <nobody>
AuthorDate: Thu Nov 10 09:58:07 2022 +0100
format source with scalafmt, #3
---
benchmark-java/project/plugins.sbt | 3 +-
build.sbt | 16 ++--
.../grpc/interop/AkkaGrpcScalaClientTester.scala | 4 +-
.../grpc/scaladsl/GrpcExceptionHandlerSpec.scala | 20 ++---
.../akka/grpc/maven/AbstractGenerateMojo.scala | 4 +-
.../main/scala/example/myapp/CombinedServer.scala | 8 +-
.../helloworld/AuthenticatedGreeterServer.scala | 16 ++--
.../myapp/helloworld/LiftedGreeterClient.scala | 4 +-
.../LoggingErrorHandlingGreeterClient.scala | 4 +-
.../LoggingErrorHandlingGreeterServer.scala | 16 ++--
project/AutomaticModuleName.scala | 2 +-
project/VersionSyncCheckPlugin.scala | 4 +-
.../main/scala/akka/grpc/GrpcClientSettings.scala | 4 +-
.../akka/grpc/internal/AbstractGrpcProtocol.scala | 23 ++---
.../akka/grpc/internal/GrpcEntityHelpers.scala | 2 +-
.../scala/akka/grpc/internal/MetadataImpl.scala | 2 +-
.../akka/grpc/internal/ServerReflectionImpl.scala | 7 +-
.../main/scala/akka/grpc/javadsl/WebHandler.scala | 2 +-
.../grpc/scaladsl/headers/PercentEncoding.scala | 4 +-
.../scala/akka/grpc/GrpcClientSettingsSpec.scala | 4 +-
.../javadsl/GoogleProtobufSerializerSpec.scala | 2 +-
.../akka/grpc/scaladsl/headers/HeadersSpec.scala | 2 +-
.../client/GrpcClientSettingsCompileOnly.scala | 12 +--
.../main/scala/akka/grpc/sbt/AkkaGrpcPlugin.scala | 2 +-
.../src/main/scala/akka/grpc/TestServiceImpl.scala | 31 +++----
.../scala/akka/grpc/AkkaGrpcClientTester.scala | 40 +++++----
.../src/test/scala/akka/grpc/GrpcInteropSpec.scala | 10 +--
.../src/main/scala/example/myapp/Main.scala | 6 +-
.../scala/example/myapp/echo/EchoServiceImpl.scala | 2 +-
.../03-test-config/project/plugins.sbt | 2 +-
.../scala/example/myapp/echo/EchoServiceImpl.scala | 2 +-
.../main/scala/example/myapp/helloworld/Main.scala | 97 +++++++++++-----------
.../09-scalapb-customizations/project/plugins.sbt | 2 +-
.../src/main/scala/example/myapp/Main.scala | 2 +-
.../scala3/01-basic-client-server/build.sbt | 3 +-
.../myapp/helloworld/GreeterServiceSpec.scala | 8 +-
36 files changed, 189 insertions(+), 183 deletions(-)
diff --git a/benchmark-java/project/plugins.sbt b/benchmark-java/project/plugins.sbt
index eda93b3a..6fd699f6 100644
--- a/benchmark-java/project/plugins.sbt
+++ b/benchmark-java/project/plugins.sbt
@@ -1,4 +1,3 @@
-lazy val plugins = project in file(".") dependsOn ProjectRef(file("../../"), "sbt-akka-grpc")
+lazy val plugins = (project in file(".")).dependsOn(ProjectRef(file("../../"), "sbt-akka-grpc"))
// Use this instead of above when importing to IDEA, after publishLocal and replacing the version here
//addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "0.1+32-fd597fcb+20180618-1248")
-
diff --git a/build.sbt b/build.sbt
index febf319a..1858066e 100644
--- a/build.sbt
+++ b/build.sbt
@@ -26,10 +26,10 @@ lazy val codegen = Project(id = akkaGrpcCodegenId, base = file("codegen"))
},
buildInfoKeys ++= Seq[BuildInfoKey](organization, name, version, scalaVersion, sbtVersion),
buildInfoKeys += "runtimeArtifactName" -> akkaGrpcRuntimeName,
- buildInfoKeys += "akkaVersion" → Dependencies.Versions.akka,
- buildInfoKeys += "akkaHttpVersion" → Dependencies.Versions.akkaHttp,
- buildInfoKeys += "grpcVersion" → Dependencies.Versions.grpc,
- buildInfoKeys += "googleProtobufVersion" → Dependencies.Versions.googleProtobuf,
+ buildInfoKeys += "akkaVersion" -> Dependencies.Versions.akka,
+ buildInfoKeys += "akkaHttpVersion" -> Dependencies.Versions.akkaHttp,
+ buildInfoKeys += "grpcVersion" -> Dependencies.Versions.grpc,
+ buildInfoKeys += "googleProtobufVersion" -> Dependencies.Versions.googleProtobuf,
buildInfoPackage := "akka.grpc.gen",
(Compile / assembly / artifact) := {
val art = (Compile / assembly / artifact).value
@@ -40,7 +40,7 @@ lazy val codegen = Project(id = akkaGrpcCodegenId, base = file("codegen"))
Some(sbtassembly.AssemblyPlugin.defaultUniversalScript(shebang = true))),
crossScalaVersions := Dependencies.Versions.CrossScalaForPlugin,
scalaVersion := scala212)
- .settings(addArtifact((Compile / assembly / artifact), assembly))
+ .settings(addArtifact(Compile / assembly / artifact, assembly))
.settings(addArtifact(Artifact(akkaGrpcCodegenId, "bat", "bat", "bat"), mkBatAssemblyTask))
lazy val runtime = Project(id = akkaGrpcRuntimeName, base = file("runtime"))
@@ -51,7 +51,7 @@ lazy val runtime = Project(id = akkaGrpcRuntimeName, base = file("runtime"))
scalaVersion := Dependencies.Versions.CrossScalaForLib.head)
.settings(
mimaFailOnNoPrevious := true,
- mimaPreviousArtifacts := Set.empty, //temporarily disable mima checks
+ mimaPreviousArtifacts := Set.empty, // temporarily disable mima checks
AutomaticModuleName.settings("akka.grpc.runtime"),
ReflectiveCodeGen.generatedLanguages := Seq("Scala"),
ReflectiveCodeGen.extraGenerators := Seq("ScalaMarshallersCodeGenerator"),
@@ -80,7 +80,7 @@ lazy val scalapbProtocPlugin = Project(id = akkaGrpcProtocPluginId, base = file(
.settings(
crossScalaVersions := Dependencies.Versions.CrossScalaForPlugin,
scalaVersion := Dependencies.Versions.CrossScalaForPlugin.head)
- .settings(addArtifact((Compile / assembly / artifact), assembly))
+ .settings(addArtifact(Compile / assembly / artifact, assembly))
.settings(addArtifact(Artifact(akkaGrpcProtocPluginId, "bat", "bat", "bat"), mkBatAssemblyTask))
.enablePlugins(ReproducibleBuildsPlugin)
@@ -150,7 +150,7 @@ lazy val interopTests = Project(id = "akka-grpc-interop-tests", base = file("int
reStartArgs.value,
startArgsParser.parsed)
}
- .dependsOn((Compile / products))
+ .dependsOn(Compile / products)
.evaluated
})))
diff --git a/interop-tests/src/test/scala/akka/grpc/interop/AkkaGrpcScalaClientTester.scala b/interop-tests/src/test/scala/akka/grpc/interop/AkkaGrpcScalaClientTester.scala
index f9706a88..a0eea44a 100644
--- a/interop-tests/src/test/scala/akka/grpc/interop/AkkaGrpcScalaClientTester.scala
+++ b/interop-tests/src/test/scala/akka/grpc/interop/AkkaGrpcScalaClientTester.scala
@@ -185,7 +185,7 @@ class AkkaGrpcScalaClientTester(val settings: Settings, backend: String)(implici
def customMetadata(): Unit = {
// unary call
- val binaryHeaderValue = akka.util.ByteString.fromInts(0xababab)
+ val binaryHeaderValue = akka.util.ByteString.fromInts(0xABABAB)
val unaryResponseFuture = client
.unaryCall()
.addHeader("x-grpc-test-echo-initial", "test_initial_metadata_value")
@@ -207,7 +207,7 @@ class AkkaGrpcScalaClientTester(val settings: Settings, backend: String)(implici
.fullDuplexCall()
.addHeader("x-grpc-test-echo-initial", "test_initial_metadata_value")
// this one is returned as trailer
- .addHeader("x-grpc-test-echo-trailing-bin", akka.util.ByteString.fromInts(0xababab))
+ .addHeader("x-grpc-test-echo-trailing-bin", akka.util.ByteString.fromInts(0xABABAB))
.invokeWithMetadata(
Source.single(
StreamingOutputCallRequest(
diff --git a/interop-tests/src/test/scala/akka/grpc/scaladsl/GrpcExceptionHandlerSpec.scala b/interop-tests/src/test/scala/akka/grpc/scaladsl/GrpcExceptionHandlerSpec.scala
index bf918e3b..2e5c341a 100644
--- a/interop-tests/src/test/scala/akka/grpc/scaladsl/GrpcExceptionHandlerSpec.scala
+++ b/interop-tests/src/test/scala/akka/grpc/scaladsl/GrpcExceptionHandlerSpec.scala
@@ -54,14 +54,14 @@ class GrpcExceptionHandlerSpec
import example.myapp.helloworld.grpc.helloworld._
object ExampleImpl extends GreeterService {
- //#streaming
+ // #streaming
import akka.NotUsed
import akka.stream.scaladsl.Source
- //#streaming
+ // #streaming
- //#unary
- //#streaming
+ // #unary
+ // #streaming
import akka.grpc.GrpcServiceException
import io.grpc.Status
@@ -70,10 +70,10 @@ class GrpcExceptionHandlerSpec
.addBinary("test-binary-bin", ByteString("test-binary-data"))
.build()
- //#unary
- //#streaming
+ // #unary
+ // #streaming
- //#unary
+ // #unary
// ...
def sayHello(in: HelloRequest): Future[HelloReply] = {
@@ -83,11 +83,11 @@ class GrpcExceptionHandlerSpec
else
Future.successful(HelloReply(s"Hi ${in.name}!"))
}
- //#unary
+ // #unary
lazy val myResponseSource: Source[HelloReply, NotUsed] = ???
- //#streaming
+ // #streaming
def itKeepsReplying(in: HelloRequest): Source[HelloReply, NotUsed] = {
if (in.name.isEmpty)
Source.failed(
@@ -95,7 +95,7 @@ class GrpcExceptionHandlerSpec
else
myResponseSource
}
- //#streaming
+ // #streaming
def itKeepsTalking(
in: akka.stream.scaladsl.Source[example.myapp.helloworld.grpc.helloworld.HelloRequest, akka.NotUsed])
diff --git a/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala b/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala
index ecf1b82e..0f865da6 100644
--- a/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala
+++ b/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala
@@ -79,7 +79,7 @@ object AbstractGenerateMojo {
def parseGeneratorSettings(generatorSettings: java.util.Map[String, String]): Seq[String] = {
import scala.collection.JavaConverters._
generatorSettings.asScala.filter(_._2.toLowerCase() != "false").keys.toSeq.map { params =>
- "[A-Z]".r.replaceAllIn(params, (s => s"_${s.group(0).toLowerCase()}"))
+ "[A-Z]".r.replaceAllIn(params, s => s"_${s.group(0).toLowerCase()}")
}
}
}
@@ -131,7 +131,7 @@ abstract class AbstractGenerateMojo @Inject() (buildContext: BuildContext) exten
var directoryFound = false
protoPaths.forEach { protoPath =>
// verify proto dir exists
- //https://maven.apache.org/plugin-developers/common-bugs.html#Resolving_Relative_Paths
+ // https://maven.apache.org/plugin-developers/common-bugs.html#Resolving_Relative_Paths
val protoDir = {
val protoFile = new File(protoPath)
if (!protoFile.isAbsolute()) {
diff --git a/plugin-tester-scala/src/main/scala/example/myapp/CombinedServer.scala b/plugin-tester-scala/src/main/scala/example/myapp/CombinedServer.scala
index d2bf914a..0b68bd01 100644
--- a/plugin-tester-scala/src/main/scala/example/myapp/CombinedServer.scala
+++ b/plugin-tester-scala/src/main/scala/example/myapp/CombinedServer.scala
@@ -36,7 +36,7 @@ object CombinedServer {
implicit val sys: ActorSystem = ActorSystem("HelloWorld", conf)
implicit val ec: ExecutionContext = sys.dispatcher
- //#concatOrNotFound
+ // #concatOrNotFound
// explicit types not needed but included in example for clarity
val greeterService: PartialFunction[HttpRequest, Future[HttpResponse]] =
example.myapp.helloworld.grpc.GreeterServiceHandler.partial(new GreeterServiceImpl())
@@ -49,16 +49,16 @@ object CombinedServer {
Http()
.newServerAt("127.0.0.1", 8080)
.bind(serviceHandlers)
- //#concatOrNotFound
+ // #concatOrNotFound
.foreach { binding => println(s"gRPC server bound to: ${binding.localAddress}") }
- //#grpc-web
+ // #grpc-web
val grpcWebServiceHandlers = WebHandler.grpcWebHandler(greeterService, echoService)
Http()
.newServerAt("127.0.0.1", 8081)
.bind(grpcWebServiceHandlers)
- //#grpc-web
+ // #grpc-web
.foreach { binding => println(s"gRPC-Web server bound to: ${binding.localAddress}") }
}
}
diff --git a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/AuthenticatedGreeterServer.scala b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/AuthenticatedGreeterServer.scala
index 11db109c..9a570964 100644
--- a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/AuthenticatedGreeterServer.scala
+++ b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/AuthenticatedGreeterServer.scala
@@ -33,34 +33,34 @@ class AuthenticatedGreeterServer(system: ActorSystem) {
implicit val sys: ActorSystem = system
implicit val ec: ExecutionContext = sys.dispatcher
- //#http-route
+ // #http-route
// A Route to authenticate with
val authenticationRoute: Route = path("login") {
get {
complete("Psst, please use token XYZ!")
}
}
- //#http-route
+ // #http-route
- //#grpc-route
+ // #grpc-route
// Create service handlers
val handler: HttpRequest => Future[HttpResponse] =
GreeterServiceHandler(new GreeterServiceImpl())
// As a Route
val handlerRoute: Route = handle(handler)
- //#grpc-route
+ // #grpc-route
- //#grpc-protected
+ // #grpc-protected
// A directive to authorize calls
val authorizationDirective: Directive0 =
headerValueByName("token").flatMap { token =>
if (token == "XYZ") pass
else reject
}
- //#grpc-protected
+ // #grpc-protected
- //#combined
+ // #combined
val route = concat(
authenticationRoute,
authorizationDirective {
@@ -69,7 +69,7 @@ class AuthenticatedGreeterServer(system: ActorSystem) {
// Bind service handler servers to localhost:8082
val binding = Http().newServerAt("127.0.0.1", 8082).bind(route)
- //#combined
+ // #combined
// report successful binding
binding.foreach { binding => println(s"gRPC server bound to: ${binding.localAddress}") }
diff --git a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LiftedGreeterClient.scala b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LiftedGreeterClient.scala
index b4c93fc5..8577e421 100644
--- a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LiftedGreeterClient.scala
+++ b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LiftedGreeterClient.scala
@@ -32,13 +32,13 @@ object LiftedGreeterClient {
sys.scheduler.scheduleWithFixedDelay(1.second, 1.second) { () => Try(singleRequestReply()) }
- //#with-metadata
+ // #with-metadata
def singleRequestReply(): Unit = {
sys.log.info("Performing request")
val reply = client.sayHello().addHeader("key", "value").invoke(HelloRequest("Alice"))
println(s"got single reply: ${Await.result(reply, 5.seconds).message}")
}
- //#with-metadata
+ // #with-metadata
def streamingRequest(): Unit = {
val requests = List("Alice", "Bob", "Peter").map(HelloRequest(_))
diff --git a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterClient.scala b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterClient.scala
index 33948bf6..20ef6fd4 100644
--- a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterClient.scala
+++ b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterClient.scala
@@ -21,7 +21,7 @@ object LoggingErrorHandlingGreeterClient {
// Create a client-side stub for the service
val client: GreeterServiceClient = GreeterServiceClient(clientSettings)
- //#client-calls
+ // #client-calls
val successful = client.sayHello(HelloRequest("Martin"))
Await.result(successful, 10.seconds)
sys.log.info("Call succeeded")
@@ -33,7 +33,7 @@ object LoggingErrorHandlingGreeterClient {
val failedBecauseEmpty = client.sayHello(HelloRequest(""))
Await.result(failedBecauseEmpty.failed, 10.seconds)
sys.log.info("Call with empty name failed")
- //#client-calls
+ // #client-calls
sys.terminate()
}
diff --git a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterServer.scala b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterServer.scala
index 8e6ccb89..13830f2f 100644
--- a/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterServer.scala
+++ b/plugin-tester-scala/src/main/scala/example/myapp/helloworld/LoggingErrorHandlingGreeterServer.scala
@@ -32,7 +32,7 @@ object LoggingErrorHandlingGreeterServer {
}
class LoggingErrorHandlingGreeterServer(system: ActorSystem) {
- //#implementation
+ // #implementation
private final class Impl(mat: Materializer) extends GreeterServiceImpl()(mat) {
override def sayHello(in: HelloRequest): Future[HelloReply] =
if (in.name.head.isLower) {
@@ -41,9 +41,9 @@ class LoggingErrorHandlingGreeterServer(system: ActorSystem) {
Future.successful(HelloReply(s"Hello, ${in.name}"))
}
}
- //#implementation
+ // #implementation
- //#method
+ // #method
private type ErrorHandler = ActorSystem => PartialFunction[Throwable, Trailers]
private def loggingErrorHandlingGrpcRoute[ServiceImpl](
@@ -70,19 +70,19 @@ class LoggingErrorHandlingGreeterServer(system: ActorSystem) {
handle(handler)
}
}
- //#method
+ // #method
- //#custom-error-mapping
+ // #custom-error-mapping
private val customErrorMapping: PartialFunction[Throwable, Trailers] = {
case ex: IllegalArgumentException => Trailers(Status.INVALID_ARGUMENT.withDescription(ex.getMessage))
}
- //#custom-error-mapping
+ // #custom-error-mapping
def run(): Future[Http.ServerBinding] = {
implicit val sys: ActorSystem = system
implicit val ec: ExecutionContext = sys.dispatcher
- //#combined
+ // #combined
val route = loggingErrorHandlingGrpcRoute[GreeterService](
buildImpl = rc => new Impl(rc.materializer),
buildHandler = (impl, eHandler) =>
@@ -93,7 +93,7 @@ class LoggingErrorHandlingGreeterServer(system: ActorSystem) {
// Bind service handler servers to localhost:8082
val binding = Http().newServerAt("127.0.0.1", 8082).bind(route)
- //#combined
+ // #combined
// report successful binding
binding.foreach { binding => println(s"gRPC server bound to: ${binding.localAddress}") }
diff --git a/project/AutomaticModuleName.scala b/project/AutomaticModuleName.scala
index 0b9a3b8b..74e685a2 100644
--- a/project/AutomaticModuleName.scala
+++ b/project/AutomaticModuleName.scala
@@ -16,5 +16,5 @@ object AutomaticModuleName {
private val AutomaticModuleName = "Automatic-Module-Name"
def settings(name: String): Seq[Def.Setting[Task[Seq[PackageOption]]]] =
- Seq((Compile / packageBin / packageOptions) += Package.ManifestAttributes(AutomaticModuleName → name))
+ Seq((Compile / packageBin / packageOptions) += Package.ManifestAttributes(AutomaticModuleName -> name))
}
diff --git a/project/VersionSyncCheckPlugin.scala b/project/VersionSyncCheckPlugin.scala
index d629a66f..a74bbfc0 100644
--- a/project/VersionSyncCheckPlugin.scala
+++ b/project/VersionSyncCheckPlugin.scala
@@ -53,9 +53,9 @@ object VersionSyncCheckPlugin extends AutoPlugin {
.lines(path)
.iterator
.asScala
- .collect({
+ .collect {
case VersionRegex(version) => version
- })
+ }
.toSeq)
log.info("Sanity checking regex extraction against known files")
diff --git a/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala b/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala
index cac67792..8d680c2d 100644
--- a/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala
+++ b/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala
@@ -134,14 +134,14 @@ object GrpcClientSettings {
getOptionalInt(clientConfiguration, "connection-attempts"),
None,
getOptionalString(clientConfiguration, "override-authority"),
- getOptionalString(clientConfiguration, "ssl-provider").map({
+ getOptionalString(clientConfiguration, "ssl-provider").map {
case "jdk" => SslProvider.JDK
case "openssl" => SslProvider.OPENSSL
case "openssl_refcnt" => SslProvider.OPENSSL_REFCNT
case other =>
throw new IllegalArgumentException(
s"ssl-provider: expected empty, 'jdk', 'openssl' or 'openssl_refcnt', but got [$other]")
- }),
+ },
None,
getOptionalString(clientConfiguration, "trusted").map(SSLContextUtils.trustManagerFromResource),
getPotentiallyInfiniteDuration(clientConfiguration, "deadline"),
diff --git a/runtime/src/main/scala/akka/grpc/internal/AbstractGrpcProtocol.scala b/runtime/src/main/scala/akka/grpc/internal/AbstractGrpcProtocol.scala
index 3caff275..619d366c 100644
--- a/runtime/src/main/scala/akka/grpc/internal/AbstractGrpcProtocol.scala
+++ b/runtime/src/main/scala/akka/grpc/internal/AbstractGrpcProtocol.scala
@@ -118,15 +118,16 @@ object AbstractGrpcProtocol {
else x => Flow[ByteString].via(preDecodeFlow).via(x)
// strict decoder
- def decoder(bs: ByteString): ByteString = try {
- val reader = new ByteReader(strictAdapter(bs))
- val frameType = reader.readByte()
- val length = reader.readIntBE()
- val data = reader.take(length)
- if (reader.hasRemaining) throw new IllegalStateException("Unexpected data")
- if ((frameType & 0x80) == 0) codec.uncompress((frameType & 1) == 1, data)
- else throw new IllegalStateException("Cannot read unknown frame")
- } catch { case ByteStringParser.NeedMoreData => throw new MissingParameterException }
+ def decoder(bs: ByteString): ByteString =
+ try {
+ val reader = new ByteReader(strictAdapter(bs))
+ val frameType = reader.readByte()
+ val length = reader.readIntBE()
+ val data = reader.take(length)
+ if (reader.hasRemaining) throw new IllegalStateException("Unexpected data")
+ if ((frameType & 0x80) == 0) codec.uncompress((frameType & 1) == 1, data)
+ else throw new IllegalStateException("Cannot read unknown frame")
+ } catch { case ByteStringParser.NeedMoreData => throw new MissingParameterException }
GrpcProtocolReader(codec, decoder, adapter(Flow.fromGraph(new GrpcFramingDecoderStage(codec, decodeFrame))))
}
@@ -154,8 +155,8 @@ object AbstractGrpcProtocol {
override def parse(reader: ByteReader): ParseResult[Frame] =
try ParseResult(
- Some(deframe(frameType, codec.uncompress(compression, reader.take(length)))),
- ReadFrameHeader)
+ Some(deframe(frameType, codec.uncompress(compression, reader.take(length)))),
+ ReadFrameHeader)
catch {
case s: StatusException =>
failStage(s) // handle explicitly to avoid noisy log
diff --git a/runtime/src/main/scala/akka/grpc/internal/GrpcEntityHelpers.scala b/runtime/src/main/scala/akka/grpc/internal/GrpcEntityHelpers.scala
index 4b250992..a90909a3 100644
--- a/runtime/src/main/scala/akka/grpc/internal/GrpcEntityHelpers.scala
+++ b/runtime/src/main/scala/akka/grpc/internal/GrpcEntityHelpers.scala
@@ -46,7 +46,7 @@ object GrpcEntityHelpers {
import akka.stream._
import akka.stream.scaladsl._
import scala.annotation.unchecked.uncheckedVariance
- //A faster implementation of concat that does not allocate so much
+ // A faster implementation of concat that does not allocate so much
private def concatCheap[U, Mat2](that: Graph[SourceShape[U], Mat2]): Graph[FlowShape[U @uncheckedVariance, U], Mat2] =
GraphDSL.createGraph(that) { implicit b => r =>
import GraphDSL.Implicits._
diff --git a/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala b/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala
index 07af4cfb..b566157f 100644
--- a/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala
+++ b/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala
@@ -4,7 +4,7 @@
package akka.grpc.internal
-import java.util.{ Locale, Optional, List => jList, Map => jMap }
+import java.util.{ List => jList, Locale, Map => jMap, Optional }
import scala.collection.JavaConverters._
import scala.collection.immutable
diff --git a/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala b/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala
index 7ba40455..666f7130 100644
--- a/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala
+++ b/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala
@@ -47,8 +47,7 @@ final class ServerReflectionImpl private (fileDescriptors: Map[String, FileDescr
val list =
findExtensionNumbersForContainingType(
container,
- fileDescriptors
- ) // TODO should we throw a NOT_FOUND if we don't know the container type at all?
+ fileDescriptors) // TODO should we throw a NOT_FOUND if we don't know the container type at all?
Out.AllExtensionNumbersResponse(ExtensionNumberResponse(container, list))
case In.ListServices(_) =>
val list = services.map(s => ServiceResponse(s))
@@ -96,9 +95,9 @@ object ServerReflectionImpl {
(splitNext(if (fileDesc.getPackage.isEmpty) symbol else symbol.drop(fileDesc.getPackage.length + 1)) match {
case ("", "") => false
case (typeOrService, "") =>
- //fileDesc.findEnumTypeByName(typeOrService) != null || // TODO investigate if this is expected
+ // fileDesc.findEnumTypeByName(typeOrService) != null || // TODO investigate if this is expected
fileDesc.findMessageTypeByName(typeOrService) != null ||
- fileDesc.findServiceByName(typeOrService) != null
+ fileDesc.findServiceByName(typeOrService) != null
case (service, method) =>
Option(fileDesc.findServiceByName(service)).exists(_.findMethodByName(method) != null)
})
diff --git a/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala b/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala
index c5c8a99f..a734a6da 100644
--- a/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala
+++ b/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala
@@ -15,7 +15,7 @@ import akka.http.javadsl.marshalling.Marshaller
import akka.http.javadsl.model.{ HttpRequest, HttpResponse }
import akka.http.javadsl.server.Route
import akka.http.javadsl.server.directives.RouteAdapter
-import akka.http.scaladsl.marshalling.{ ToResponseMarshaller, Marshaller => sMarshaller }
+import akka.http.scaladsl.marshalling.{ Marshaller => sMarshaller, ToResponseMarshaller }
import akka.grpc.scaladsl
import akka.http.scaladsl.server.directives.MarshallingDirectives
import akka.japi.function.{ Function => JFunction }
diff --git a/runtime/src/main/scala/akka/grpc/scaladsl/headers/PercentEncoding.scala b/runtime/src/main/scala/akka/grpc/scaladsl/headers/PercentEncoding.scala
index 382be0bc..5a2711ec 100644
--- a/runtime/src/main/scala/akka/grpc/scaladsl/headers/PercentEncoding.scala
+++ b/runtime/src/main/scala/akka/grpc/scaladsl/headers/PercentEncoding.scala
@@ -64,8 +64,8 @@ private[grpc] object PercentEncoding {
// Manually implement URL encoding, per the gRPC spec.
if (isEscapingChar(b)) {
escapedBytes.update(wi, '%')
- escapedBytes.update(wi + 1, HexArr((b >> 4) & 0xf))
- escapedBytes.update(wi + 2, HexArr(b & 0xf))
+ escapedBytes.update(wi + 1, HexArr((b >> 4) & 0xF))
+ escapedBytes.update(wi + 2, HexArr(b & 0xF))
wi += 3
} else {
escapedBytes.update(wi, b)
diff --git a/runtime/src/test/scala/akka/grpc/GrpcClientSettingsSpec.scala b/runtime/src/test/scala/akka/grpc/GrpcClientSettingsSpec.scala
index e70100e5..430e93bc 100644
--- a/runtime/src/test/scala/akka/grpc/GrpcClientSettingsSpec.scala
+++ b/runtime/src/test/scala/akka/grpc/GrpcClientSettingsSpec.scala
@@ -131,10 +131,10 @@ class GrpcClientSettingsSpec extends AnyWordSpec with Matchers with ScalaFutures
}
"load a user defined service discovery mechanism" in {
- //#sd-settings
+ // #sd-settings
// an implicit ActorSystem is required to be in scope for service discovery
val settings = GrpcClientSettings.fromConfig(clientName = "project.WithConfigServiceDiscovery")
- //#sd-settings
+ // #sd-settings
settings.serviceDiscovery shouldBe a[ConfigServiceDiscovery]
diff --git a/runtime/src/test/scala/akka/grpc/javadsl/GoogleProtobufSerializerSpec.scala b/runtime/src/test/scala/akka/grpc/javadsl/GoogleProtobufSerializerSpec.scala
index d52ca5ad..bc55b487 100644
--- a/runtime/src/test/scala/akka/grpc/javadsl/GoogleProtobufSerializerSpec.scala
+++ b/runtime/src/test/scala/akka/grpc/javadsl/GoogleProtobufSerializerSpec.scala
@@ -4,7 +4,7 @@
package akka.grpc.javadsl
-import com.google.protobuf.{ ByteString, Any => ProtobufAny }
+import com.google.protobuf.{ Any => ProtobufAny, ByteString }
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
diff --git a/runtime/src/test/scala/akka/grpc/scaladsl/headers/HeadersSpec.scala b/runtime/src/test/scala/akka/grpc/scaladsl/headers/HeadersSpec.scala
index 77bd3e6b..28d26217 100644
--- a/runtime/src/test/scala/akka/grpc/scaladsl/headers/HeadersSpec.scala
+++ b/runtime/src/test/scala/akka/grpc/scaladsl/headers/HeadersSpec.scala
@@ -24,7 +24,7 @@ class HeadersSpec extends AnyWordSpec with Matchers {
// \udc37 is a low surrogate, a lone surrogate character is getting decoded as ? with UTF-8
("my favorite character is \udc37", "my favorite character is ?"),
// a pair of surrogate characters is fine
- ("my favorite character is " + 0xdbff.toChar + 0xdfff.toChar, "my favorite character is %F4%8F%BF%BF"))
+ ("my favorite character is " + 0xDBFF.toChar + 0xDFFF.toChar, "my favorite character is %F4%8F%BF%BF"))
forAll(inAndExpectedOut) { (in, expected) =>
new `Status-Message`(in).value() should equal(expected)
diff --git a/runtime/src/test/scala/docs/akka/grpc/client/GrpcClientSettingsCompileOnly.scala b/runtime/src/test/scala/docs/akka/grpc/client/GrpcClientSettingsCompileOnly.scala
index 99063ae6..19f6b914 100644
--- a/runtime/src/test/scala/docs/akka/grpc/client/GrpcClientSettingsCompileOnly.scala
+++ b/runtime/src/test/scala/docs/akka/grpc/client/GrpcClientSettingsCompileOnly.scala
@@ -12,20 +12,20 @@ import scala.concurrent.duration._
object GrpcClientSettingsCompileOnly {
implicit val actorSystem = ActorSystem()
- //#simple
+ // #simple
GrpcClientSettings.connectToServiceAt("localhost", 443)
- //#simple
+ // #simple
- //#simple-programmatic
+ // #simple-programmatic
GrpcClientSettings.connectToServiceAt("localhost", 443).withDeadline(1.second).withTls(false)
- //#simple-programmatic
+ // #simple-programmatic
val serviceDiscovery: ServiceDiscovery = Discovery.get(actorSystem).discovery
- //#provide-sd
+ // #provide-sd
// An ActorSystem's default service discovery mechanism
GrpcClientSettings
.usingServiceDiscovery(serviceName = "my-service")
.withServicePortName("https") // (optional) refine the lookup operation to only https ports
- //#provide-sd
+ // #provide-sd
}
diff --git a/sbt-plugin/src/main/scala/akka/grpc/sbt/AkkaGrpcPlugin.scala b/sbt-plugin/src/main/scala/akka/grpc/sbt/AkkaGrpcPlugin.scala
index 90bd389b..8722a7a8 100644
--- a/sbt-plugin/src/main/scala/akka/grpc/sbt/AkkaGrpcPlugin.scala
+++ b/sbt-plugin/src/main/scala/akka/grpc/sbt/AkkaGrpcPlugin.scala
@@ -7,7 +7,7 @@ package akka.grpc.sbt
import akka.grpc.gen.CodeGenerator.ScalaBinaryVersion
import akka.grpc.gen.scaladsl.{ ScalaClientCodeGenerator, ScalaServerCodeGenerator, ScalaTraitCodeGenerator }
import akka.grpc.gen.javadsl.{ JavaClientCodeGenerator, JavaInterfaceCodeGenerator, JavaServerCodeGenerator }
-import akka.grpc.gen.{ BuildInfo, ProtocSettings, Logger => GenLogger }
+import akka.grpc.gen.{ BuildInfo, Logger => GenLogger, ProtocSettings }
import protocbridge.Generator
import sbt.Keys._
import sbt._
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/main/scala/akka/grpc/TestServiceImpl.scala b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/main/scala/akka/grpc/TestServiceImpl.scala
index 3bc51aa7..47f092f5 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/main/scala/akka/grpc/TestServiceImpl.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/main/scala/akka/grpc/TestServiceImpl.scala
@@ -5,12 +5,12 @@ import scala.concurrent.Future
import scala.reflect.ClassTag
import scala.collection.immutable
-import akka.grpc.scaladsl.{GrpcMarshalling}
+import akka.grpc.scaladsl.GrpcMarshalling
import akka.NotUsed
import akka.actor.ActorSystem
import akka.grpc._
-import akka.stream.scaladsl.{Flow, Source}
+import akka.stream.scaladsl.{ Flow, Source }
import akka.stream.{ Materializer, SystemMaterializer }
import com.google.protobuf.ByteString
@@ -31,19 +31,19 @@ object TestServiceImpl {
}
/**
- * Implementation of the generated service.
- *
- * Essentially porting the client code from [[io.grpc.testing.integration.TestServiceImpl]] against our API's
- *
- * The same implementation is also be found as part of the 'non-scripted' tests at
- * /interop-tests/src/test/scala/akka/grpc/interop/TestServiceImpl.scala
- */
+ * Implementation of the generated service.
+ *
+ * Essentially porting the client code from [[io.grpc.testing.integration.TestServiceImpl]] against our API's
+ *
+ * The same implementation is also be found as part of the 'non-scripted' tests at
+ * /interop-tests/src/test/scala/akka/grpc/interop/TestServiceImpl.scala
+ */
class TestServiceImpl(implicit sys: ActorSystem) extends TestService {
import TestServiceImpl._
implicit val mat: Materializer = SystemMaterializer(sys).materializer
implicit val ec: ExecutionContext = sys.dispatcher
-
+
override def emptyCall(req: Empty) =
Future.successful(Empty())
@@ -55,13 +55,14 @@ class TestServiceImpl(implicit sys: ActorSystem) extends TestService {
val responseStatus = Status.fromCodeValue(requestStatus.code).withDescription(requestStatus.message)
// - Either one of the following works
Future.failed(new GrpcServiceException(responseStatus))
- // throw new GrpcServiceException(responseStatus)
+ // throw new GrpcServiceException(responseStatus)
}
}
override def cacheableUnaryCall(in: SimpleRequest): Future[SimpleResponse] = ???
- override def fullDuplexCall(in: Source[StreamingOutputCallRequest, NotUsed]): Source[StreamingOutputCallResponse, NotUsed] =
+ override def fullDuplexCall(
+ in: Source[StreamingOutputCallRequest, NotUsed]): Source[StreamingOutputCallResponse, NotUsed] =
in.map(req => {
req.responseStatus.foreach(reqStatus =>
throw new GrpcServiceException(
@@ -70,9 +71,11 @@ class TestServiceImpl(implicit sys: ActorSystem) extends TestService {
}).mapConcat(
_.responseParameters.to[immutable.Seq]).via(parametersToResponseFlow)
- override def halfDuplexCall(in: Source[StreamingOutputCallRequest, NotUsed]): Source[StreamingOutputCallResponse, NotUsed] = ???
+ override def halfDuplexCall(
+ in: Source[StreamingOutputCallRequest, NotUsed]): Source[StreamingOutputCallResponse, NotUsed] = ???
- override def streamingInputCall(in: Source[StreamingInputCallRequest, NotUsed]): Future[StreamingInputCallResponse] = {
+ override def streamingInputCall(
+ in: Source[StreamingInputCallRequest, NotUsed]): Future[StreamingInputCallResponse] = {
in
.map(_.payload.map(_.body.size).getOrElse(0))
.runFold(0)(_ + _)
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/AkkaGrpcClientTester.scala b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/AkkaGrpcClientTester.scala
index 368865ff..7b87ce6a 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/AkkaGrpcClientTester.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/AkkaGrpcClientTester.scala
@@ -2,19 +2,26 @@ package akka.grpc.interop
import java.io.InputStream
-import akka.grpc.{GrpcClientSettings, GrpcResponseMetadata, SSLContextUtils}
+import akka.grpc.{ GrpcClientSettings, GrpcResponseMetadata, SSLContextUtils }
import akka.stream.{ Materializer, SystemMaterializer }
import akka.actor.ActorSystem
-import akka.stream.scaladsl.{Keep, Sink, Source}
+import akka.stream.scaladsl.{ Keep, Sink, Source }
import com.google.protobuf.ByteString
-import io.grpc.testing.integration.messages.{Payload, ResponseParameters, SimpleRequest, StreamingOutputCallRequest, StreamingOutputCallResponse, _}
+import io.grpc.testing.integration.messages.{
+ Payload,
+ ResponseParameters,
+ SimpleRequest,
+ StreamingOutputCallRequest,
+ StreamingOutputCallResponse,
+ _
+}
import io.grpc.testing.integration.empty.Empty
-import io.grpc.testing.integration2.{ChannelBuilder, ClientTester, Settings}
-import io.grpc.{ManagedChannel, Status, StatusRuntimeException}
+import io.grpc.testing.integration2.{ ChannelBuilder, ClientTester, Settings }
+import io.grpc.{ ManagedChannel, Status, StatusRuntimeException }
import org.junit.Assert._
import scala.concurrent.duration._
-import scala.concurrent.{Await, ExecutionContext, Future}
+import scala.concurrent.{ Await, ExecutionContext, Future }
import scala.util.Failure
import scala.util.control.NoStackTrace
@@ -22,13 +29,13 @@ import scala.util.control.NoStackTrace
import io.grpc.testing.integration.test.{ TestServiceClient, UnimplementedServiceClient }
/**
- * ClientTester implementation that uses the generated akka-grpc Scala client to exercise a server under test.
- *
- * Essentially porting the client code from [[io.grpc.testing.integration.AbstractInteropTest]] against our Java API's
- *
- * The same implementation is also be found as part of the 'non-scripted' tests at
- * /interop-tests/src/test/scala/akka/grpc/interop/AkkaGrpcScalaClientTester.scala
- */
+ * ClientTester implementation that uses the generated akka-grpc Scala client to exercise a server under test.
+ *
+ * Essentially porting the client code from [[io.grpc.testing.integration.AbstractInteropTest]] against our Java API's
+ *
+ * The same implementation is also be found as part of the 'non-scripted' tests at
+ * /interop-tests/src/test/scala/akka/grpc/interop/AkkaGrpcScalaClientTester.scala
+ */
class AkkaGrpcClientTester(val settings: Settings)(implicit system: ActorSystem) extends ClientTester {
private var client: TestServiceClient = null
@@ -217,12 +224,13 @@ class AkkaGrpcClientTester(val settings: Settings)(implicit system: ActorSystem)
def customMetadata(): Unit = {
// unary call
- val binaryHeaderValue = akka.util.ByteString.fromInts(0xababab)
+ val binaryHeaderValue = akka.util.ByteString.fromInts(0xABABAB)
val unaryResponseFuture = client.unaryCall()
.addHeader("x-grpc-test-echo-initial", "test_initial_metadata_value")
// this one is returned as trailer
.addHeader("x-grpc-test-echo-trailing-bin", binaryHeaderValue)
- .invokeWithMetadata(SimpleRequest(responseSize = 314159, payload = Some(Payload(body = ByteString.copyFrom(new Array[Byte](271828))))))
+ .invokeWithMetadata(SimpleRequest(responseSize = 314159,
+ payload = Some(Payload(body = ByteString.copyFrom(new Array[Byte](271828))))))
val unaryResponse = Await.result(unaryResponseFuture, awaitTimeout)
assertEquals(
@@ -238,7 +246,7 @@ class AkkaGrpcClientTester(val settings: Settings)(implicit system: ActorSystem)
client.fullDuplexCall()
.addHeader("x-grpc-test-echo-initial", "test_initial_metadata_value")
// this one is returned as trailer
- .addHeader("x-grpc-test-echo-trailing-bin", akka.util.ByteString.fromInts(0xababab))
+ .addHeader("x-grpc-test-echo-trailing-bin", akka.util.ByteString.fromInts(0xABABAB))
.invokeWithMetadata(Source.single(
StreamingOutputCallRequest(
responseParameters = Seq(ResponseParameters(size = 314159)),
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/GrpcInteropSpec.scala b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/GrpcInteropSpec.scala
index 5537576f..3d457e04 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/GrpcInteropSpec.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/src/test/scala/akka/grpc/GrpcInteropSpec.scala
@@ -1,10 +1,10 @@
package akka.grpc.interop
-import akka.stream.{Materializer, SystemMaterializer}
+import akka.stream.{ Materializer, SystemMaterializer }
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.RawHeader
import akka.http.scaladsl.server.RouteResult.Complete
-import akka.http.scaladsl.server.{Directive0, Directives, Route}
+import akka.http.scaladsl.server.{ Directive0, Directives, Route }
import io.grpc.testing.integration.TestServiceHandlerFactory
import io.grpc.testing.integration.test.TestService
@@ -18,7 +18,8 @@ import io.grpc.testing.integration.test.TestServiceHandler
class GrpcInteropIoWithAkkaSpec extends GrpcInteropTests(IoGrpcJavaServerProvider, AkkaHttpClientProviderScala)
class GrpcInteropAkkaScalaWithIoSpec extends GrpcInteropTests(AkkaHttpServerProviderScala, IoGrpcJavaClientProvider)
-class GrpcInteropAkkaScalaWithAkkaSpec extends GrpcInteropTests(AkkaHttpServerProviderScala, AkkaHttpClientProviderScala)
+class GrpcInteropAkkaScalaWithAkkaSpec
+ extends GrpcInteropTests(AkkaHttpServerProviderScala, AkkaHttpClientProviderScala)
class GrpcInteropAkkaJavaWithIoSpec extends GrpcInteropTests(AkkaHttpServerProviderJava, IoGrpcJavaClientProvider)
class GrpcInteropAkkaJavaWithAkkaSpec extends GrpcInteropTests(AkkaHttpServerProviderJava, AkkaHttpClientProviderScala)
@@ -76,8 +77,7 @@ object AkkaHttpServerProviderJava extends AkkaHttpServerProvider {
val pendingCases =
Set(
- "custom_metadata"
- )
+ "custom_metadata")
val server = new AkkaGrpcServerJava((mat, sys) => {
TestServiceHandlerFactory.create(new JavaTestServiceImpl(mat), sys)
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/Main.scala b/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/Main.scala
index 969f2e02..a1f0c0bb 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/Main.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/Main.scala
@@ -1,13 +1,13 @@
package example.myapp
import java.io.InputStream
-import java.security.{KeyStore, SecureRandom}
-import javax.net.ssl.{KeyManagerFactory, SSLContext}
+import java.security.{ KeyStore, SecureRandom }
+import javax.net.ssl.{ KeyManagerFactory, SSLContext }
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.grpc.scaladsl.ServiceHandler
-import akka.http.scaladsl.{Http, HttpsConnectionContext}
+import akka.http.scaladsl.{ Http, HttpsConnectionContext }
import example.myapp.echo.EchoServiceImpl
import example.myapp.echo.grpc.EchoServiceHandler
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/echo/EchoServiceImpl.scala b/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/echo/EchoServiceImpl.scala
index 17451c2a..4988c518 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/echo/EchoServiceImpl.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/02-multiple-services/src/main/scala/example/myapp/echo/EchoServiceImpl.scala
@@ -6,4 +6,4 @@ import example.myapp.echo.grpc._
class EchoServiceImpl extends EchoService {
def echo(in: EchoMessage): Future[EchoMessage] = Future.successful(in)
-}
\ No newline at end of file
+}
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/project/plugins.sbt b/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/project/plugins.sbt
index ac863a66..646e81fd 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/project/plugins.sbt
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/project/plugins.sbt
@@ -1 +1 @@
-addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version"))
\ No newline at end of file
+addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version"))
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/src/test/scala/example/myapp/echo/EchoServiceImpl.scala b/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/src/test/scala/example/myapp/echo/EchoServiceImpl.scala
index 17451c2a..4988c518 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/src/test/scala/example/myapp/echo/EchoServiceImpl.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/03-test-config/src/test/scala/example/myapp/echo/EchoServiceImpl.scala
@@ -6,4 +6,4 @@ import example.myapp.echo.grpc._
class EchoServiceImpl extends EchoService {
def echo(in: EchoMessage): Future[EchoMessage] = Future.successful(in)
-}
\ No newline at end of file
+}
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/04-server-reflection/src/main/scala/example/myapp/helloworld/Main.scala b/sbt-plugin/src/sbt-test/gen-scala-server/04-server-reflection/src/main/scala/example/myapp/helloworld/Main.scala
index 2d5183fa..0e7121f2 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/04-server-reflection/src/main/scala/example/myapp/helloworld/Main.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/04-server-reflection/src/main/scala/example/myapp/helloworld/Main.scala
@@ -18,53 +18,52 @@ import example.myapp.helloworld.grpc._
//#server-reflection
-
object Main extends App {
- val conf = ConfigFactory
- .parseString("akka.http.server.preview.enable-http2 = on")
- .withFallback(ConfigFactory.defaultApplication())
- implicit val sys = ActorSystem("HelloWorld", conf)
-
- implicit val mat: Materializer = ActorMaterializer()
- implicit val ec: ExecutionContext = sys.dispatcher
-
- //#server-reflection
- // Create service handler with a fallback to a Server Reflection handler.
- // `.withServerReflection` is a convenience method that contacts a partial
- // function of the provided service with a reflection handler for that
- // same service.
- val greeter: HttpRequest => Future[HttpResponse] =
- GreeterServiceHandler.withServerReflection(new GreeterServiceImpl())
-
- // Bind service handler servers to localhost:8080
- val binding = Http().bindAndHandleAsync(
- greeter,
- interface = "127.0.0.1",
- port = 8080,
- connectionContext = HttpConnectionContext())
- //#server-reflection
-
- // report successful binding
- binding.foreach { binding =>
- println(s"gRPC server bound to: ${binding.localAddress}")
- }
-
- //#server-reflection-manual-concat
- // Create service handlers
- val greeterPartial: PartialFunction[HttpRequest, Future[HttpResponse]] =
- GreeterServiceHandler.partial(new GreeterServiceImpl(), "greeting-prefix")
- val echoPartial: PartialFunction[HttpRequest, Future[HttpResponse]] =
- EchoServiceHandler.partial(new EchoServiceImpl())
- // Create the reflection handler for multiple services
- val reflection =
- ServerReflection.partial(List(GreeterService, EchoService))
-
- // Concatenate the partial functions into a single handler
- val handler =
- ServiceHandler.concatOrNotFound(
- greeterPartial,
- echoPartial,
- reflection),
- //#server-reflection-manual-concat
-
-}
\ No newline at end of file
+ val conf = ConfigFactory
+ .parseString("akka.http.server.preview.enable-http2 = on")
+ .withFallback(ConfigFactory.defaultApplication())
+ implicit val sys = ActorSystem("HelloWorld", conf)
+
+ implicit val mat: Materializer = ActorMaterializer()
+ implicit val ec: ExecutionContext = sys.dispatcher
+
+ // #server-reflection
+ // Create service handler with a fallback to a Server Reflection handler.
+ // `.withServerReflection` is a convenience method that contacts a partial
+ // function of the provided service with a reflection handler for that
+ // same service.
+ val greeter: HttpRequest => Future[HttpResponse] =
+ GreeterServiceHandler.withServerReflection(new GreeterServiceImpl())
+
+ // Bind service handler servers to localhost:8080
+ val binding = Http().bindAndHandleAsync(
+ greeter,
+ interface = "127.0.0.1",
+ port = 8080,
+ connectionContext = HttpConnectionContext())
+ // #server-reflection
+
+ // report successful binding
+ binding.foreach { binding =>
+ println(s"gRPC server bound to: ${binding.localAddress}")
+ }
+
+ // #server-reflection-manual-concat
+ // Create service handlers
+ val greeterPartial: PartialFunction[HttpRequest, Future[HttpResponse]] =
+ GreeterServiceHandler.partial(new GreeterServiceImpl(), "greeting-prefix")
+ val echoPartial: PartialFunction[HttpRequest, Future[HttpResponse]] =
+ EchoServiceHandler.partial(new EchoServiceImpl())
+ // Create the reflection handler for multiple services
+ val reflection =
+ ServerReflection.partial(List(GreeterService, EchoService))
+
+ // Concatenate the partial functions into a single handler
+ val handler =
+ ServiceHandler.concatOrNotFound(
+ greeterPartial,
+ echoPartial,
+ reflection),
+ // #server-reflection-manual-concat
+
+}
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/09-scalapb-customizations/project/plugins.sbt b/sbt-plugin/src/sbt-test/gen-scala-server/09-scalapb-customizations/project/plugins.sbt
index ac863a66..646e81fd 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/09-scalapb-customizations/project/plugins.sbt
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/09-scalapb-customizations/project/plugins.sbt
@@ -1 +1 @@
-addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version"))
\ No newline at end of file
+addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version"))
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/10-scalapb-validate/src/main/scala/example/myapp/Main.scala b/sbt-plugin/src/sbt-test/gen-scala-server/10-scalapb-validate/src/main/scala/example/myapp/Main.scala
index b940c6d4..9aa1f393 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/10-scalapb-validate/src/main/scala/example/myapp/Main.scala
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/10-scalapb-validate/src/main/scala/example/myapp/Main.scala
@@ -1,6 +1,6 @@
package example.myapp
-import scala.util.{Failure, Success, Try}
+import scala.util.{ Failure, Success, Try }
import scalapb.validate._
import example.myapp.helloworld.grpc.HelloRequest
diff --git a/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/build.sbt b/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/build.sbt
index 5d874b80..9daada35 100644
--- a/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/build.sbt
+++ b/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/build.sbt
@@ -7,5 +7,4 @@ scalacOptions += "-Xfatal-warnings"
enablePlugins(AkkaGrpcPlugin)
libraryDependencies ++= Seq(
- "org.scalatest" %% "scalatest" % "3.2.9" % "test"
-)
+ "org.scalatest" %% "scalatest" % "3.2.9" % "test")
diff --git a/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/src/test/scala/example/myapp/helloworld/GreeterServiceSpec.scala b/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/src/test/scala/example/myapp/helloworld/GreeterServiceSpec.scala
index 649270e4..6589e775 100644
--- a/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/src/test/scala/example/myapp/helloworld/GreeterServiceSpec.scala
+++ b/sbt-plugin/src/sbt-test/scala3/01-basic-client-server/src/test/scala/example/myapp/helloworld/GreeterServiceSpec.scala
@@ -12,7 +12,7 @@ import example.myapp.helloworld.grpc._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.concurrent.PatienceConfiguration
import org.scalatest.matchers.should.Matchers
-import org.scalatest.time.{ Span, Millis, Seconds }
+import org.scalatest.time.{ Millis, Seconds, Span }
import org.scalatest.wordspec.AnyWordSpec
class GreeterServiceSpec extends AnyWordSpec with Matchers with ScalaFutures:
@@ -26,14 +26,12 @@ class GreeterServiceSpec extends AnyWordSpec with Matchers with ScalaFutures:
val client = GreeterServiceClient(
GrpcClientSettings.connectToServiceAt(
"localhost",
- binding.localAddress.getPort
- ).withTls(false)
- )
+ binding.localAddress.getPort).withTls(false))
"A GreeterService" should {
"respond to a unary request" in {
val reply = client.sayHello(HelloRequest("Dave"))
val r = scala.concurrent.Await.result(reply, 10.seconds)
- r.message shouldBe("Hello, Dave!")
+ r.message shouldBe "Hello, Dave!"
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org