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`.
123 lines
3.8 KiB
Go
123 lines
3.8 KiB
Go
package archiver
|
|
|
|
import (
|
|
"errors"
|
|
|
|
archiverspb "go.temporal.io/server/api/archiver/v1"
|
|
"go.temporal.io/server/common/log"
|
|
"go.temporal.io/server/common/log/tag"
|
|
)
|
|
|
|
var (
|
|
errEmptyNamespaceID = errors.New("field NamespaceId is empty")
|
|
errEmptyNamespace = errors.New("field Namespace is empty")
|
|
errEmptyWorkflowID = errors.New("field WorkflowId is empty")
|
|
errEmptyRunID = errors.New("field RunId is empty")
|
|
errInvalidPageSize = errors.New("field PageSize should be greater than 0")
|
|
errEmptyWorkflowTypeName = errors.New("field WorkflowTypeName is empty")
|
|
errEmptyStartTime = errors.New("field StartTime is empty")
|
|
errEmptyCloseTime = errors.New("field CloseTime is empty")
|
|
)
|
|
|
|
// TagLoggerWithArchiveHistoryRequestAndURI tags logger with fields in the archive history request and the URI
|
|
func TagLoggerWithArchiveHistoryRequestAndURI(logger log.Logger, request *ArchiveHistoryRequest, URI string) log.Logger {
|
|
return log.With(
|
|
logger,
|
|
tag.ShardID(request.ShardID),
|
|
tag.ArchivalRequestNamespaceID(request.NamespaceID),
|
|
tag.ArchivalRequestNamespace(request.Namespace),
|
|
tag.ArchivalRequestWorkflowID(request.WorkflowID),
|
|
tag.ArchivalRequestRunID(request.RunID),
|
|
tag.ArchivalRequestBranchToken(request.BranchToken),
|
|
tag.ArchivalRequestNextEventID(request.NextEventID),
|
|
tag.ArchivalRequestCloseFailoverVersion(request.CloseFailoverVersion),
|
|
tag.ArchivalURI(URI),
|
|
)
|
|
}
|
|
|
|
// TagLoggerWithArchiveVisibilityRequestAndURI tags logger with fields in the archive visibility request and the URI
|
|
func TagLoggerWithArchiveVisibilityRequestAndURI(logger log.Logger, request *archiverspb.VisibilityRecord, URI string) log.Logger {
|
|
return log.With(
|
|
logger,
|
|
tag.ArchivalRequestNamespaceID(request.GetNamespaceId()),
|
|
tag.ArchivalRequestNamespace(request.GetNamespace()),
|
|
tag.ArchivalRequestWorkflowID(request.GetWorkflowId()),
|
|
tag.ArchivalRequestRunID(request.GetRunId()),
|
|
tag.ArchvialRequestWorkflowType(request.GetWorkflowTypeName()),
|
|
tag.ArchivalRequestCloseTimestamp(request.GetCloseTime()),
|
|
tag.ArchivalRequestStatus(request.GetStatus().String()),
|
|
tag.ArchivalURI(URI),
|
|
)
|
|
}
|
|
|
|
// ValidateHistoryArchiveRequest validates the archive history request
|
|
func ValidateHistoryArchiveRequest(request *ArchiveHistoryRequest) error {
|
|
if request.NamespaceID == "" {
|
|
return errEmptyNamespaceID
|
|
}
|
|
if request.WorkflowID == "" {
|
|
return errEmptyWorkflowID
|
|
}
|
|
if request.RunID == "" {
|
|
return errEmptyRunID
|
|
}
|
|
if request.Namespace == "" {
|
|
return errEmptyNamespace
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ValidateGetRequest validates the get archived history request
|
|
func ValidateGetRequest(request *GetHistoryRequest) error {
|
|
if request.NamespaceID == "" {
|
|
return errEmptyNamespaceID
|
|
}
|
|
if request.WorkflowID == "" {
|
|
return errEmptyWorkflowID
|
|
}
|
|
if request.RunID == "" {
|
|
return errEmptyRunID
|
|
}
|
|
if request.PageSize == 0 {
|
|
return errInvalidPageSize
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ValidateVisibilityArchivalRequest validates the archive visibility request
|
|
func ValidateVisibilityArchivalRequest(request *archiverspb.VisibilityRecord) error {
|
|
if request.GetNamespaceId() == "" {
|
|
return errEmptyNamespaceID
|
|
}
|
|
if request.GetNamespace() == "" {
|
|
return errEmptyNamespace
|
|
}
|
|
if request.GetWorkflowId() == "" {
|
|
return errEmptyWorkflowID
|
|
}
|
|
if request.GetRunId() == "" {
|
|
return errEmptyRunID
|
|
}
|
|
if request.GetWorkflowTypeName() == "" {
|
|
return errEmptyWorkflowTypeName
|
|
}
|
|
if request.GetStartTime() == nil || request.GetStartTime().AsTime().IsZero() {
|
|
return errEmptyStartTime
|
|
}
|
|
if request.GetCloseTime() == nil || request.GetCloseTime().AsTime().IsZero() {
|
|
return errEmptyCloseTime
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ValidateQueryRequest validates the query visibility request
|
|
func ValidateQueryRequest(request *QueryVisibilityRequest) error {
|
|
if request.NamespaceID == "" {
|
|
return errEmptyNamespaceID
|
|
}
|
|
if request.PageSize == 0 {
|
|
return errInvalidPageSize
|
|
}
|
|
return nil
|
|
}
|