File tree Expand file tree Collapse file tree 6 files changed +49
-3
lines changed
java-sdk-protobuf/src/main
java/kalix/javasdk/workflow
scala/kalix/javasdk/impl/workflow
scala-sdk-protobuf/src/main/scala/kalix/scalasdk Expand file tree Collapse file tree 6 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ object Dependencies {
7676
7777 val scalapbCompilerPlugin = " com.thesamet.scalapb" %% " compilerplugin" % scalapb.compiler.Version .scalapbVersion
7878 val scalaPbValidateCore = " com.thesamet.scalapb" %% " scalapb-validate-core" % " 0.3.4"
79- val sbtProtoc = " com.thesamet" % " sbt-protoc" % " 1.0.0"
79+ // keep aligned with the sbt-protoc plugin version in plugins.sbt
80+ val sbtProtoc = " com.thesamet" % " sbt-protoc" % " 1.0.3"
8081
8182 val akkaGrpc = " com.lightbend.akka.grpc" % " sbt-akka-grpc" % akka.grpc.gen.BuildInfo .version
8283 val scalaCollectionCompat = " org.scala-lang.modules" %% " scala-collection-compat" % " 2.10.0"
Original file line number Diff line number Diff line change @@ -12,3 +12,6 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
1212addSbtPlugin(" net.aichler" % " sbt-jupiter-interface" % " 0.11.0" )
1313addSbtPlugin(" com.thesamet" % " sbt-protoc" % " 1.0.3" )
1414addSbtPlugin(" com.thoughtworks.sbt-api-mappings" % " sbt-api-mappings" % " 3.0.2" )
15+
16+ // force bumped because of CI not finding 1.0.0 which was the transitive version
17+ addSbtPlugin(" org.portable-scala" % " sbt-platform-deps" % " 1.0.2" )
Original file line number Diff line number Diff line change @@ -13,4 +13,17 @@ public interface WorkflowContext extends Context {
1313 * @return The workflow id.
1414 */
1515 String workflowId ();
16+
17+ /**
18+ * Get an Akka gRPC client for the given service name. The same client instance is shared across
19+ * components in the application. The lifecycle of the client is managed by the SDK and it should
20+ * not be stopped by user code.
21+ *
22+ * @param <T> The "service" interface generated for the service by Akka gRPC
23+ * @param clientClass The class of a gRPC service generated by Akka gRPC
24+ * @param service The name of the service to connect to, either a name of another Kalix service or
25+ * an external service where connection details are configured under
26+ * `akka.grpc.client.[service-name]` in `application.conf`.
27+ */
28+ <T > T getGrpcClient (Class <T > clientClass , String service );
1629}
Original file line number Diff line number Diff line change @@ -361,8 +361,16 @@ private[kalix] final class CommandContextImpl(
361361 system : ActorSystem )
362362 extends AbstractContext (system)
363363 with CommandContext
364- with ActivatableContext
364+ with ActivatableContext {
365+ override def getGrpcClient [T ](clientClass : Class [T ], service : String ): T =
366+ GrpcClients (system).getGrpcClient(clientClass, service)
367+
368+ }
365369
366370private [kalix] final class WorkflowContextImpl (override val workflowId : String , system : ActorSystem )
367371 extends AbstractContext (system)
368- with WorkflowContext
372+ with WorkflowContext {
373+ override def getGrpcClient [T ](clientClass : Class [T ], service : String ): T =
374+ GrpcClients (system).getGrpcClient(clientClass, service)
375+
376+ }
Original file line number Diff line number Diff line change @@ -203,6 +203,9 @@ private[scalasdk] final class ScalaCommandContextAdapter(val javaSdkContext: jav
203203 case ctx : javasdk.impl.AbstractContext => ctx.getComponentGrpcClient(serviceClass)
204204 }
205205
206+ override def getGrpcClient [T ](clientClass : Class [T ], service : String ): T =
207+ javaSdkContext.getGrpcClient(clientClass, service)
208+
206209 override def materializer (): Materializer = javaSdkContext.materializer()
207210
208211 override def workflowId : String = javaSdkContext.workflowId()
@@ -211,6 +214,9 @@ private[scalasdk] final class ScalaCommandContextAdapter(val javaSdkContext: jav
211214private [scalasdk] final class ScalaWorkflowContextAdapter (javaSdkContext : javasdk.workflow.WorkflowContext )
212215 extends WorkflowContext {
213216
217+ override def getGrpcClient [T ](clientClass : Class [T ], service : String ): T =
218+ javaSdkContext.getGrpcClient(clientClass, service)
219+
214220 override def materializer (): Materializer = javaSdkContext.materializer()
215221
216222 override def workflowId : String = javaSdkContext.workflowId()
Original file line number Diff line number Diff line change @@ -15,4 +15,19 @@ trait WorkflowContext extends Context {
1515 * The workflow id.
1616 */
1717 def workflowId : String
18+
19+ /**
20+ * Get an Akka gRPC client for the given service name. The same client instance is shared across components in the
21+ * application. The lifecycle of the client is managed by the SDK and it should not be stopped by user code.
22+ *
23+ * @tparam T
24+ * The "service" interface generated for the service by Akka gRPC
25+ * @param clientClass
26+ * The class of a gRPC service generated by Akka gRPC
27+ * @param service
28+ * The name of the service to connect to, either a name of another Kalix service or an external service where
29+ * connection details are configured under `akka.grpc.client.[service-name]` in `application.conf`.
30+ */
31+ def getGrpcClient [T ](clientClass : Class [T ], service : String ): T
32+
1833}
You can’t perform that action at this time.
0 commit comments