File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -64,22 +64,29 @@ func NewWorker(opts ...workerOption) (*WorkflowWorker, error) {
64
64
return nil , errors .New ("failed to load options" )
65
65
}
66
66
}
67
- var daprClient dapr.Client
68
- var err error
69
- if options .daprClient == nil {
70
- daprClient , err = dapr .NewClient ()
71
- } else {
67
+
68
+ var (
69
+ daprClient dapr.Client
70
+ err error
71
+ closeFunc = func () {}
72
+ )
73
+
74
+ if options .daprClient != nil {
72
75
daprClient = options .daprClient
76
+ } else {
77
+ if daprClient , err = dapr .NewClient (); err != nil {
78
+ return nil , err
79
+ }
80
+
81
+ closeFunc = daprClient .Close
73
82
}
74
- if err != nil {
75
- return nil , err
76
- }
83
+
77
84
grpcConn := daprClient .GrpcClientConn ()
78
85
79
86
return & WorkflowWorker {
80
87
tasks : task .NewTaskRegistry (),
81
88
client : durabletaskclient .NewTaskHubGrpcClient (grpcConn , backend .DefaultLogger ()),
82
- close : daprClient . Close ,
89
+ close : closeFunc ,
83
90
}, nil
84
91
}
85
92
You can’t perform that action at this time.
0 commit comments