@@ -1413,6 +1413,18 @@ func WithWorkflowTaskList(ctx Context, name string) Context {
1413
1413
return ctx1
1414
1414
}
1415
1415
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
+
1416
1428
// WithWorkflowID adds a workflowID to the context.
1417
1429
func WithWorkflowID (ctx Context , workflowID string ) Context {
1418
1430
ctx1 := setWorkflowEnvOptionsIfNotExist (ctx )
@@ -1794,12 +1806,21 @@ func WithLocalActivityOptions(ctx Context, options LocalActivityOptions) Context
1794
1806
}
1795
1807
1796
1808
// 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
1797
1810
func WithTaskList (ctx Context , name string ) Context {
1798
1811
ctx1 := setActivityParametersIfNotExist (ctx )
1799
1812
getActivityOptions (ctx1 ).TaskListName = name
1800
1813
return ctx1
1801
1814
}
1802
1815
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
+
1803
1824
// WithScheduleToCloseTimeout adds a timeout to the copy of the context.
1804
1825
// The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is
1805
1826
// subjected to change in the future.
0 commit comments