Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improving workflow config #156

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion akka-javasdk-maven/akka-javasdk-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<!-- These are dependent on runtime environment and cannot be customized by users -->
<maven.compiler.release>21</maven.compiler.release>
<kalix-runtime.version>1.3.0-940b627</kalix-runtime.version>
<kalix-runtime.version>1.3.0-2ecdbe3</kalix-runtime.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skip.docker>false</skip.docker>
Expand Down
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,
aludwiko marked this conversation as resolved.
Show resolved Hide resolved
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
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Dependencies {
val ProtocolVersionMinor = 1
val RuntimeImage = "gcr.io/kalix-public/kalix-runtime"
// Remember to bump kalix-runtime.version in akka-javasdk-maven/akka-javasdk-parent if bumping this
val RuntimeVersion = sys.props.getOrElse("kalix-runtime.version", "1.3.0-940b627")
val RuntimeVersion = sys.props.getOrElse("kalix-runtime.version", "1.3.0-2ecdbe3")
}
// NOTE: embedded SDK should have the AkkaVersion aligned, when updating RuntimeVersion, make sure to check
// if AkkaVersion and AkkaHttpVersion are aligned
Expand Down
Loading