Skip to content

Commit 80e6cbf

Browse files
authored
Merge branch 'master' into taylan/strict_nondeterminism_option
2 parents 718a795 + ae5a7e6 commit 80e6cbf

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

internal/internal_workflow_testsuite.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ func (env *testWorkflowEnvironmentImpl) newTestWorkflowEnvironmentForChild(param
363363
childEnv.testWorkflowEnvironmentShared = env.testWorkflowEnvironmentShared
364364
childEnv.workerOptions = env.workerOptions
365365
childEnv.workerOptions.DataConverter = params.dataConverter
366+
childEnv.workflowInterceptors = env.workflowInterceptors
366367
childEnv.registry = env.registry
367368

368369
if params.workflowID == "" {

internal/workflow.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,18 @@ func WithWorkflowTaskList(ctx Context, name string) Context {
14131413
return ctx1
14141414
}
14151415

1416+
// WithWorkflowTaskListMapper returns a copy of context and changes workflow tasklist with mapper function.
1417+
func WithWorkflowTaskListMapper(ctx Context, mapper func(string) string) Context {
1418+
ctx1 := setWorkflowEnvOptionsIfNotExist(ctx)
1419+
var taskList string
1420+
if getWorkflowEnvOptions(ctx1).taskListName != nil {
1421+
taskList = *getWorkflowEnvOptions(ctx1).taskListName
1422+
}
1423+
newTaskList := mapper(taskList)
1424+
getWorkflowEnvOptions(ctx1).taskListName = &newTaskList
1425+
return ctx1
1426+
}
1427+
14161428
// WithWorkflowID adds a workflowID to the context.
14171429
func WithWorkflowID(ctx Context, workflowID string) Context {
14181430
ctx1 := setWorkflowEnvOptionsIfNotExist(ctx)
@@ -1794,12 +1806,21 @@ func WithLocalActivityOptions(ctx Context, options LocalActivityOptions) Context
17941806
}
17951807

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

1816+
// WithTaskListMapper makes a copy of the context and apply the tasklist mapper function
1817+
// Note this shall not confuse with WithWorkflowTaskListMapper. This is the tasklist for activities.
1818+
func WithTaskListMapper(ctx Context, mapper func(string) string) Context {
1819+
ctx1 := setActivityParametersIfNotExist(ctx)
1820+
getActivityOptions(ctx1).TaskListName = mapper(getActivityOptions(ctx1).TaskListName)
1821+
return ctx1
1822+
}
1823+
18031824
// WithScheduleToCloseTimeout adds a timeout to the copy of the context.
18041825
// The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is
18051826
// subjected to change in the future.

workflow/activity_options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ func WithTaskList(ctx Context, name string) Context {
5858
return internal.WithTaskList(ctx, name)
5959
}
6060

61+
// WithTaskListMapper makes a copy of current context and update the tasklist with mapper function.
62+
// Note this is the tasklist for activity tasklist. For workflow tasklist, use WithWorkflowTaskListMapper
63+
func WithTaskListMapper(ctx Context, mapper func(string) string) Context {
64+
return internal.WithTaskListMapper(ctx, mapper)
65+
}
66+
6167
// WithScheduleToCloseTimeout makes a copy of the current context and update
6268
// the ScheduleToCloseTimeout field in its activity options. An empty activity
6369
// options will be created if it does not exist in the original context.

workflow/workflow_options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func WithWorkflowTaskList(ctx Context, name string) Context {
4242
return internal.WithWorkflowTaskList(ctx, name)
4343
}
4444

45+
// WithWorkflowTaskListMapper returns a copy of Context with changed tasklist
46+
func WithWorkflowTaskListMapper(ctx Context, mapper func(name string) string) Context {
47+
return internal.WithWorkflowTaskListMapper(ctx, mapper)
48+
}
49+
4550
// WithWorkflowID adds a workflowID to the context.
4651
func WithWorkflowID(ctx Context, workflowID string) Context {
4752
return internal.WithWorkflowID(ctx, workflowID)

0 commit comments

Comments
 (0)