@@ -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.
14171429func 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
17971810func 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.
0 commit comments