Skip to content

Commit ca6e00a

Browse files
committed
workflows: support timer names
Signed-off-by: Fabian Martinez <[email protected]>
1 parent a3df75f commit ca6e00a

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.23.6
44

55
require (
66
github.com/dapr/dapr v1.15.0-rc.17
7-
github.com/dapr/durabletask-go v0.6.3
7+
github.com/dapr/durabletask-go v0.7.1
88
github.com/go-chi/chi/v5 v5.1.0
99
github.com/golang/mock v1.6.0
1010
github.com/google/uuid v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
22
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
33
github.com/dapr/dapr v1.15.0-rc.17 h1:bR0rd4FH81IteuOHTWVNyl58ZuQTDp3DYaTtXnpZ6JA=
44
github.com/dapr/dapr v1.15.0-rc.17/go.mod h1:SD0AXom2XpX7pr8eYlbJ+gHfNREsflsrzCR19AZJ7/Q=
5-
github.com/dapr/durabletask-go v0.6.3 h1:WHhSAw1YL4xneK3Jo5nGfmMaJxfFodIIF5q1rpkDDfs=
6-
github.com/dapr/durabletask-go v0.6.3/go.mod h1:nTZ5fCbJLnZbVdi6Z2YxdDF1OgQZL3LroogGuetrwuA=
5+
github.com/dapr/durabletask-go v0.7.1 h1:FiTlVVFh0UnYdqoFeUtgT7BszkGMA0eL0qjgfB7YOr0=
6+
github.com/dapr/durabletask-go v0.7.1/go.mod h1:JhMyDybRUFmmgieGxCPeg9e2cWwtx4LwNXjD+LBtKYk=
77
github.com/dapr/kit v0.15.0 h1:446jrEOQV/0rt6FwmoKrifP3vav5+Uh/u38DqU8q+JM=
88
github.com/dapr/kit v0.15.0/go.mod h1:HwFsBKEbcyLanWlDZE7u/jnaDCD/tU+n3pkFNUctQNw=
99
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

workflow/context.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ func (wfc *WorkflowContext) CallChildWorkflow(workflow interface{}, opts ...call
9494
// The value passed to the Await method must be a pointer or can be nil to ignore the returned value.
9595
// Alternatively, tasks can be awaited using the task.WhenAll or task.WhenAny methods, allowing the workflow
9696
// to block and wait for multiple tasks at the same time.
97-
func (wfc *WorkflowContext) CreateTimer(duration time.Duration) task.Task {
97+
func (wfc *WorkflowContext) CreateTimer(duration time.Duration, opts ...createTimerOption) task.Task {
98+
options := new(createTimerOptions)
99+
for _, configure := range opts {
100+
if err := configure(options); err != nil {
101+
return nil
102+
}
103+
}
104+
if options.name != nil {
105+
return wfc.orchestrationContext.CreateTimer(duration, task.WithTimerName(*options.name))
106+
}
98107
return wfc.orchestrationContext.CreateTimer(duration)
99108
}
100109

workflow/workflow.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,16 @@ func NewTaskSlice(length int) []task.Task {
148148
taskSlice := make([]task.Task, length)
149149
return taskSlice
150150
}
151+
152+
type createTimerOption func(*createTimerOptions) error
153+
154+
type createTimerOptions struct {
155+
name *string
156+
}
157+
158+
func WithTimerName(name string) createTimerOption {
159+
return func(opt *createTimerOptions) error {
160+
opt.name = &name
161+
return nil
162+
}
163+
}

0 commit comments

Comments
 (0)