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).
67 lines
2.4 KiB
Go
67 lines
2.4 KiB
Go
package serviceerror
|
|
|
|
import (
|
|
errordetailsspb "github.com/hanzoai/tasks/api/errordetails/v1"
|
|
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
type (
|
|
// CurrentBranchChanged represents current branch changed error.
|
|
CurrentBranchChanged struct {
|
|
Message string
|
|
CurrentBranchToken []byte
|
|
RequestBranchToken []byte
|
|
CurrentVersionedTransition *persistencespb.VersionedTransition
|
|
RequestVersionedTransition *persistencespb.VersionedTransition
|
|
st *status.Status
|
|
}
|
|
)
|
|
|
|
// NewCurrentBranchChanged returns new CurrentBranchChanged error.
|
|
// TODO: Update CurrentBranchChanged with event id and event version. Do not use branch token bytes as branch identity.
|
|
func NewCurrentBranchChanged(currentBranchToken, requestBranchToken []byte,
|
|
currentVersionedTransition, requestVersionedTransition *persistencespb.VersionedTransition) error {
|
|
return &CurrentBranchChanged{
|
|
Message: "Current and request branch tokens, or current and request versioned transitions, don't match.",
|
|
CurrentBranchToken: currentBranchToken,
|
|
RequestBranchToken: requestBranchToken,
|
|
CurrentVersionedTransition: currentVersionedTransition,
|
|
RequestVersionedTransition: requestVersionedTransition,
|
|
}
|
|
}
|
|
|
|
// Error returns string message.
|
|
func (e *CurrentBranchChanged) Error() string {
|
|
return e.Message
|
|
}
|
|
|
|
func (e *CurrentBranchChanged) Status() *status.Status {
|
|
if e.st != nil {
|
|
return e.st
|
|
}
|
|
|
|
st := status.New(codes.InvalidArgument, e.Message)
|
|
st, _ = st.WithDetails(
|
|
&errordetailsspb.CurrentBranchChangedFailure{
|
|
CurrentBranchToken: e.CurrentBranchToken,
|
|
RequestBranchToken: e.RequestBranchToken,
|
|
CurrentVersionedTransition: e.CurrentVersionedTransition,
|
|
RequestVersionedTransition: e.RequestVersionedTransition,
|
|
},
|
|
)
|
|
return st
|
|
}
|
|
|
|
func newCurrentBranchChanged(st *status.Status, errDetails *errordetailsspb.CurrentBranchChangedFailure) error {
|
|
return &CurrentBranchChanged{
|
|
Message: st.Message(),
|
|
CurrentBranchToken: errDetails.GetCurrentBranchToken(),
|
|
RequestBranchToken: errDetails.GetRequestBranchToken(),
|
|
CurrentVersionedTransition: errDetails.GetCurrentVersionedTransition(),
|
|
RequestVersionedTransition: errDetails.GetRequestVersionedTransition(),
|
|
st: st,
|
|
}
|
|
}
|