mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +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`.
119 lines
4.0 KiB
Go
119 lines
4.0 KiB
Go
package api
|
|
|
|
import (
|
|
historyspb "go.temporal.io/server/api/history/v1"
|
|
"go.temporal.io/server/api/historyservice/v1"
|
|
tokenspb "go.temporal.io/server/api/token/v1"
|
|
"go.temporal.io/server/service/history/consts"
|
|
)
|
|
|
|
// NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
|
|
func GeneratePaginationTokenV2Request(
|
|
request *historyservice.GetWorkflowExecutionRawHistoryV2Request,
|
|
versionHistories *historyspb.VersionHistories,
|
|
) *tokenspb.RawHistoryContinuation {
|
|
|
|
req := request.Request
|
|
execution := req.Execution
|
|
return &tokenspb.RawHistoryContinuation{
|
|
NamespaceId: req.GetNamespaceId(),
|
|
WorkflowId: execution.GetWorkflowId(),
|
|
RunId: execution.GetRunId(),
|
|
StartEventId: req.GetStartEventId(),
|
|
StartEventVersion: req.GetStartEventVersion(),
|
|
EndEventId: req.GetEndEventId(),
|
|
EndEventVersion: req.GetEndEventVersion(),
|
|
VersionHistories: versionHistories,
|
|
PersistenceToken: nil, // this is the initialized value
|
|
}
|
|
}
|
|
|
|
// NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
|
|
func ValidatePaginationTokenV2Request(
|
|
request *historyservice.GetWorkflowExecutionRawHistoryV2Request,
|
|
token *tokenspb.RawHistoryContinuation,
|
|
) error {
|
|
|
|
req := request.Request
|
|
execution := req.Execution
|
|
if req.GetNamespaceId() != token.GetNamespaceId() ||
|
|
execution.GetWorkflowId() != token.GetWorkflowId() ||
|
|
execution.GetRunId() != token.GetRunId() ||
|
|
req.GetStartEventId() != token.GetStartEventId() ||
|
|
req.GetStartEventVersion() != token.GetStartEventVersion() ||
|
|
req.GetEndEventId() != token.GetEndEventId() ||
|
|
req.GetEndEventVersion() != token.GetEndEventVersion() {
|
|
return consts.ErrInvalidPaginationToken
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
|
|
func SerializeRawHistoryToken(token *tokenspb.RawHistoryContinuation) ([]byte, error) {
|
|
if token == nil {
|
|
return nil, nil
|
|
}
|
|
return token.Marshal()
|
|
}
|
|
|
|
// NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
|
|
func DeserializeRawHistoryToken(bytes []byte) (*tokenspb.RawHistoryContinuation, error) {
|
|
token := &tokenspb.RawHistoryContinuation{}
|
|
err := token.Unmarshal(bytes)
|
|
return token, err
|
|
}
|
|
|
|
// NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
|
|
func SerializeHistoryToken(token *tokenspb.HistoryContinuation) ([]byte, error) {
|
|
if token == nil {
|
|
return nil, nil
|
|
}
|
|
return token.Marshal()
|
|
}
|
|
|
|
// NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go
|
|
func DeserializeHistoryToken(bytes []byte) (*tokenspb.HistoryContinuation, error) {
|
|
token := &tokenspb.HistoryContinuation{}
|
|
err := token.Unmarshal(bytes)
|
|
return token, err
|
|
}
|
|
|
|
func GeneratePaginationToken(
|
|
request *historyservice.GetWorkflowExecutionRawHistoryRequest,
|
|
versionHistories *historyspb.VersionHistories,
|
|
) *tokenspb.RawHistoryContinuation {
|
|
|
|
req := request.Request
|
|
execution := req.Execution
|
|
return &tokenspb.RawHistoryContinuation{
|
|
NamespaceId: req.GetNamespaceId(),
|
|
WorkflowId: execution.GetWorkflowId(),
|
|
RunId: execution.GetRunId(),
|
|
StartEventId: req.GetStartEventId(),
|
|
StartEventVersion: req.GetStartEventVersion(),
|
|
EndEventId: req.GetEndEventId(),
|
|
EndEventVersion: req.GetEndEventVersion(),
|
|
VersionHistories: versionHistories,
|
|
PersistenceToken: nil, // this is the initialized value
|
|
}
|
|
}
|
|
|
|
func ValidatePaginationToken(
|
|
request *historyservice.GetWorkflowExecutionRawHistoryRequest,
|
|
token *tokenspb.RawHistoryContinuation,
|
|
) error {
|
|
|
|
req := request.Request
|
|
execution := req.Execution
|
|
if req.GetNamespaceId() != token.GetNamespaceId() ||
|
|
execution.GetWorkflowId() != token.GetWorkflowId() ||
|
|
execution.GetRunId() != token.GetRunId() ||
|
|
req.GetStartEventId() != token.GetStartEventId() ||
|
|
req.GetStartEventVersion() != token.GetStartEventVersion() ||
|
|
req.GetEndEventId() != token.GetEndEventId() ||
|
|
req.GetEndEventVersion() != token.GetEndEventVersion() {
|
|
return consts.ErrInvalidPaginationToken
|
|
}
|
|
return nil
|
|
}
|