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_2.13 Show documentation
Show all versions of pekko-grpc-codegen_2.13 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 _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: 02d0d9db4c2c8f97bcae196f2fa9332d989c8655
MATRIX: 687->364|834->418|862->420|873->423|943->472|971->473|1007->482|1023->489|1056->501|1085->503|1463->855|2433->1805|2462->1807|2570->1890|2605->1904|2648->1920|2683->1934|2712->1935|2745->1941|2780->1955|2871->2021|2906->2035|2941->2042|2970->2043|3000->2046|3111->2130|3147->2144|3199->2169|3234->2183|3392->2314|3427->2328|3479->2353|3514->2367|3606->2432|3641->2446|3774->2551|3810->2565|3846->2572|3876->2573|3908->2578|3943->2586|3978->2600|4025->2620|4091->2665|4124->2671|4338->2859|4384->2889|4424->2891|4456->2896|4496->2909|4530->2922|4681->3046|4721->3048|4755->3055|4812->3085|4846->3098|4914->3149|4953->3150|5054->3224|5094->3226|5128->3233|5195->3273|5229->3286|5366->3405|5406->3407|5440->3414|5507->3454|5541->3467|5676->3585|5716->3587|5750->3594|5824->3641|5858->3654|5948->3701|5984->3707|6020->3713|6053->3720|6099->3750|6139->3752|6171->3757|6307->3866|6345->3883|6374->3885|6389->3891|6424->3905|6602->4055|6643->4057|6675->4062|6716->4076|6754->4093|6815->4127|6830->4133|6865->4147|6895->4150|6910->4156|6950->4174|6987->4185|7021->4198|7089->4249|7128->4250|7160->4255|7201->4269|7239->4286|7300->4320|7315->4326|7350->4340|7380->4343|7395->4349|7435->4367|7472->4378|7506->4391|7581->4436|7614->4442|7716->4517|7754->4534|7787->4540|7826->4552|7864->4569|7897->4575|7912->4581|7947->4595|7978->4599|7993->4605|8025->4616|8054->4617|8090->4626|8129->4643|8179->4662|8213->4668|8474->4901|8503->4902|8532->4903|8561->4904|8591->4906|8645->4934|8681->4948|8725->4963|8755->4964|8786->4968|8833->4998|8874->5000|8905->5003|9038->5108|9077->5125|9107->5127|9123->5133|9159->5147|9334->5293|9376->5295|9407->5298|9439->5303|9478->5320|9540->5354|9556->5360|9592->5374|9623->5377|9639->5383|9680->5401|9715->5418|9755->5419|9786->5422|9818->5427|9857->5444|9919->5478|9935->5484|9971->5498|10002->5501|10018->5507|10059->5525|10101->5536|10136->5540|10166->5542|10195->5543
LINES: 16->14|21->15|22->16|22->16|22->16|23->17|23->17|23->17|23->17|25->19|40->34|54->48|56->50|58->52|58->52|58->52|58->52|58->52|58->52|58->52|61->55|61->55|61->55|61->55|62->56|62->56|62->56|63->57|63->57|64->58|64->58|65->59|65->59|67->61|67->61|67->61|67->61|67->61|67->61|68->62|68->62|68->62|68->62|68->62|70->64|74->68|74->68|74->68|75->69|75->69|75->69|76->70|76->70|77->71|77->71|77->71|78->72|78->72|79->73|79->73|80->74|80->74|80->74|81->75|81->75|82->76|82->76|82->76|83->77|83->77|84->78|84->78|84->78|85->79|86->80|87->81|89->83|89->83|89->83|90->84|92->86|92->86|92->86|92->86|92->86|94->88|94->88|95->89|95->89|95->89|95->89|95->89|95->89|95->89|95->89|95->89|96->90|96->90|97->91|97->91|98->92|98->92|98->92|98->92|98->92|98->92|98->92|98->92|98->92|99->93|99->93|100->94|102->96|103->97|103->97|104->98|105->99|105->99|105->99|105->99|105->99|105->99|105->99|105->99|105->99|106->100|106->100|107->101|109->103|114->108|114->108|115->109|115->109|117->111|118->112|118->112|118->112|118->112|119->113|119->113|119->113|120->114|122->116|122->116|122->116|122->116|122->116|124->118|124->118|125->119|125->119|125->119|125->119|125->119|125->119|125->119|125->119|125->119|126->120|126->120|127->121|127->121|127->121|127->121|127->121|127->121|127->121|127->121|127->121|128->122|129->123|131->125|131->125
-- GENERATED --
*/
© 2015 - 2025 Weber Informatics LLC | Privacy Policy