Skip to content

Commit

Permalink
add a task interface
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiesheng committed Feb 18, 2025
1 parent 52dd229 commit a0d53b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions internal/internal_task_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const (
defaultMediumLivedWorkflowTimeoutUpperLimitInSec = 8 * 3600
)

var (
_ autoConfigHintAwareTask = (*workflowTask)(nil)
_ autoConfigHintAwareTask = (*activityTask)(nil)
)

type (
// workflowExecutionEventHandler process a single event.
workflowExecutionEventHandler interface {
Expand All @@ -72,6 +77,11 @@ type (
Close()
}

// autoConfigHintAwareTask is a task that can provide auto config hint
autoConfigHintAwareTask interface {
getAutoConfigHint() *s.AutoConfigHint
}

// workflowTask wraps a decision task.
workflowTask struct {
task *s.PollForDecisionTaskResponse
Expand Down Expand Up @@ -153,6 +163,20 @@ type (
}
)

func (t *workflowTask) getAutoConfigHint() *s.AutoConfigHint {
if t.task != nil {
return t.task.AutoConfigHint
}
return nil
}

func (t *activityTask) getAutoConfigHint() *s.AutoConfigHint {
if t.task != nil {
return t.task.AutoConfigHint
}
return nil
}

func newHistory(task *workflowTask, eventsHandler *workflowExecutionEventHandlerImpl) *history {
result := &history{
workflowTask: task,
Expand Down
4 changes: 2 additions & 2 deletions internal/internal_worker_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ func (bw *baseWorker) pollTask() {
bw.retrier.Failed()
} else {
bw.retrier.Succeeded()
if bw.concurrencyAutoScaler != nil {
bw.concurrencyAutoScaler.ProcessPollerHint(getAutoConfigHint(task))
if t, ok :=task.(autoConfigHintAwareTask); bw.concurrencyAutoScaler != nil && ok {
bw.concurrencyAutoScaler.ProcessPollerHint(t.getAutoConfigHint())
}
}
}
Expand Down

0 comments on commit a0d53b5

Please sign in to comment.