Files
tasks/service/history/replication/executable_unknown_task.go
Yu XiaandGitHub 31840b32b5 Add new rate limiter priority to support high/low replication tier (#7745)
## What changed?
Add new rate limiter priority to support high/low replication tier

## Why?
high replication tier has higher priority than the low replication tier.
The task processing part is separated. This change allow us throttled
low replication tier first.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2025-06-13 12:25:48 -07:00

80 lines
1.5 KiB
Go

package replication
import (
"fmt"
"time"
"go.temporal.io/api/serviceerror"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/metrics"
ctasks "go.temporal.io/server/common/tasks"
)
type (
ExecutableUnknownTask struct {
ProcessToolBox
ExecutableTask
task any
}
)
const (
unknownTaskID = "unknown-task-id"
)
var _ ctasks.Task = (*ExecutableUnknownTask)(nil)
var _ TrackableExecutableTask = (*ExecutableUnknownTask)(nil)
func NewExecutableUnknownTask(
processToolBox ProcessToolBox,
taskID int64,
taskCreationTime time.Time,
task any,
) *ExecutableUnknownTask {
return &ExecutableUnknownTask{
ProcessToolBox: processToolBox,
ExecutableTask: NewExecutableTask(
processToolBox,
taskID,
metrics.UnknownTaskScope,
taskCreationTime,
time.Now().UTC(),
"sourceCluster",
ClusterShardKey{
ClusterID: 0,
ShardID: 0,
},
nil,
),
task: task,
}
}
func (e *ExecutableUnknownTask) QueueID() interface{} {
return unknownTaskID
}
func (e *ExecutableUnknownTask) Execute() error {
return serviceerror.NewInvalidArgument(
fmt.Sprintf("unknown task, ID: %v, task: %v", e.TaskID(), e.task),
)
}
func (e *ExecutableUnknownTask) HandleErr(err error) error {
return err
}
func (e *ExecutableUnknownTask) IsRetryableError(err error) bool {
return false
}
func (e *ExecutableUnknownTask) MarkPoisonPill() error {
e.Logger.Error("unable to enqueue unknown replication task to DLQ",
tag.Task(e.task),
tag.TaskID(e.ExecutableTask.TaskID()),
)
return nil
}