@@ -27,7 +27,7 @@ import (
27
27
dapr "github.com/dapr/go-sdk/client"
28
28
)
29
29
30
- type client struct {
30
+ type Client struct {
31
31
taskHubClient * durabletaskclient.TaskHubGrpcClient
32
32
}
33
33
@@ -95,11 +95,11 @@ func WithDaprClient(input dapr.Client) clientOption {
95
95
// TODO: Implement mocks
96
96
97
97
// NewClient returns a workflow client.
98
- func NewClient (opts ... clientOption ) (client , error ) {
98
+ func NewClient (opts ... clientOption ) (* Client , error ) {
99
99
options := new (clientOptions )
100
100
for _ , configure := range opts {
101
101
if err := configure (options ); err != nil {
102
- return client {}, fmt .Errorf ("failed to load options: %v" , err )
102
+ return & Client {}, fmt .Errorf ("failed to load options: %v" , err )
103
103
}
104
104
}
105
105
var daprClient dapr.Client
@@ -110,18 +110,18 @@ func NewClient(opts ...clientOption) (client, error) {
110
110
daprClient = options .daprClient
111
111
}
112
112
if err != nil {
113
- return client {}, fmt .Errorf ("failed to initialise dapr.Client: %v" , err )
113
+ return & Client {}, fmt .Errorf ("failed to initialise dapr.Client: %v" , err )
114
114
}
115
115
116
116
taskHubClient := durabletaskclient .NewTaskHubGrpcClient (daprClient .GrpcClientConn (), backend .DefaultLogger ())
117
117
118
- return client {
118
+ return & Client {
119
119
taskHubClient : taskHubClient ,
120
120
}, nil
121
121
}
122
122
123
123
// ScheduleNewWorkflow will start a workflow and return the ID and/or error.
124
- func (c * client ) ScheduleNewWorkflow (ctx context.Context , workflow string , opts ... api.NewOrchestrationOptions ) (id string , err error ) {
124
+ func (c * Client ) ScheduleNewWorkflow (ctx context.Context , workflow string , opts ... api.NewOrchestrationOptions ) (id string , err error ) {
125
125
if workflow == "" {
126
126
return "" , errors .New ("no workflow specified" )
127
127
}
@@ -130,7 +130,7 @@ func (c *client) ScheduleNewWorkflow(ctx context.Context, workflow string, opts
130
130
}
131
131
132
132
// FetchWorkflowMetadata will return the metadata for a given workflow InstanceID and/or error.
133
- func (c * client ) FetchWorkflowMetadata (ctx context.Context , id string , opts ... api.FetchOrchestrationMetadataOptions ) (* Metadata , error ) {
133
+ func (c * Client ) FetchWorkflowMetadata (ctx context.Context , id string , opts ... api.FetchOrchestrationMetadataOptions ) (* Metadata , error ) {
134
134
if id == "" {
135
135
return nil , errors .New ("no workflow id specified" )
136
136
}
@@ -143,7 +143,7 @@ func (c *client) FetchWorkflowMetadata(ctx context.Context, id string, opts ...a
143
143
}
144
144
145
145
// WaitForWorkflowStart will wait for a given workflow to start and return metadata and/or an error.
146
- func (c * client ) WaitForWorkflowStart (ctx context.Context , id string , opts ... api.FetchOrchestrationMetadataOptions ) (* Metadata , error ) {
146
+ func (c * Client ) WaitForWorkflowStart (ctx context.Context , id string , opts ... api.FetchOrchestrationMetadataOptions ) (* Metadata , error ) {
147
147
if id == "" {
148
148
return nil , errors .New ("no workflow id specified" )
149
149
}
@@ -156,7 +156,7 @@ func (c *client) WaitForWorkflowStart(ctx context.Context, id string, opts ...ap
156
156
}
157
157
158
158
// WaitForWorkflowCompletion will block pending the completion of a specified workflow and return the metadata and/or error.
159
- func (c * client ) WaitForWorkflowCompletion (ctx context.Context , id string , opts ... api.FetchOrchestrationMetadataOptions ) (* Metadata , error ) {
159
+ func (c * Client ) WaitForWorkflowCompletion (ctx context.Context , id string , opts ... api.FetchOrchestrationMetadataOptions ) (* Metadata , error ) {
160
160
if id == "" {
161
161
return nil , errors .New ("no workflow id specified" )
162
162
}
@@ -169,15 +169,15 @@ func (c *client) WaitForWorkflowCompletion(ctx context.Context, id string, opts
169
169
}
170
170
171
171
// TerminateWorkflow will stop a given workflow and return an error output.
172
- func (c * client ) TerminateWorkflow (ctx context.Context , id string , opts ... api.TerminateOptions ) error {
172
+ func (c * Client ) TerminateWorkflow (ctx context.Context , id string , opts ... api.TerminateOptions ) error {
173
173
if id == "" {
174
174
return errors .New ("no workflow id specified" )
175
175
}
176
176
return c .taskHubClient .TerminateOrchestration (ctx , api .InstanceID (id ), opts ... )
177
177
}
178
178
179
179
// RaiseEvent will raise an event on a given workflow and return an error output.
180
- func (c * client ) RaiseEvent (ctx context.Context , id , eventName string , opts ... api.RaiseEventOptions ) error {
180
+ func (c * Client ) RaiseEvent (ctx context.Context , id , eventName string , opts ... api.RaiseEventOptions ) error {
181
181
if id == "" {
182
182
return errors .New ("no workflow id specified" )
183
183
}
@@ -188,15 +188,15 @@ func (c *client) RaiseEvent(ctx context.Context, id, eventName string, opts ...a
188
188
}
189
189
190
190
// SuspendWorkflow will pause a given workflow and return an error output.
191
- func (c * client ) SuspendWorkflow (ctx context.Context , id , reason string ) error {
191
+ func (c * Client ) SuspendWorkflow (ctx context.Context , id , reason string ) error {
192
192
if id == "" {
193
193
return errors .New ("no workflow id specified" )
194
194
}
195
195
return c .taskHubClient .SuspendOrchestration (ctx , api .InstanceID (id ), reason )
196
196
}
197
197
198
198
// ResumeWorkflow will resume a suspended workflow and return an error output.
199
- func (c * client ) ResumeWorkflow (ctx context.Context , id , reason string ) error {
199
+ func (c * Client ) ResumeWorkflow (ctx context.Context , id , reason string ) error {
200
200
if id == "" {
201
201
return errors .New ("no workflow id specified" )
202
202
}
@@ -205,7 +205,7 @@ func (c *client) ResumeWorkflow(ctx context.Context, id, reason string) error {
205
205
206
206
// PurgeWorkflow will purge a given workflow and return an error output.
207
207
// NOTE: The workflow must be in a terminated or completed state.
208
- func (c * client ) PurgeWorkflow (ctx context.Context , id string ) error {
208
+ func (c * Client ) PurgeWorkflow (ctx context.Context , id string ) error {
209
209
if id == "" {
210
210
return errors .New ("no workflow id specified" )
211
211
}
0 commit comments