Skip to content

Commit

Permalink
Toggle text in docs by switching tabs
Browse files Browse the repository at this point in the history
(cherry picked from commit 6a6278b)

# Conflicts:
#	docs/modules/ROOT/pages/consuming-grpc.adoc
  • Loading branch information
ihostage committed Dec 25, 2023
1 parent e09b730 commit 576cfec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions docs/modules/ROOT/pages/consuming-grpc.adoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
== Using a gRPC client in Play
= 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
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]
[tabs,sync-group-id=lang]
====
Scala::
+
Expand Down Expand Up @@ -33,17 +33,16 @@ 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
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 module file is generated in [.lang-scala]#`example.myapp.helloworld.grpc.helloworld.AkkaGrpcClientModule`,# [.lang-java]#`example.myapp.helloworld.grpc.AkkaGrpcClientModule`,#, which corresponds to the default value
of `flat_package` for [.lang-scala]#Scala.# [.lang-java]#Java.# 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
the `java_package` option in the proto-file (if there are multiple different gRPC generated clients the module will
be generated in the longest package prefix shared between the clients).

To hook it into Play, in `application.conf`:

[tabs]
[tabs,sync-group-id=lang]
====
Scala::
+
Expand Down Expand Up @@ -73,7 +72,7 @@ when injecting the client (see https://github.com/akka/akka-grpc/issues/271[#271

You can now use the client in a controller by injecting it:

[tabs]
[tabs,sync-group-id=lang]
====
Scala::
+
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/gradle-support.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
== Gradle support in Play
= 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:
Expand Down
10 changes: 5 additions & 5 deletions docs/modules/ROOT/pages/serving-grpc.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
== Serving gRPC from Play
= 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.
Expand All @@ -17,7 +17,7 @@ libraryDependencies += "com.typesafe.play" %% "play-grpc-generators" % "{page-co

Then you need to enable the Play server side code generator in `build.sbt`:

[tabs]
[tabs,sync-group-id=lang]
====
Scala::
+
Expand Down Expand Up @@ -46,10 +46,10 @@ The plugin will look for `.proto` service descriptors in `app/protobuf` and outp
include::example$play-interop-test-scala/src/main/proto/helloworld.proto[tags=protoSources]
----

You will get an abstract class named `example.myapp.helloworld.grpc.helloworld.AbstractGreeterServiceRouter` (or `example.myapp.helloworld.grpc.AbstractGreeterServiceRouter`). Create a concrete subclass implementing this
wherever you see fit in your project, let's say `controller.GreeterServiceImpl` like so:
You will get an abstract class named [.lang-scala]#`example.myapp.helloworld.grpc.helloworld.AbstractGreeterServiceRouter`.# [.lang-java]#`example.myapp.helloworld.grpc.AbstractGreeterServiceRouter`.#
Create a concrete subclass implementing this wherever you see fit in your project, let's say `controller.GreeterServiceImpl` like so:

[tabs]
[tabs,sync-group-id=lang]
====
Scala::
+
Expand Down

0 comments on commit 576cfec

Please sign in to comment.