Skip to content

Commit

Permalink
chore: improving workflow config
Browse files Browse the repository at this point in the history
  • Loading branch information
aludwiko committed Jan 16, 2025
1 parent d28fb66 commit 1c59142
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,28 @@ class WorkflowImpl[S, W <: Workflow[S]](
new SpiWorkflow.RecoverStrategy(sdkRecoverStrategy.maxRetries, failoverTo = stepTransition)
}

val failoverTo = {
definition.getFailoverStepName.toScala.map { stepName =>
new SpiWorkflow.StepTransition(stepName, definition.getFailoverStepInput.toScala.map(serializer.toBytes))
}
}

val stepConfigs =
definition.getStepConfigs.asScala.map { config =>
val stepTimeout = config.timeout.toScala.map(_.toScala)
val failoverRecoverStrategy = config.recoverStrategy.toScala.map(toRecovery)
(config.stepName, new SpiWorkflow.StepConfig(config.stepName, stepTimeout, failoverRecoverStrategy))
}.toMap

val failoverRecoverStrategy = definition.getStepRecoverStrategy.toScala.map(toRecovery)
val defaultStepRecoverStrategy = definition.getStepRecoverStrategy.toScala.map(toRecovery)

val failoverRecoverStrategy = definition.getFailoverStepName.toScala.map(stepName =>
//when failoverStepName exists, maxRetries must exist
new SpiWorkflow.RecoverStrategy(
definition.getFailoverMaxRetries.toScala.get.maxRetries,
new SpiWorkflow.StepTransition(stepName, definition.getFailoverStepInput.toScala.map(serializer.toBytes))))

val stepTimeout = definition.getStepTimeout.toScala.map(_.toScala)

new SpiWorkflow.WorkflowConfig(
workflowTimeout = definition.getWorkflowTimeout.toScala.map(_.toScala),
failoverTo = failoverTo,
failoverRecoverStrategy = failoverRecoverStrategy,
defaultStepTimeout = stepTimeout,
defaultStepRecoverStrategy = failoverRecoverStrategy,
defaultStepRecoverStrategy = defaultStepRecoverStrategy,
stepConfigs = stepConfigs)
}

Expand Down
24 changes: 3 additions & 21 deletions akka-javasdk/src/test/scala/akka/javasdk/impl/AnySupportSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

package akka.javasdk.impl

import kalix.protocol.discovery.{ DiscoveryProto, UserFunctionError }
import kalix.protocol.event_sourced_entity.EventSourcedEntityProto
import com.google.protobuf.any.{ Any => ScalaPbAny }
import com.google.protobuf.{ Any => JavaPbAny }
import com.google.protobuf.ByteString
Expand All @@ -15,29 +13,13 @@ import org.scalatest.wordspec.AnyWordSpec

class AnySupportSpec extends AnyWordSpec with Matchers with OptionValues {

private val anySupport = new AnySupport(
Array(EventSourcedEntityProto.javaDescriptor, DiscoveryProto.javaDescriptor),
getClass.getClassLoader,
"com.example")
private val anySupport = new AnySupport(Array.empty, getClass.getClassLoader, "com.example")

private val anySupportScala = new AnySupport(
Array(EventSourcedEntityProto.javaDescriptor, DiscoveryProto.javaDescriptor),
getClass.getClassLoader,
"com.example",
AnySupport.PREFER_SCALA)
private val anySupportScala =
new AnySupport(Array.empty, getClass.getClassLoader, "com.example", AnySupport.PREFER_SCALA)

"Any support for Java" should {

"support se/deserializing scala protobufs" in {
val error = UserFunctionError("error")
val any = anySupport.encodeScala(UserFunctionError("error"))
any.typeUrl should ===("com.example/kalix.protocol.UserFunctionError")

val decoded = anySupport.decodePossiblyPrimitive(any)
decoded.getClass should ===(error.getClass)
decoded should ===(error)
}

def testPrimitive[T](name: String, value: T, defaultValue: T) = {
val any = anySupport.encodeScala(value)
any.typeUrl should ===(AnySupport.KalixPrimitive + name)
Expand Down

0 comments on commit 1c59142

Please sign in to comment.