question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’ll go with a top-to-bottom approach with the things I encountered, and how I tried to solve them in my project.

  1. 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
 }
  1. 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

  1. 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()
    })
  }
  1. 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

  1. Accepting Scala Duration type

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

5reactions
vitaliihontacommented, Jun 22, 2022

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.

4reactions
kthamcommented, Feb 20, 2022

Would love the additional support for Scala 👍 it could potentially unlock some interesting use-cases if I can pitch Temporal to my team

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found