Skip to content

Commit 0f452bd

Browse files
committed
Expose workflow client in go-sdk
Signed-off-by: joshvanl <[email protected]>
1 parent 04eb4c6 commit 0f452bd

File tree

8 files changed

+19
-15
lines changed

8 files changed

+19
-15
lines changed

client/client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"sync"
2828
"time"
2929

30+
"github.com/dapr/durabletask-go/workflow"
3031
"github.com/dapr/go-sdk/actor"
3132
"github.com/dapr/go-sdk/actor/config"
3233
"github.com/dapr/go-sdk/client/internal"
@@ -288,6 +289,15 @@ func NewClient() (client Client, err error) {
288289
return defaultClient, nil
289290
}
290291

292+
func NewWorkflowClient() (*workflow.Client, error) {
293+
dclient, err := NewClient()
294+
if err != nil {
295+
return nil, err
296+
}
297+
298+
return workflow.NewClient(dclient.GrpcClientConn()), nil
299+
}
300+
291301
// NewClientWithPort instantiates Dapr using specific gRPC port.
292302
func NewClientWithPort(port string) (client Client, err error) {
293303
if port == "" {

examples/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ require (
3737
gopkg.in/yaml.v3 v3.0.1 // indirect
3838
)
3939

40-
replace github.com/dapr/durabletask-go => github.com/joshvanl/durabletask-go v0.0.0-20250910141618-db30df7b52d6
40+
replace github.com/dapr/durabletask-go => github.com/joshvanl/durabletask-go v0.0.0-20250910145333-8c0bbac241c3

examples/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
3434
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
3535
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
3636
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
37-
github.com/joshvanl/durabletask-go v0.0.0-20250910141618-db30df7b52d6 h1:6jQhO49OJkcPrSd6muUU2KV2fsDh4OW3z0qB/TKmqJs=
38-
github.com/joshvanl/durabletask-go v0.0.0-20250910141618-db30df7b52d6/go.mod h1:0Ts4rXp74JyG19gDWPcwNo5V6NBZzhARzHF5XynmA7Q=
37+
github.com/joshvanl/durabletask-go v0.0.0-20250910145333-8c0bbac241c3 h1:pJl5ptC8ovsxT5aMREpoP/CBpPj1KmmLj2+lUSJDBnw=
38+
github.com/joshvanl/durabletask-go v0.0.0-20250910145333-8c0bbac241c3/go.mod h1:0Ts4rXp74JyG19gDWPcwNo5V6NBZzhARzHF5XynmA7Q=
3939
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
4040
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
4141
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=

examples/workflow-parallel/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ func main() {
2727
}
2828
fmt.Println("Workflow(s) and activities registered.")
2929

30-
dclient, err := client.NewClient()
30+
wclient, err := client.NewWorkflowClient()
3131
if err != nil {
3232
log.Fatal(err)
3333
}
34-
35-
wclient := workflow.NewClient(dclient.GrpcClientConn())
3634
fmt.Println("Worker initialized")
3735

3836
ctx, cancel := context.WithCancel(context.Background())

examples/workflow-taskexecutionid/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ func main() {
2323
}
2424
fmt.Println("Workflow(s) and activities registered.")
2525

26-
dclient, err := client.NewClient()
26+
wclient, err := client.NewWorkflowClient()
2727
if err != nil {
2828
log.Fatal(err)
2929
}
30-
31-
wclient := workflow.NewClient(dclient.GrpcClientConn())
3230
fmt.Println("Worker initialized")
3331

3432
ctx, cancel := context.WithCancel(context.Background())

examples/workflow/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ func main() {
4646
}
4747
fmt.Println("FailActivity registered")
4848

49-
dclient, err := client.NewClient()
49+
wclient, err := client.NewWorkflowClient()
5050
if err != nil {
5151
log.Fatal(err)
5252
}
53-
54-
wclient := workflow.NewClient(dclient.GrpcClientConn())
5553
fmt.Println("Worker initialized")
5654

5755
ctx, cancel := context.WithCancel(context.Background())

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ require (
3131
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
3232
)
3333

34-
replace github.com/dapr/durabletask-go => github.com/joshvanl/durabletask-go v0.0.0-20250910141618-db30df7b52d6
34+
replace github.com/dapr/durabletask-go => github.com/joshvanl/durabletask-go v0.0.0-20250910145333-8c0bbac241c3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2121
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
2222
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
2323
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
24-
github.com/joshvanl/durabletask-go v0.0.0-20250910141618-db30df7b52d6 h1:6jQhO49OJkcPrSd6muUU2KV2fsDh4OW3z0qB/TKmqJs=
25-
github.com/joshvanl/durabletask-go v0.0.0-20250910141618-db30df7b52d6/go.mod h1:0Ts4rXp74JyG19gDWPcwNo5V6NBZzhARzHF5XynmA7Q=
24+
github.com/joshvanl/durabletask-go v0.0.0-20250910145333-8c0bbac241c3 h1:pJl5ptC8ovsxT5aMREpoP/CBpPj1KmmLj2+lUSJDBnw=
25+
github.com/joshvanl/durabletask-go v0.0.0-20250910145333-8c0bbac241c3/go.mod h1:0Ts4rXp74JyG19gDWPcwNo5V6NBZzhARzHF5XynmA7Q=
2626
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
2727
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
2828
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=

0 commit comments

Comments
 (0)