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.5 KiB
Go
59 lines
1.5 KiB
Go
package tasktoken
|
|
|
|
import (
|
|
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
|
|
tokenspb "github.com/hanzoai/tasks/api/token/v1"
|
|
)
|
|
|
|
type Serializer struct{}
|
|
|
|
// NewSerializer creates a new instance of Serializer
|
|
func NewSerializer() *Serializer {
|
|
return &Serializer{}
|
|
}
|
|
|
|
func (s *Serializer) Serialize(taskToken *tokenspb.Task) ([]byte, error) {
|
|
if taskToken == nil {
|
|
return nil, nil
|
|
}
|
|
return taskToken.Marshal()
|
|
}
|
|
|
|
func (s *Serializer) Deserialize(data []byte) (*tokenspb.Task, error) {
|
|
taskToken := &tokenspb.Task{}
|
|
err := taskToken.Unmarshal(data)
|
|
return taskToken, err
|
|
}
|
|
|
|
func (s *Serializer) SerializeQueryTaskToken(taskToken *tokenspb.QueryTask) ([]byte, error) {
|
|
if taskToken == nil {
|
|
return nil, nil
|
|
}
|
|
return taskToken.Marshal()
|
|
}
|
|
|
|
func (s *Serializer) DeserializeQueryTaskToken(data []byte) (*tokenspb.QueryTask, error) {
|
|
taskToken := tokenspb.QueryTask{}
|
|
err := taskToken.Unmarshal(data)
|
|
return &taskToken, err
|
|
}
|
|
|
|
func (s *Serializer) SerializeNexusTaskToken(taskToken *tokenspb.NexusTask) ([]byte, error) {
|
|
if taskToken == nil {
|
|
return nil, nil
|
|
}
|
|
return taskToken.Marshal()
|
|
}
|
|
|
|
func (s *Serializer) DeserializeNexusTaskToken(data []byte) (*tokenspb.NexusTask, error) {
|
|
taskToken := tokenspb.NexusTask{}
|
|
err := taskToken.Unmarshal(data)
|
|
return &taskToken, err
|
|
}
|
|
|
|
func (s *Serializer) DeserializeChasmComponentRef(data []byte) (*persistencespb.ChasmComponentRef, error) {
|
|
token := persistencespb.ChasmComponentRef{}
|
|
err := token.Unmarshal(data)
|
|
return &token, err
|
|
}
|