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).
74 lines
1.8 KiB
Go
74 lines
1.8 KiB
Go
package tdbg
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
"github.com/hanzoai/tasks/api/adminservice/v1"
|
|
)
|
|
|
|
type (
|
|
DLQJobService struct {
|
|
clientFactory ClientFactory
|
|
writer io.Writer
|
|
}
|
|
)
|
|
|
|
func NewDLQJobService(
|
|
clientFactory ClientFactory,
|
|
writer io.Writer,
|
|
) *DLQV2Service {
|
|
return &DLQV2Service{
|
|
clientFactory: clientFactory,
|
|
writer: writer,
|
|
}
|
|
}
|
|
|
|
func (ac *DLQJobService) DescribeJob(c *cli.Context) error {
|
|
adminClient := ac.clientFactory.AdminClient(c)
|
|
jobToken := c.String(FlagJobToken)
|
|
jobTokenBytes, err := base64.StdEncoding.DecodeString(jobToken)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to parse job token: %w", err)
|
|
}
|
|
ctx, cancel := newContext(c)
|
|
defer cancel()
|
|
response, err := adminClient.DescribeDLQJob(ctx, &adminservice.DescribeDLQJobRequest{
|
|
JobToken: jobTokenBytes,
|
|
})
|
|
if err != nil {
|
|
return fmt.Errorf("call to DescribeDLQJob failed: %w", err)
|
|
}
|
|
err = newEncoder(ac.writer).Encode(response)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to encode DescribeDLQJob response: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (ac *DLQJobService) CancelJob(c *cli.Context) error {
|
|
adminClient := ac.clientFactory.AdminClient(c)
|
|
jobToken := c.String(FlagJobToken)
|
|
jobTokenBytes, err := base64.StdEncoding.DecodeString(jobToken)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to parse job token: %w", err)
|
|
}
|
|
reason := c.String(FlagReason)
|
|
ctx, cancel := newContext(c)
|
|
defer cancel()
|
|
response, err := adminClient.CancelDLQJob(ctx, &adminservice.CancelDLQJobRequest{
|
|
JobToken: jobTokenBytes,
|
|
Reason: reason,
|
|
})
|
|
if err != nil {
|
|
return fmt.Errorf("call to CancelDLQJob failed: %w", err)
|
|
}
|
|
err = newEncoder(ac.writer).Encode(response)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to encode CancelDLQJob response: %w", err)
|
|
}
|
|
return nil
|
|
}
|