Skip to content

Commit

Permalink
Merge branch 'master' into taylan/strict_nondeterminism_option
Browse files Browse the repository at this point in the history
  • Loading branch information
agautam478 authored Nov 6, 2023
2 parents 718a795 + ae5a7e6 commit 80e6cbf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/internal_workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ func (env *testWorkflowEnvironmentImpl) newTestWorkflowEnvironmentForChild(param
childEnv.testWorkflowEnvironmentShared = env.testWorkflowEnvironmentShared
childEnv.workerOptions = env.workerOptions
childEnv.workerOptions.DataConverter = params.dataConverter
childEnv.workflowInterceptors = env.workflowInterceptors
childEnv.registry = env.registry

if params.workflowID == "" {
Expand Down
21 changes: 21 additions & 0 deletions internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,18 @@ func WithWorkflowTaskList(ctx Context, name string) Context {
return ctx1
}

// WithWorkflowTaskListMapper returns a copy of context and changes workflow tasklist with mapper function.
func WithWorkflowTaskListMapper(ctx Context, mapper func(string) string) Context {
ctx1 := setWorkflowEnvOptionsIfNotExist(ctx)
var taskList string
if getWorkflowEnvOptions(ctx1).taskListName != nil {
taskList = *getWorkflowEnvOptions(ctx1).taskListName
}
newTaskList := mapper(taskList)
getWorkflowEnvOptions(ctx1).taskListName = &newTaskList
return ctx1
}

// WithWorkflowID adds a workflowID to the context.
func WithWorkflowID(ctx Context, workflowID string) Context {
ctx1 := setWorkflowEnvOptionsIfNotExist(ctx)
Expand Down Expand Up @@ -1794,12 +1806,21 @@ func WithLocalActivityOptions(ctx Context, options LocalActivityOptions) Context
}

// WithTaskList adds a task list to the copy of the context.
// Note this shall not confuse with WithWorkflowTaskList. This is the tasklist for activities
func WithTaskList(ctx Context, name string) Context {
ctx1 := setActivityParametersIfNotExist(ctx)
getActivityOptions(ctx1).TaskListName = name
return ctx1
}

// WithTaskListMapper makes a copy of the context and apply the tasklist mapper function
// Note this shall not confuse with WithWorkflowTaskListMapper. This is the tasklist for activities.
func WithTaskListMapper(ctx Context, mapper func(string) string) Context {
ctx1 := setActivityParametersIfNotExist(ctx)
getActivityOptions(ctx1).TaskListName = mapper(getActivityOptions(ctx1).TaskListName)
return ctx1
}

// WithScheduleToCloseTimeout adds a timeout to the copy of the context.
// The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is
// subjected to change in the future.
Expand Down
6 changes: 6 additions & 0 deletions workflow/activity_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ func WithTaskList(ctx Context, name string) Context {
return internal.WithTaskList(ctx, name)
}

// WithTaskListMapper makes a copy of current context and update the tasklist with mapper function.
// Note this is the tasklist for activity tasklist. For workflow tasklist, use WithWorkflowTaskListMapper
func WithTaskListMapper(ctx Context, mapper func(string) string) Context {
return internal.WithTaskListMapper(ctx, mapper)
}

// WithScheduleToCloseTimeout makes a copy of the current context and update
// the ScheduleToCloseTimeout field in its activity options. An empty activity
// options will be created if it does not exist in the original context.
Expand Down
5 changes: 5 additions & 0 deletions workflow/workflow_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func WithWorkflowTaskList(ctx Context, name string) Context {
return internal.WithWorkflowTaskList(ctx, name)
}

// WithWorkflowTaskListMapper returns a copy of Context with changed tasklist
func WithWorkflowTaskListMapper(ctx Context, mapper func(name string) string) Context {
return internal.WithWorkflowTaskListMapper(ctx, mapper)
}

// WithWorkflowID adds a workflowID to the context.
func WithWorkflowID(ctx Context, workflowID string) Context {
return internal.WithWorkflowID(ctx, workflowID)
Expand Down

0 comments on commit 80e6cbf

Please sign in to comment.