Skip to content

Commit

Permalink
Clarify ScheduleToStartTimeout in ActivityOptions (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns authored Jul 31, 2023
1 parent 746bcf2 commit 7fe0679
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ type (
// better to rely on the default value.
// ScheduleToStartTimeout is always non-retryable. Retrying after this timeout doesn't make sense as it would
// just put the Activity Task back into the same Task Queue.
// If ScheduleToClose is not provided then this timeout is required.
// Optional: Defaults to unlimited.
ScheduleToStartTimeout time.Duration

Expand All @@ -109,7 +108,7 @@ type (
// to detect that an Activity that didn't complete on time. So this timeout should be as short as the longest
// possible execution of the Activity body. Potentially long running Activities must specify HeartbeatTimeout
// and call Activity.RecordHeartbeat(ctx, "my-heartbeat") periodically for timely failure detection.
// If ScheduleToClose is not provided then this timeout is required: Defaults to the ScheduleToCloseTimeout value.
// Either this option or ScheduleToClose is required: Defaults to the ScheduleToCloseTimeout value.
StartToCloseTimeout time.Duration

// HeartbeatTimeout - Heartbeat interval. Activity must call Activity.RecordHeartbeat(ctx, "my-heartbeat")
Expand Down
16 changes: 16 additions & 0 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,22 @@ func (ts *IntegrationTestSuite) TestWorkflowWithParallelSideEffects() {
ts.NoError(ts.executeWorkflow("test-wf-parallel-side-effects", ts.workflows.WorkflowWithParallelSideEffects, nil))
}

func (ts *IntegrationTestSuite) TestActivityTimeoutsWorkflow() {
ts.NoError(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{
ScheduleToCloseTimeout: 5 * time.Second,
}))

ts.NoError(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{
StartToCloseTimeout: 5 * time.Second,
}))

ts.Error(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{}))
ts.Error(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{
ScheduleToStartTimeout: 5 * time.Second,
}))

}

func (ts *IntegrationTestSuite) TestWorkflowWithParallelSideEffectsUsingReplay() {
replayer := worker.NewWorkflowReplayer()
replayer.RegisterWorkflowWithOptions(ts.workflows.WorkflowWithParallelSideEffects, workflow.RegisterOptions{DisableAlreadyRegisteredCheck: true})
Expand Down
5 changes: 5 additions & 0 deletions test/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,10 @@ func (w *Workflows) ConsistentQueryWorkflow(ctx workflow.Context, delay time.Dur
return nil
}

func (w *Workflows) ActivityTimeoutsWorkflow(ctx workflow.Context, activityOptions workflow.ActivityOptions) error {
activityCtx := workflow.WithActivityOptions(ctx, activityOptions)
return workflow.ExecuteActivity(activityCtx, "Sleep", time.Second).Get(ctx, nil)
}
func (w *Workflows) SignalWorkflow(ctx workflow.Context) (*commonpb.WorkflowType, error) {
s := workflow.NewSelector(ctx)

Expand Down Expand Up @@ -2289,6 +2293,7 @@ func (w *Workflows) register(worker worker.Worker) {
worker.RegisterWorkflow(w.UpdateInfoWorkflow)
worker.RegisterWorkflow(w.SignalWorkflow)
worker.RegisterWorkflow(w.CronWorkflow)
worker.RegisterWorkflow(w.ActivityTimeoutsWorkflow)
worker.RegisterWorkflow(w.CancelTimerConcurrentWithOtherCommandWorkflow)
worker.RegisterWorkflow(w.CancelMultipleCommandsOverMultipleTasks)
worker.RegisterWorkflow(w.CancelChildAndExecuteActivityRace)
Expand Down

0 comments on commit 7fe0679

Please sign in to comment.