This repository was archived by the owner on Dec 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
gRPC
Arsene edited this page Sep 10, 2020
·
1 revision
The gRPC is an interface that helps interact with both the Write Side and the Read Side using gRPC service calls.
-
Define your gRPC services as explained here
-
Add the following lines to your
build.sbtfile:
PB.protoSources in Compile := Seq(file(<path-to-your-proto-definitions>))
PB.includePaths in Compile ++= Seq(file(<path-to-your-include>))
akkaGrpcGeneratedLanguages := Seq(AkkaGrpc.Scala),
akkaGrpcExtraGenerators in Compile += PlayScalaServerCodeGenerator,
akkaGrpcExtraGenerators in Compile += PlayScalaClientCodeGenerator,
akkaGrpcCodeGeneratorSettings += "server_power_apis",
akkaGrpcCodeGeneratorSettings := akkaGrpcCodeGeneratorSettings.value.filterNot(_ == "flat_package")
-
From the root folder of your project run
sbt clean compileto generate the grpc scala traits. -
Implement the generated traits by injecting the following
akka.cluster.sharding.typed.scaladsl.ClusterShardingandcom.lightbend.lagom.scaladsl.persistence.PersistentEntityRegistryand mixed in withio.superflat.lagompb.BaseGrpcServiceImplto be able to interact with the domain model implementation.
Example:
class AccountGrpcServiceImpl(
sys: ActorSystem,
val clusterSharding: ClusterSharding,
val aggregateRoot: AggregateRoot
)(implicit ec: ExecutionContext)
extends AbstractAccountGrpcServicePowerApiRouter(sys)
with BaseGrpcServiceImpl{
// your implementation goes in here
}Copyright © 2020 superflat