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`.
67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package persistence
|
|
|
|
import "encoding/json"
|
|
|
|
type (
|
|
jsonHistoryTokenSerializer struct{}
|
|
// historyPagingToken is used to serialize/deserialize pagination token for ReadHistoryBranchRequest
|
|
historyPagingToken struct {
|
|
LastEventID int64
|
|
// the pagination token passing to persistence
|
|
StoreToken []byte
|
|
// recording which branchRange it is reading
|
|
CurrentRangeIndex int
|
|
FinalRangeIndex int
|
|
// LastNodeID is the last known node ID attached to a history node
|
|
LastNodeID int64
|
|
// LastTransactionID is the last known transaction ID attached to a history node
|
|
LastTransactionID int64
|
|
}
|
|
)
|
|
|
|
const notStartedIndex = -1
|
|
|
|
// newJSONHistoryTokenSerializer creates a new instance of TaskTokenSerializer
|
|
func newJSONHistoryTokenSerializer() *jsonHistoryTokenSerializer {
|
|
return &jsonHistoryTokenSerializer{}
|
|
}
|
|
|
|
func (t *historyPagingToken) SetRangeIndexes(
|
|
current int,
|
|
final int,
|
|
) {
|
|
|
|
t.CurrentRangeIndex = current
|
|
t.FinalRangeIndex = final
|
|
}
|
|
|
|
func (j *jsonHistoryTokenSerializer) Serialize(
|
|
token *historyPagingToken,
|
|
) ([]byte, error) {
|
|
|
|
data, err := json.Marshal(token)
|
|
return data, err
|
|
}
|
|
|
|
func (j *jsonHistoryTokenSerializer) Deserialize(
|
|
data []byte,
|
|
defaultLastEventID int64,
|
|
defaultLastNodeID int64,
|
|
defaultLastTransactionID int64,
|
|
) (*historyPagingToken, error) {
|
|
|
|
if len(data) == 0 {
|
|
token := historyPagingToken{
|
|
LastEventID: defaultLastEventID,
|
|
CurrentRangeIndex: notStartedIndex,
|
|
LastNodeID: defaultLastNodeID,
|
|
LastTransactionID: defaultLastTransactionID,
|
|
}
|
|
return &token, nil
|
|
}
|
|
|
|
token := historyPagingToken{}
|
|
err := json.Unmarshal(data, &token)
|
|
return &token, err
|
|
}
|