mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
101 lines
2.5 KiB
Go
101 lines
2.5 KiB
Go
//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination history_branch_util_mock.go
|
|
|
|
package persistence
|
|
|
|
import (
|
|
"time"
|
|
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
persistencespb "go.temporal.io/server/api/persistence/v1"
|
|
"go.temporal.io/server/common/persistence/serialization"
|
|
"go.temporal.io/server/common/primitives"
|
|
)
|
|
|
|
type (
|
|
HistoryBranchUtil interface {
|
|
NewHistoryBranch(
|
|
namespaceID string,
|
|
workflowID string,
|
|
runID string,
|
|
treeID string,
|
|
branchID *string,
|
|
ancestors []*persistencespb.HistoryBranchRange,
|
|
runTimeout time.Duration,
|
|
executionTimeout time.Duration,
|
|
retentionDuration time.Duration,
|
|
) ([]byte, error)
|
|
// ParseHistoryBranchInfo parses the history branch for branch information
|
|
ParseHistoryBranchInfo(
|
|
branchToken []byte,
|
|
) (*persistencespb.HistoryBranch, error)
|
|
// UpdateHistoryBranchInfo updates the history branch with branch information
|
|
UpdateHistoryBranchInfo(
|
|
branchToken []byte,
|
|
branchInfo *persistencespb.HistoryBranch,
|
|
runID string,
|
|
) ([]byte, error)
|
|
}
|
|
|
|
HistoryBranchUtilImpl struct {
|
|
}
|
|
)
|
|
|
|
func (u *HistoryBranchUtilImpl) NewHistoryBranch(
|
|
_ string, // namespaceID
|
|
_ string, // workflowID
|
|
_ string, // runID
|
|
treeID string,
|
|
branchID *string,
|
|
ancestors []*persistencespb.HistoryBranchRange,
|
|
_ time.Duration, // runTimeout
|
|
_ time.Duration, // executionTimeout
|
|
_ time.Duration, // retentionDuration
|
|
) ([]byte, error) {
|
|
var id string
|
|
if branchID == nil {
|
|
id = primitives.NewUUID().String()
|
|
} else {
|
|
id = *branchID
|
|
}
|
|
bi := &persistencespb.HistoryBranch{
|
|
TreeId: treeID,
|
|
BranchId: id,
|
|
Ancestors: ancestors,
|
|
}
|
|
data, err := serialization.HistoryBranchToBlob(bi)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return data.Data, nil
|
|
}
|
|
|
|
func (u *HistoryBranchUtilImpl) ParseHistoryBranchInfo(
|
|
branchToken []byte,
|
|
) (*persistencespb.HistoryBranch, error) {
|
|
return serialization.HistoryBranchFromBlob(branchToken, enumspb.ENCODING_TYPE_PROTO3.String())
|
|
}
|
|
|
|
func (u *HistoryBranchUtilImpl) UpdateHistoryBranchInfo(
|
|
branchToken []byte,
|
|
branchInfo *persistencespb.HistoryBranch,
|
|
runID string,
|
|
) ([]byte, error) {
|
|
bi, err := serialization.HistoryBranchFromBlob(branchToken, enumspb.ENCODING_TYPE_PROTO3.String())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bi.TreeId = branchInfo.TreeId
|
|
bi.BranchId = branchInfo.BranchId
|
|
bi.Ancestors = branchInfo.Ancestors
|
|
|
|
blob, err := serialization.HistoryBranchToBlob(bi)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return blob.Data, nil
|
|
}
|
|
|
|
func (u *HistoryBranchUtilImpl) GetHistoryBranchUtil() HistoryBranchUtil {
|
|
return u
|
|
}
|