All Downloads are FREE. Search and download functionalities are using the official Maven repository.

akka.grpc.gen.scaladsl.Service.scala Maven / Gradle / Ivy

Go to download

Akka gRPC - Support for building streaming gRPC servers and clients on top of Akka Streams.

There is a newer version: 2.3.4
Show newest version
/*
 * Copyright (C) 2018-2021 Lightbend Inc. 
 */

package akka.grpc.gen.scaladsl

import scala.collection.immutable
import scala.collection.JavaConverters._
import com.google.protobuf.Descriptors._
import protocgen.CodeGenRequest
import scalapb.compiler.{ DescriptorImplicits, GeneratorParams }

case class Service(
    descriptor: String,
    packageName: String,
    name: String,
    grpcName: String,
    methods: immutable.Seq[Method],
    serverPowerApi: Boolean,
    usePlayActions: Boolean,
    options: com.google.protobuf.DescriptorProtos.ServiceOptions,
    comment: Option[String] = None) {
  def serializers: Seq[Serializer] = (methods.map(_.deserializer) ++ methods.map(_.serializer)).distinct
  def packageDir = packageName.replace('.', '/')
}

object Service {
  def apply(
      request: CodeGenRequest,
      generatorParams: GeneratorParams,
      fileDesc: FileDescriptor,
      serviceDescriptor: ServiceDescriptor,
      serverPowerApi: Boolean,
      usePlayActions: Boolean): Service = {
    implicit val ops =
      DescriptorImplicits.fromCodeGenRequest(generatorParams, request)
    import ops._

    val serviceClassName = serviceDescriptor.getName

    Service(
      fileDesc.fileDescriptorObject.fullName + ".javaDescriptor",
      fileDesc.scalaPackage.fullName,
      serviceClassName,
      (if (fileDesc.getPackage.isEmpty) "" else fileDesc.getPackage + ".") + serviceDescriptor.getName,
      serviceDescriptor.getMethods.asScala.map(method => Method(method)).toList,
      serverPowerApi,
      usePlayActions,
      serviceDescriptor.getOptions,
      serviceDescriptor.comment)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy