Skip to content

Commit a1e723b

Browse files
authored
make workflow client struct public (dapr#577)
Signed-off-by: Fabian Martinez <[email protected]>
1 parent d3eef2e commit a1e723b

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

workflow/client.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
dapr "github.com/dapr/go-sdk/client"
2828
)
2929

30-
type client struct {
30+
type Client struct {
3131
taskHubClient *durabletaskclient.TaskHubGrpcClient
3232
}
3333

@@ -95,11 +95,11 @@ func WithDaprClient(input dapr.Client) clientOption {
9595
// TODO: Implement mocks
9696

9797
// NewClient returns a workflow client.
98-
func NewClient(opts ...clientOption) (client, error) {
98+
func NewClient(opts ...clientOption) (*Client, error) {
9999
options := new(clientOptions)
100100
for _, configure := range opts {
101101
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)
103103
}
104104
}
105105
var daprClient dapr.Client
@@ -110,18 +110,18 @@ func NewClient(opts ...clientOption) (client, error) {
110110
daprClient = options.daprClient
111111
}
112112
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)
114114
}
115115

116116
taskHubClient := durabletaskclient.NewTaskHubGrpcClient(daprClient.GrpcClientConn(), backend.DefaultLogger())
117117

118-
return client{
118+
return &Client{
119119
taskHubClient: taskHubClient,
120120
}, nil
121121
}
122122

123123
// 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) {
125125
if workflow == "" {
126126
return "", errors.New("no workflow specified")
127127
}
@@ -130,7 +130,7 @@ func (c *client) ScheduleNewWorkflow(ctx context.Context, workflow string, opts
130130
}
131131

132132
// 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) {
134134
if id == "" {
135135
return nil, errors.New("no workflow id specified")
136136
}
@@ -143,7 +143,7 @@ func (c *client) FetchWorkflowMetadata(ctx context.Context, id string, opts ...a
143143
}
144144

145145
// 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) {
147147
if id == "" {
148148
return nil, errors.New("no workflow id specified")
149149
}
@@ -156,7 +156,7 @@ func (c *client) WaitForWorkflowStart(ctx context.Context, id string, opts ...ap
156156
}
157157

158158
// 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) {
160160
if id == "" {
161161
return nil, errors.New("no workflow id specified")
162162
}
@@ -169,15 +169,15 @@ func (c *client) WaitForWorkflowCompletion(ctx context.Context, id string, opts
169169
}
170170

171171
// 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 {
173173
if id == "" {
174174
return errors.New("no workflow id specified")
175175
}
176176
return c.taskHubClient.TerminateOrchestration(ctx, api.InstanceID(id), opts...)
177177
}
178178

179179
// 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 {
181181
if id == "" {
182182
return errors.New("no workflow id specified")
183183
}
@@ -188,15 +188,15 @@ func (c *client) RaiseEvent(ctx context.Context, id, eventName string, opts ...a
188188
}
189189

190190
// 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 {
192192
if id == "" {
193193
return errors.New("no workflow id specified")
194194
}
195195
return c.taskHubClient.SuspendOrchestration(ctx, api.InstanceID(id), reason)
196196
}
197197

198198
// 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 {
200200
if id == "" {
201201
return errors.New("no workflow id specified")
202202
}
@@ -205,7 +205,7 @@ func (c *client) ResumeWorkflow(ctx context.Context, id, reason string) error {
205205

206206
// PurgeWorkflow will purge a given workflow and return an error output.
207207
// 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 {
209209
if id == "" {
210210
return errors.New("no workflow id specified")
211211
}

workflow/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func returnClientOptions(opts ...clientOption) clientOptions {
4949
}
5050

5151
func TestClientMethods(t *testing.T) {
52-
testClient := client{
52+
testClient := Client{
5353
taskHubClient: nil,
5454
}
5555
ctx := context.Background()

0 commit comments

Comments
 (0)