mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
Full module path rebrand from Temporal to Hanzo Tasks: - go.mod module: github.com/hanzoai/tasks - All internal Go imports updated (1906 files) - cmd/server renamed to cmd/tasksd - Binary name: tasksd (was temporal-server) - Docker images: hanzoai/tasks (was temporalio/server) - README rewritten with Hanzo Tasks branding - LLM.md created with integration notes - Makefile, goreleaser, CI workflows updated - go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos) Fork of Temporal.io (MIT license).
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package chasm
|
|
|
|
import (
|
|
"github.com/hanzoai/tasks/common/persistence/transitionhistory"
|
|
"github.com/hanzoai/tasks/service/history/consts"
|
|
)
|
|
|
|
// ExecutionStateChanged returns true if execution state has advanced beyond the state encoded in
|
|
// refBytes. It may return ErrInvalidComponentRef or ErrMalformedComponentRef. Callers should
|
|
// consider converting these to serviceerror.NewInvalidArgument.
|
|
func ExecutionStateChanged(c Component, ctx Context, refBytes []byte) (bool, error) {
|
|
ref, err := DeserializeComponentRef(refBytes)
|
|
if err != nil {
|
|
return false, ErrMalformedComponentRef
|
|
}
|
|
currentRef, err := ctx.structuredRef(c)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if ref.ExecutionKey != currentRef.ExecutionKey {
|
|
return false, ErrInvalidComponentRef
|
|
}
|
|
switch transitionhistory.Compare(ref.executionLastUpdateVT, currentRef.executionLastUpdateVT) {
|
|
case -1:
|
|
// Execution state has advanced beyond submitted ref
|
|
return true, nil
|
|
case 0:
|
|
// Execution state has not advanced beyond submitted ref
|
|
return false, nil
|
|
case 1:
|
|
// Execution state is behind submitted ref
|
|
return false, consts.ErrStaleState
|
|
}
|
|
panic("unexpected result from transitionhistory.Compare") //nolint:forbidigo
|
|
}
|