Skip to content

Commit

Permalink
chore: new workflow spi adt
Browse files Browse the repository at this point in the history
  • Loading branch information
octonato committed Dec 13, 2024
1 parent 98e726e commit 6c199fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,35 +137,37 @@ class WorkflowImpl[S, W <: Workflow[S]](

effect match {
case error: ErrorEffectImpl[_] =>
new SpiWorkflow.Effect(
persistence = SpiWorkflow.NoPersistence, // mean runtime don't need to persist any new state
SpiWorkflow.NoTransition,
reply = None,
error = Some(new SpiEntity.Error(error.description)),
metadata = SpiMetadata.Empty)
new SpiWorkflow.ErrorEffect(new SpiEntity.Error(error.description))

case WorkflowEffectImpl(persistence, transition, reply) =>
val (replyOpt, spiMetadata) =
val (replyBytes, spiMetadata) =
reply match {
case ReplyValue(value, metadata) => (Some(value), MetadataImpl.toSpi(metadata))
// discarded
case NoReply => (None, SpiMetadata.Empty)
case ReplyValue(value, metadata) => (serializer.toBytes(value), MetadataImpl.toSpi(metadata))
// FIXME: WorkflowEffectImpl never contain a NoReply
case NoReply => (BytesPayload.empty, SpiMetadata.Empty)
}

new SpiWorkflow.Effect(
handleState(persistence),
toSpiTransition(transition),
reply = replyOpt.map(serializer.toBytes),
error = None,
metadata = spiMetadata)
val spiTransition = toSpiTransition(transition)

handleState(persistence) match {
case upt: SpiWorkflow.UpdateState =>
new SpiWorkflow.WriteEffect(upt, spiTransition, replyBytes, spiMetadata)

case SpiWorkflow.NoPersistence =>
// no persistence and no transition, is a reply only effect
if (spiTransition == SpiWorkflow.NoTransition)
new SpiWorkflow.ReadOnlyEffect(replyBytes, spiMetadata)
else
new SpiWorkflow.WriteEffect(SpiWorkflow.NoPersistence, spiTransition, replyBytes, spiMetadata)

case SpiWorkflow.DeleteState =>
// TODO: delete not yet supported, therefore always ReplyEffect
throw new IllegalArgumentException("State deletion not supported yet")

}

case TransitionalEffectImpl(persistence, transition) =>
new SpiWorkflow.Effect(
handleState(persistence),
toSpiTransition(transition),
reply = None,
error = None,
metadata = SpiMetadata.Empty)
new SpiWorkflow.TransitionalEffect(handleState(persistence), toSpiTransition(transition))
}
}

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-03a3a40")
val RuntimeVersion = sys.props.getOrElse("kalix-runtime.version", "1.3.0-03a3a40-5-677e7803-SNAPSHOT")
}
// NOTE: embedded SDK should have the AkkaVersion aligned, when updating RuntimeVersion, make sure to check
// if AkkaVersion and AkkaHttpVersion are aligned
Expand Down

0 comments on commit 6c199fd

Please sign in to comment.