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).
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package versionhistory
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
historyspb "github.com/hanzoai/tasks/api/history/v1"
|
|
)
|
|
|
|
// NewVersionHistoryItem create a new instance of VersionHistoryItem.
|
|
func NewVersionHistoryItem(eventID int64, version int64) *historyspb.VersionHistoryItem {
|
|
if eventID < 0 || version < 0 {
|
|
panic(fmt.Sprintf("invalid version history item event ID: %v, version: %v", eventID, version))
|
|
}
|
|
|
|
return &historyspb.VersionHistoryItem{EventId: eventID, Version: version}
|
|
}
|
|
|
|
// CopyVersionHistoryItem create a new instance of VersionHistoryItem.
|
|
func CopyVersionHistoryItem(item *historyspb.VersionHistoryItem) *historyspb.VersionHistoryItem {
|
|
return NewVersionHistoryItem(item.EventId, item.Version)
|
|
}
|
|
|
|
// IsEqualVersionHistoryItem checks whether version history items are equal
|
|
func IsEqualVersionHistoryItem(item1 *historyspb.VersionHistoryItem, item2 *historyspb.VersionHistoryItem) bool {
|
|
return item1.EventId == item2.EventId && item1.Version == item2.Version
|
|
}
|
|
|
|
// IsEqualVersionHistoryItems checks whether version history items are equal
|
|
func IsEqualVersionHistoryItems(items1 []*historyspb.VersionHistoryItem, items2 []*historyspb.VersionHistoryItem) bool {
|
|
if len(items1) != len(items2) {
|
|
return false
|
|
}
|
|
for i := range items1 {
|
|
if !IsEqualVersionHistoryItem(items1[i], items2[i]) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// CompareVersionHistoryItem compares 2 version history items
|
|
func CompareVersionHistoryItem(item1 *historyspb.VersionHistoryItem, item2 *historyspb.VersionHistoryItem) int {
|
|
if item1.Version < item2.Version {
|
|
return -1
|
|
}
|
|
if item1.Version > item2.Version {
|
|
return 1
|
|
}
|
|
|
|
// item1.Version == item2.Version
|
|
if item1.EventId < item2.EventId {
|
|
return -1
|
|
}
|
|
if item1.EventId > item2.EventId {
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|