templates.ScalaClient.txt.Client.template.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pekko-grpc-codegen_3 Show documentation
Show all versions of pekko-grpc-codegen_3 Show documentation
Apache Pekko gRPC - Support for building streaming gRPC servers and clients on top of Pekko Streams.
The newest version!
package templates.ScalaClient.txt
import _root_.play.twirl.api.TwirlFeatureImports.*
import _root_.play.twirl.api.TwirlHelperImports.*
import scala.language.adhocExtensions
import _root_.play.twirl.api.Html
import _root_.play.twirl.api.JavaScript
import _root_.play.twirl.api.Txt
import _root_.play.twirl.api.Xml
object Client extends _root_.play.twirl.api.BaseScalaTemplate[play.twirl.api.TxtFormat.Appendable,_root_.play.twirl.api.Format[play.twirl.api.TxtFormat.Appendable]](play.twirl.api.TxtFormat) with _root_.play.twirl.api.Template1[org.apache.pekko.grpc.gen.scaladsl.Service,play.twirl.api.TxtFormat.Appendable] {
/*
* Copyright (C) 2018-2021 Lightbend Inc.
*/
def apply/*14.2*/(service: org.apache.pekko.grpc.gen.scaladsl.Service):play.twirl.api.TxtFormat.Appendable = {
_display_ {
{
Seq[Any](format.raw/*15.1*/("""
"""),_display_(/*16.2*/org/*16.5*/.apache.pekko.grpc.gen.Constants.DoNotEditComment),format.raw/*16.54*/("""
"""),format.raw/*17.1*/("""package """),_display_(/*17.10*/service/*17.17*/.packageName),format.raw/*17.29*/("""
"""),format.raw/*19.1*/("""import scala.concurrent.ExecutionContext
import org.apache.pekko
import pekko.actor.ClassicActorSystemProvider
import pekko.grpc.GrpcChannel
import pekko.grpc.GrpcClientCloseException
import pekko.grpc.GrpcClientSettings
import pekko.grpc.scaladsl.PekkoGrpcClient
import pekko.grpc.internal.NettyClientUtils
import pekko.grpc.PekkoGrpcGenerated
"""),_display_(/*34.2*/{
def withSingleResponse(stmt: String) = Set("import pekko.grpc.scaladsl.SingleResponseRequestBuilder", stmt)
def withStreamResponse(stmt: String) = Set("import pekko.grpc.scaladsl.StreamResponseRequestBuilder", stmt)
service.methods.flatMap { (method: org.apache.pekko.grpc.gen.scaladsl.Method) =>
val statements = method.methodType match {
case org.apache.pekko.grpc.gen.Unary => withSingleResponse("import pekko.grpc.internal.ScalaUnaryRequestBuilder")
case org.apache.pekko.grpc.gen.ClientStreaming => withSingleResponse("import pekko.grpc.internal.ScalaClientStreamingRequestBuilder")
case org.apache.pekko.grpc.gen.ServerStreaming => withStreamResponse("import pekko.grpc.internal.ScalaServerStreamingRequestBuilder")
case org.apache.pekko.grpc.gen.BidiStreaming => withStreamResponse("import pekko.grpc.internal.ScalaBidirectionalStreamingRequestBuilder")
}
statements
}.distinct.mkString("\n")
}),format.raw/*48.2*/("""
"""),format.raw/*50.1*/("""// Not sealed so users can extend to write their stubs
@PekkoGrpcGenerated
trait """),_display_(/*52.8*/{service.name}),format.raw/*52.22*/("""Client extends """),_display_(/*52.38*/{service.name}),format.raw/*52.52*/(""" """),format.raw/*52.53*/("""with """),_display_(/*52.59*/{service.name}),format.raw/*52.73*/("""ClientPowerApi with PekkoGrpcClient
@PekkoGrpcGenerated
object """),_display_(/*55.9*/{service.name}),format.raw/*55.23*/("""Client """),format.raw/*55.30*/("""{"""),format.raw/*55.31*/("""
"""),format.raw/*56.3*/("""def apply(settings: GrpcClientSettings)(implicit sys: ClassicActorSystemProvider): """),_display_(/*56.87*/{service.name}),format.raw/*56.101*/("""Client =
new Default"""),_display_(/*57.17*/{service.name}),format.raw/*57.31*/("""Client(GrpcChannel(settings), isChannelOwned = true)
def apply(channel: GrpcChannel)(implicit sys: ClassicActorSystemProvider): """),_display_(/*58.79*/{service.name}),format.raw/*58.93*/("""Client =
new Default"""),_display_(/*59.17*/{service.name}),format.raw/*59.31*/("""Client(channel, isChannelOwned = false)
private class Default"""),_display_(/*61.25*/{service.name}),format.raw/*61.39*/("""Client(channel: GrpcChannel, isChannelOwned: Boolean)(implicit sys: ClassicActorSystemProvider) extends """),_display_(/*61.144*/{service.name}),format.raw/*61.158*/("""Client """),format.raw/*61.165*/("""{"""),format.raw/*61.166*/("""
"""),format.raw/*62.5*/("""import """),_display_(/*62.13*/{service.name}),format.raw/*62.27*/(""".MethodDescriptors."""),_display_(/*62.47*/{service.scalaCompatConstants.WildcardImport}),format.raw/*62.92*/("""
"""),format.raw/*64.5*/("""private implicit val ex: ExecutionContext = sys.classicSystem.dispatcher
private val settings = channel.settings
private val options = NettyClientUtils.callOptions(settings)
"""),_display_(/*68.6*/for(method <- service.methods) yield /*68.36*/ {_display_(Seq[Any](format.raw/*68.38*/("""
"""),format.raw/*69.5*/("""private def """),_display_(/*69.18*/{method.name}),format.raw/*69.31*/("""RequestBuilder(channel: pekko.grpc.internal.InternalChannel) =
"""),_display_(if(method.methodType == org.apache.pekko.grpc.gen.Unary)/*70.62*/ {_display_(Seq[Any](format.raw/*70.64*/("""
"""),format.raw/*71.7*/("""new ScalaUnaryRequestBuilder("""),_display_(/*71.37*/{method.name}),format.raw/*71.50*/("""Descriptor, channel, options, settings)
""")))}else/*72.12*/{_display_(Seq[Any](format.raw/*72.13*/("""
"""),_display_(if(method.methodType == org.apache.pekko.grpc.gen.ServerStreaming)/*73.74*/ {_display_(Seq[Any](format.raw/*73.76*/("""
"""),format.raw/*74.7*/("""new ScalaServerStreamingRequestBuilder("""),_display_(/*74.47*/{method.name}),format.raw/*74.60*/("""Descriptor, channel, options, settings)
""")))}else if(method.methodType == org.apache.pekko.grpc.gen.ClientStreaming)/*75.80*/ {_display_(Seq[Any](format.raw/*75.82*/("""
"""),format.raw/*76.7*/("""new ScalaClientStreamingRequestBuilder("""),_display_(/*76.47*/{method.name}),format.raw/*76.60*/("""Descriptor, channel, options, settings)
""")))}else if(method.methodType == org.apache.pekko.grpc.gen.BidiStreaming)/*77.79*/ {_display_(Seq[Any](format.raw/*77.81*/("""
"""),format.raw/*78.7*/("""new ScalaBidirectionalStreamingRequestBuilder("""),_display_(/*78.54*/{method.name}),format.raw/*78.67*/("""Descriptor, channel, options, settings)
""")))} else {null} ),format.raw/*79.8*/("""
""")))}),format.raw/*80.6*/("""
""")))}),format.raw/*81.6*/("""
"""),_display_(/*83.6*/for(method <- service.methods) yield /*83.36*/ {_display_(Seq[Any](format.raw/*83.38*/("""
"""),format.raw/*84.5*/("""/**
* Lower level "lifted" version of the method, giving access to request metadata etc.
* prefer """),_display_(/*86.16*/{method.nameSafe}),format.raw/*86.33*/("""("""),_display_(/*86.35*/method/*86.41*/.parameterType),format.raw/*86.55*/(""") if possible.
*/
"""),_display_(if(method.methodType == org.apache.pekko.grpc.gen.Unary || method.methodType == org.apache.pekko.grpc.gen.ClientStreaming)/*88.128*/ {_display_(Seq[Any](format.raw/*88.130*/("""
"""),format.raw/*89.5*/("""override def """),_display_(/*89.19*/{method.nameSafe}),format.raw/*89.36*/("""(): SingleResponseRequestBuilder["""),_display_(/*89.70*/method/*89.76*/.parameterType),format.raw/*89.90*/(""", """),_display_(/*89.93*/method/*89.99*/.outputTypeUnboxed),format.raw/*89.117*/("""] =
"""),_display_(/*90.8*/{method.name}),format.raw/*90.21*/("""RequestBuilder(channel.internalChannel)
""")))}else/*91.12*/{_display_(Seq[Any](format.raw/*91.13*/("""
"""),format.raw/*92.5*/("""override def """),_display_(/*92.19*/{method.nameSafe}),format.raw/*92.36*/("""(): StreamResponseRequestBuilder["""),_display_(/*92.70*/method/*92.76*/.parameterType),format.raw/*92.90*/(""", """),_display_(/*92.93*/method/*92.99*/.outputTypeUnboxed),format.raw/*92.117*/("""] =
"""),_display_(/*93.8*/{method.name}),format.raw/*93.21*/("""RequestBuilder(channel.internalChannel)
""")))}),format.raw/*94.6*/("""
"""),format.raw/*96.5*/("""/**
* For access to method metadata use the parameterless version of """),_display_(/*97.72*/{method.nameSafe}),format.raw/*97.89*/("""
"""),format.raw/*98.6*/("""*/
def """),_display_(/*99.10*/{method.nameSafe}),format.raw/*99.27*/("""(in: """),_display_(/*99.33*/method/*99.39*/.parameterType),format.raw/*99.53*/("""): """),_display_(/*99.57*/method/*99.63*/.returnType),format.raw/*99.74*/(""" """),format.raw/*99.75*/("""=
"""),_display_(/*100.8*/{method.nameSafe}),format.raw/*100.25*/("""().invoke(in)
""")))}),format.raw/*101.6*/("""
"""),format.raw/*103.5*/("""override def close(): scala.concurrent.Future[pekko.Done] =
if (isChannelOwned) channel.close()
else throw new GrpcClientCloseException()
override def closed: scala.concurrent.Future[pekko.Done] = channel.closed()
"""),format.raw/*108.3*/("""}"""),format.raw/*108.4*/("""
"""),format.raw/*109.1*/("""}"""),format.raw/*109.2*/("""
"""),format.raw/*111.1*/("""@PekkoGrpcGenerated
trait """),_display_(/*112.8*/{service.name}),format.raw/*112.22*/("""ClientPowerApi """),format.raw/*112.37*/("""{"""),format.raw/*112.38*/("""
"""),_display_(/*113.4*/for(method <- service.methods) yield /*113.34*/ {_display_(Seq[Any](format.raw/*113.36*/("""
"""),format.raw/*114.3*/("""/**
* Lower level "lifted" version of the method, giving access to request metadata etc.
* prefer """),_display_(/*116.14*/{method.nameSafe}),format.raw/*116.31*/("""("""),_display_(/*116.33*/method/*116.39*/.parameterType),format.raw/*116.53*/(""") if possible.
*/
"""),_display_(if(method.methodType == org.apache.pekko.grpc.gen.Unary || method.methodType == org.apache.pekko.grpc.gen.ClientStreaming)/*118.126*/ {_display_(Seq[Any](format.raw/*118.128*/("""
"""),format.raw/*119.3*/("""def """),_display_(/*119.8*/{method.nameSafe}),format.raw/*119.25*/("""(): SingleResponseRequestBuilder["""),_display_(/*119.59*/method/*119.65*/.parameterType),format.raw/*119.79*/(""", """),_display_(/*119.82*/method/*119.88*/.outputTypeUnboxed),format.raw/*119.106*/("""] = ???
""")))}else/*120.10*/{_display_(Seq[Any](format.raw/*120.11*/("""
"""),format.raw/*121.3*/("""def """),_display_(/*121.8*/{method.nameSafe}),format.raw/*121.25*/("""(): StreamResponseRequestBuilder["""),_display_(/*121.59*/method/*121.65*/.parameterType),format.raw/*121.79*/(""", """),_display_(/*121.82*/method/*121.88*/.outputTypeUnboxed),format.raw/*121.106*/("""] = ???
""")))}),format.raw/*122.4*/("""
""")))}),format.raw/*123.4*/("""
"""),format.raw/*125.1*/("""}"""),format.raw/*125.2*/("""
"""))
}
}
}
def render(service:org.apache.pekko.grpc.gen.scaladsl.Service): play.twirl.api.TxtFormat.Appendable = apply(service)
def f:((org.apache.pekko.grpc.gen.scaladsl.Service) => play.twirl.api.TxtFormat.Appendable) = (service) => apply(service)
def ref: this.type = this
}
/*
-- GENERATED --
SOURCE: codegen/src/main/twirl/templates/ScalaClient/Client.scala.txt
HASH: 187dc8b888e5a88b0428c45dcebeb08e6d786873
MATRIX: 725->364|872->418|900->420|911->423|981->472|1009->473|1045->482|1061->489|1094->501|1123->503|1501->855|2471->1805|2500->1807|2608->1890|2643->1904|2686->1920|2721->1934|2750->1935|2783->1941|2818->1955|2909->2021|2944->2035|2979->2042|3008->2043|3038->2046|3149->2130|3185->2144|3237->2169|3272->2183|3430->2314|3465->2328|3517->2353|3552->2367|3644->2432|3679->2446|3812->2551|3848->2565|3884->2572|3914->2573|3946->2578|3981->2586|4016->2600|4063->2620|4129->2665|4162->2671|4376->2859|4422->2889|4462->2891|4494->2896|4534->2909|4568->2922|4719->3046|4759->3048|4793->3055|4850->3085|4884->3098|4952->3149|4991->3150|5092->3224|5132->3226|5166->3233|5233->3273|5267->3286|5404->3405|5444->3407|5478->3414|5545->3454|5579->3467|5714->3585|5754->3587|5788->3594|5862->3641|5896->3654|5986->3701|6022->3707|6058->3713|6091->3720|6137->3750|6177->3752|6209->3757|6345->3866|6383->3883|6412->3885|6427->3891|6462->3905|6640->4055|6681->4057|6713->4062|6754->4076|6792->4093|6853->4127|6868->4133|6903->4147|6933->4150|6948->4156|6988->4174|7025->4185|7059->4198|7127->4249|7166->4250|7198->4255|7239->4269|7277->4286|7338->4320|7353->4326|7388->4340|7418->4343|7433->4349|7473->4367|7510->4378|7544->4391|7619->4436|7652->4442|7754->4517|7792->4534|7825->4540|7864->4552|7902->4569|7935->4575|7950->4581|7985->4595|8016->4599|8031->4605|8063->4616|8092->4617|8128->4626|8167->4643|8217->4662|8251->4668|8512->4901|8541->4902|8570->4903|8599->4904|8629->4906|8683->4934|8719->4948|8763->4963|8793->4964|8824->4968|8871->4998|8912->5000|8943->5003|9076->5108|9115->5125|9145->5127|9161->5133|9197->5147|9372->5293|9414->5295|9445->5298|9477->5303|9516->5320|9578->5354|9594->5360|9630->5374|9661->5377|9677->5383|9718->5401|9753->5418|9793->5419|9824->5422|9856->5427|9895->5444|9957->5478|9973->5484|10009->5498|10040->5501|10056->5507|10097->5525|10139->5536|10174->5540|10204->5542|10233->5543
LINES: 17->14|22->15|23->16|23->16|23->16|24->17|24->17|24->17|24->17|26->19|41->34|55->48|57->50|59->52|59->52|59->52|59->52|59->52|59->52|59->52|62->55|62->55|62->55|62->55|63->56|63->56|63->56|64->57|64->57|65->58|65->58|66->59|66->59|68->61|68->61|68->61|68->61|68->61|68->61|69->62|69->62|69->62|69->62|69->62|71->64|75->68|75->68|75->68|76->69|76->69|76->69|77->70|77->70|78->71|78->71|78->71|79->72|79->72|80->73|80->73|81->74|81->74|81->74|82->75|82->75|83->76|83->76|83->76|84->77|84->77|85->78|85->78|85->78|86->79|87->80|88->81|90->83|90->83|90->83|91->84|93->86|93->86|93->86|93->86|93->86|95->88|95->88|96->89|96->89|96->89|96->89|96->89|96->89|96->89|96->89|96->89|97->90|97->90|98->91|98->91|99->92|99->92|99->92|99->92|99->92|99->92|99->92|99->92|99->92|100->93|100->93|101->94|103->96|104->97|104->97|105->98|106->99|106->99|106->99|106->99|106->99|106->99|106->99|106->99|106->99|107->100|107->100|108->101|110->103|115->108|115->108|116->109|116->109|118->111|119->112|119->112|119->112|119->112|120->113|120->113|120->113|121->114|123->116|123->116|123->116|123->116|123->116|125->118|125->118|126->119|126->119|126->119|126->119|126->119|126->119|126->119|126->119|126->119|127->120|127->120|128->121|128->121|128->121|128->121|128->121|128->121|128->121|128->121|128->121|129->122|130->123|132->125|132->125
-- GENERATED --
*/
© 2015 - 2025 Weber Informatics LLC | Privacy Policy