Scala module
See original GitHub issueI’ll go with a top-to-bottom approach with the things I encountered, and how I tried to solve them in my project.
- WorkflowClient
- WorkflowClient.start with
io.temporal.workflow.Functions.Func
arguments - WorkflowClient.start with
io.temporal.workflow.Functions.Proc
arguments - WorkflowClient.execute with
io.temporal.workflow.Functions.Func
arguments - WorkflowClient.execute with
io.temporal.workflow.Functions.Proc
arguments
Solved this by writing some small wrappers. I don’t think this is the way, but the code inside might be useful. These are the only type of functions I needed, didn’t convert them all (e.g the ones that take more arguments)
def startAsync(f: T => Unit, arg: T): WorkflowExecution = {
WorkflowClient.start(new Proc1[T]() {
override def apply(j: T): Unit = f(j)
}, t)
}
def executeAsyncVoid(f: () => Unit): Future[Unit] = {
import scala.compat.java8.FutureConverters._
WorkflowClient.execute(new Proc {
override def apply(): Unit = f()
}).toScala.map[Unit](_ => ())
}
def executeAsync[T](f: () => T): Future[T] = {
import scala.compat.java8.FutureConverters._
WorkflowClient.execute(new Func[T] {
override def apply(): T = f()
}).toScala
}
- Scala specific object types serialization/deserialization
- Option
- List (basically all Scala collections)
We can probably solve this when Jackson will be integrated in java-sdk
- Workflow.await requiring a Supplier, instead of passing a function reference
Again, solved in a simple wrapper
def await(duration: Duration, f: () => Boolean) {
Workflow.await(duration, new Supplier[lang.Boolean] {
override def get(): lang.Boolean = f()
})
}
- Java way of referencing some method (not sure how this syntax it’s called in Java) (Mostly the same as 1. but I put it in a different issue as it’s a little bit a different problem)
WorkflowClient.execute(workflow::getGreeting, "World")
-> notice the double colon
- Accepting Scala Duration type
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
Scala module - Play Framework
This module is for the Play 1.x series only. Play Scala enables you to use the Scala language for your application keeping key...
Read more >Scala 3 modules: How to build modular systems
To understand this solution, you have to understand the concept of a module. The book, Programming in Scala — co-written by Martin Odersky ......
Read more >What is a first class module in Scala? - Stack Overflow
A "module" is a pluggable piece of software, also called a "package" sometimes. It provides a functionality through a well-defined set of ...
Read more >README.md - GitHub
The Scala Module supports serialization and limited deserialization of Scala Case Classes, Sequence s, Map s, Tuple s, Option s, and Enumerations.
Read more >sbt-scala-module - Scaladex
Scala modules sbt plugin. This is an sbt 1.x plugin for building Scala modules. ... addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0").
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi everyone, basically I’ve implemented Scala SDK which supports most temporal features. https://github.com/vitaliihonta/ztemporal
It allows to use protobuf via ScalaPB as a protocol layer as well as jackson.
Currently it’s tied to ZIO, but I could add plain Scala Futures and Cats as well.
Would love the additional support for Scala 👍 it could potentially unlock some interesting use-cases if I can pitch Temporal to my team