Skip to content
This repository was archived by the owner on Dec 27, 2021. It is now read-only.
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.

Implementation

  • Define your gRPC services as explained here

  • Add the following lines to your build.sbt file:

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 compile to generate the grpc scala traits.

  • Implement the generated traits by injecting the following akka.cluster.sharding.typed.scaladsl.ClusterSharding and com.lightbend.lagom.scaladsl.persistence.PersistentEntityRegistry and mixed in with io.superflat.lagompb.BaseGrpcServiceImpl to 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
}

Clone this wiki locally