Skip to content

Commit e317f06

Browse files
authored
add purge options (#638)
* add options to PurgeWorkflow Signed-off-by: Fabian Martinez <[email protected]> * Update client.go Signed-off-by: Fabian Martinez <[email protected]> --------- Signed-off-by: Fabian Martinez <[email protected]>
1 parent 4953b12 commit e317f06

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/go-chi/chi/v5 v5.1.0
88
github.com/golang/mock v1.6.0
99
github.com/google/uuid v1.6.0
10-
github.com/microsoft/durabletask-go v0.5.0
10+
github.com/microsoft/durabletask-go v0.5.1-0.20241014200046-fac9dd959f4d
1111
github.com/stretchr/testify v1.9.0
1212
google.golang.org/grpc v1.65.0
1313
google.golang.org/protobuf v1.34.2

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2828
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2929
github.com/marusama/semaphore/v2 v2.5.0 h1:o/1QJD9DBYOWRnDhPwDVAXQn6mQYD0gZaS1Tpx6DJGM=
3030
github.com/marusama/semaphore/v2 v2.5.0/go.mod h1:z9nMiNUekt/LTpTUQdpp+4sJeYqUGpwMHfW0Z8V8fnQ=
31-
github.com/microsoft/durabletask-go v0.5.0 h1:4DWBgg05wnkV/VwakaiPqZ4cARvATP74ZQJFcXVMC18=
32-
github.com/microsoft/durabletask-go v0.5.0/go.mod h1:goe2gmMgLptCijMDQ7JsekaR86KjPUG64V9JDXvKBhE=
31+
github.com/microsoft/durabletask-go v0.5.1-0.20241014200046-fac9dd959f4d h1:Phnx8/wPd9BM6RPIjlqNl8kAaFjtU+Sdw9CzmZd8Wsw=
32+
github.com/microsoft/durabletask-go v0.5.1-0.20241014200046-fac9dd959f4d/go.mod h1:goe2gmMgLptCijMDQ7JsekaR86KjPUG64V9JDXvKBhE=
3333
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
3434
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3535
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=

workflow/client.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ func WithRawOutput(data string) api.TerminateOptions {
9898
return api.WithRawOutput(data)
9999
}
100100

101+
// WithRecursiveTerminate configures whether to terminate all sub-workflows created by the target workflow.
102+
func WithRecursiveTerminate(recursive bool) api.TerminateOptions {
103+
return api.WithRecursiveTerminate(recursive)
104+
}
105+
106+
// WithRecursivePurge configures whether to purge all sub-workflows created by the target workflow.
107+
func WithRecursivePurge(recursive bool) api.PurgeOptions {
108+
return api.WithRecursivePurge(recursive)
109+
}
110+
101111
type clientOption func(*clientOptions) error
102112

103113
type clientOptions struct {
@@ -225,9 +235,9 @@ func (c *Client) ResumeWorkflow(ctx context.Context, id, reason string) error {
225235

226236
// PurgeWorkflow will purge a given workflow and return an error output.
227237
// NOTE: The workflow must be in a terminated or completed state.
228-
func (c *Client) PurgeWorkflow(ctx context.Context, id string) error {
238+
func (c *Client) PurgeWorkflow(ctx context.Context, id string, opts ...api.PurgeOptions) error {
229239
if id == "" {
230240
return errors.New("no workflow id specified")
231241
}
232-
return c.taskHubClient.PurgeOrchestrationState(ctx, api.InstanceID(id))
242+
return c.taskHubClient.PurgeOrchestrationState(ctx, api.InstanceID(id), opts...)
233243
}

0 commit comments

Comments
 (0)