temporalio / temporalio/sdk-java

Scala module

Open
#1,007 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
433
Forks
249
Avg merge
5d 6h
Merged PRs (30d)
26

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the listed WorkflowClient.start/execute and Workflow.await interop cases, then assess Scala Option and collection serialization and Scala Duration support. The Java method-reference example and existing wrapper snippets define additional requirements. Done means a coherent Scala module addresses the listed interop and type-conversion needs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.