Skip to content

Commit ac26e62

Browse files
mikeeecgillum
andauthored
feat: workflow authoring and management support (#487)
* feat: initial workflow Signed-off-by: mikeee <[email protected]> * test: add activity context test for input Signed-off-by: mikeee <[email protected]> * test: add context texts Signed-off-by: mikeee <[email protected]> * fix/test: identify anonymous functions and add tests to runtime Signed-off-by: mikeee <[email protected]> * chore: lint and minor fixes Signed-off-by: mikeee <[email protected]> * chore: improve readability+tests and implement context method Signed-off-by: mikeee <[email protected]> * test: add nil coverage Signed-off-by: mikeee <[email protected]> * feat: workflow implementation wip Signed-off-by: mikeee <[email protected]> * chore: add missing actor, configuration and workflow runners for validation Signed-off-by: mikeee <[email protected]> * chore: lint Signed-off-by: mikeee <[email protected]> * fix: missing formatting directives Signed-off-by: mikeee <[email protected]> * feat: implement wf state Signed-off-by: mikeee <[email protected]> * feat: add workflow management Signed-off-by: mikeee <[email protected]> * chore: fix direct proto field references and general lint Signed-off-by: mikeee <[email protected]> * fix: correct states Signed-off-by: mikeee <[email protected]> * fix: refactor workflow contexts Signed-off-by: mikeee <[email protected]> * fix: increase verbosity and move channel Signed-off-by: mikeee <[email protected]> * fix: implement full workflow validation Signed-off-by: mikeee <[email protected]> * fix: add dapr-app-id to example Signed-off-by: mikeee <[email protected]> * fix: set endpoint Signed-off-by: mikeee <[email protected]> * chore: revert actor mod change Signed-off-by: mikeee <[email protected]> * chore: revert sum addition Signed-off-by: mikeee <[email protected]> * fix: wrap wf management set authtoken in context Signed-off-by: mikeee <[email protected]> * fix: migrate to dapr builtin sdk client Signed-off-by: mikeee <[email protected]> * fix: correct runtime testing logic and lint The runtime creation should never be successful in test Signed-off-by: mikeee <[email protected]> * fix: implement delayed cancellation Signed-off-by: mikeee <[email protected]> * fix(minor): rename getDecorator to getFunctionName Signed-off-by: mikeee <[email protected]> * fix: remove alpha workflow Signed-off-by: mikeee <[email protected]> * fix(validation): remove redundant result line Signed-off-by: mikeee <[email protected]> * feat: initial wfclient implementation Signed-off-by: mikeee <[email protected]> * fix: remove redundant closer and fix comparison Signed-off-by: mikeee <[email protected]> * tests: improve unit test coverage Signed-off-by: mikeee <[email protected]> * fix: cleanup Signed-off-by: mikeee <[email protected]> * fix: wording change Co-authored-by: Chris Gillum <[email protected]> Signed-off-by: mikeee <[email protected]> * fix: wording change Co-authored-by: Chris Gillum <[email protected]> Signed-off-by: mikeee <[email protected]> * chore: bump durabletask-go and deps Signed-off-by: mikeee <[email protected]> * chore: add copyright Signed-off-by: mikeee <[email protected]> * fix: refactor from runtime to worker and other minor changes Signed-off-by: mikeee <[email protected]> * fix: update worker tests Signed-off-by: mikeee <[email protected]> * fix: remove workflow component requirement and return worker error Signed-off-by: mikeee <[email protected]> * fix: reason field validation removed Signed-off-by: mikeee <[email protected]> * fix: remove reason tests Signed-off-by: mikeee <[email protected]> * refactoring Signed-off-by: mikeee <[email protected]> * fix: inputs Signed-off-by: mikeee <[email protected]> * tests: add coverage to activity options Signed-off-by: mikeee <[email protected]> * feat: add worker options Signed-off-by: mikeee <[email protected]> * fix: remove unused logger Signed-off-by: mikeee <[email protected]> * feat: add client options and testing Signed-off-by: mikeee <[email protected]> * feat: decouple metadata Signed-off-by: mikeee <[email protected]> * chore: remove unused client interface Signed-off-by: mikeee <[email protected]> * chore: update tests Signed-off-by: mikeee <[email protected]> * chore: lint Signed-off-by: mikeee <[email protected]> * test: improve coverage Signed-off-by: mikeee <[email protected]> * tests: improve unit coverage Signed-off-by: mikeee <[email protected]> * feat: initial workflow Signed-off-by: mikeee <[email protected]> * test: add activity context test for input Signed-off-by: mikeee <[email protected]> * test: add context texts Signed-off-by: mikeee <[email protected]> * fix/test: identify anonymous functions and add tests to runtime Signed-off-by: mikeee <[email protected]> * chore: lint and minor fixes Signed-off-by: mikeee <[email protected]> * chore: improve readability+tests and implement context method Signed-off-by: mikeee <[email protected]> * test: add nil coverage Signed-off-by: mikeee <[email protected]> * feat: workflow implementation wip Signed-off-by: mikeee <[email protected]> * chore: add missing actor, configuration and workflow runners for validation Signed-off-by: mikeee <[email protected]> * chore: lint Signed-off-by: mikeee <[email protected]> * fix: missing formatting directives Signed-off-by: mikeee <[email protected]> * feat: implement wf state Signed-off-by: mikeee <[email protected]> * feat: add workflow management Signed-off-by: mikeee <[email protected]> * chore: fix direct proto field references and general lint Signed-off-by: mikeee <[email protected]> * fix: correct states Signed-off-by: mikeee <[email protected]> * fix: refactor workflow contexts Signed-off-by: mikeee <[email protected]> * fix: increase verbosity and move channel Signed-off-by: mikeee <[email protected]> * fix: implement full workflow validation Signed-off-by: mikeee <[email protected]> * fix: add dapr-app-id to example Signed-off-by: mikeee <[email protected]> * fix: set endpoint Signed-off-by: mikeee <[email protected]> * chore: revert actor mod change Signed-off-by: mikeee <[email protected]> * chore: revert sum addition Signed-off-by: mikeee <[email protected]> * fix: wrap wf management set authtoken in context Signed-off-by: mikeee <[email protected]> * fix: migrate to dapr builtin sdk client Signed-off-by: mikeee <[email protected]> * fix: correct runtime testing logic and lint The runtime creation should never be successful in test Signed-off-by: mikeee <[email protected]> * fix: implement delayed cancellation Signed-off-by: mikeee <[email protected]> * fix(minor): rename getDecorator to getFunctionName Signed-off-by: mikeee <[email protected]> * fix: remove alpha workflow Signed-off-by: mikeee <[email protected]> * fix(validation): remove redundant result line Signed-off-by: mikeee <[email protected]> * feat: initial wfclient implementation Signed-off-by: mikeee <[email protected]> * fix: remove redundant closer and fix comparison Signed-off-by: mikeee <[email protected]> * tests: improve unit test coverage Signed-off-by: mikeee <[email protected]> * fix: cleanup Signed-off-by: mikeee <[email protected]> * fix: wording change Co-authored-by: Chris Gillum <[email protected]> Signed-off-by: mikeee <[email protected]> * fix: wording change Co-authored-by: Chris Gillum <[email protected]> Signed-off-by: mikeee <[email protected]> * chore: bump durabletask-go and deps Signed-off-by: mikeee <[email protected]> * chore: add copyright Signed-off-by: mikeee <[email protected]> * fix: refactor from runtime to worker and other minor changes Signed-off-by: mikeee <[email protected]> * fix: update worker tests Signed-off-by: mikeee <[email protected]> * fix: remove workflow component requirement and return worker error Signed-off-by: mikeee <[email protected]> * fix: reason field validation removed Signed-off-by: mikeee <[email protected]> * fix: remove reason tests Signed-off-by: mikeee <[email protected]> * refactoring Signed-off-by: mikeee <[email protected]> * fix: inputs Signed-off-by: mikeee <[email protected]> * tests: add coverage to activity options Signed-off-by: mikeee <[email protected]> * feat: add worker options Signed-off-by: mikeee <[email protected]> * fix: remove unused logger Signed-off-by: mikeee <[email protected]> * feat: add client options and testing Signed-off-by: mikeee <[email protected]> * feat: decouple metadata Signed-off-by: mikeee <[email protected]> * chore: remove unused client interface Signed-off-by: mikeee <[email protected]> * chore: update tests Signed-off-by: mikeee <[email protected]> * chore: lint Signed-off-by: mikeee <[email protected]> * test: improve coverage Signed-off-by: mikeee <[email protected]> * tests: improve unit coverage Signed-off-by: mikeee <[email protected]> * fix: implement code review suggestions/refactor and gracefully handle errors Signed-off-by: mikeee <[email protected]> * fix: innerfailure handling Signed-off-by: mikeee <[email protected]> * docs: add docs to public methods and functions Signed-off-by: mikeee <[email protected]> * implements correction Co-authored-by: Chris Gillum <[email protected]> Signed-off-by: mikeee <[email protected]> * change typecast assertion Signed-off-by: mikeee <[email protected]> * improve clarity of notes Signed-off-by: mikeee <[email protected]> * fix mod issues from rebasing interactively on github Signed-off-by: mikeee <[email protected]> * implement suggestions from review - task invoke documentation - refactor type assertion for startworkflowbeta1 Signed-off-by: mikeee <[email protected]> * remoove unused definition Signed-off-by: mikeee <[email protected]> * fix mod Signed-off-by: mikeee <[email protected]> --------- Signed-off-by: mikeee <[email protected]> Co-authored-by: Chris Gillum <[email protected]>
1 parent e45054d commit ac26e62

23 files changed

+2449
-8
lines changed

.github/workflows/validate_examples.yaml

+16-6
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ on:
1414
workflow_dispatch:
1515
inputs:
1616
daprdapr_commit:
17-
description: 'Dapr/Dapr commit to build custom daprd from'
17+
description: "Dapr/Dapr commit to build custom daprd from"
1818
required: false
19-
default: ''
19+
default: ""
2020
daprcli_commit:
21-
description: 'Dapr/CLI commit to build custom dapr CLI from'
21+
description: "Dapr/CLI commit to build custom dapr CLI from"
2222
required: false
23-
default: ''
23+
default: ""
2424
repository_dispatch:
25-
types: [ validate-examples ]
25+
types: [validate-examples]
2626
merge_group:
2727
jobs:
2828
setup:
@@ -154,7 +154,17 @@ jobs:
154154
strategy:
155155
fail-fast: false
156156
matrix:
157-
examples: [ "actor", "configuration", "grpc-service", "hello-world", "pubsub", "service", "socket" ]
157+
examples:
158+
[
159+
"actor",
160+
"configuration",
161+
"grpc-service",
162+
"hello-world",
163+
"pubsub",
164+
"service",
165+
"socket",
166+
"workflow",
167+
]
158168
steps:
159169
- name: Check out code onto GOPATH
160170
uses: actions/checkout@v4

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cover: ## Displays test coverage in the client and service packages
2727
go test -coverprofile=cover-client.out ./client && go tool cover -html=cover-client.out
2828
go test -coverprofile=cover-grpc.out ./service/grpc && go tool cover -html=cover-grpc.out
2929
go test -coverprofile=cover-http.out ./service/http && go tool cover -html=cover-http.out
30+
go test -coverprofile=cover-workflow.out ./workflow && go tool cover -html=cover-workflow.out
3031

3132
.PHONY: lint
3233
lint: check-lint ## Lints the entire project

client/client.go

+23
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,31 @@ type Client interface {
209209
// ImplActorClientStub is to impl user defined actor client stub
210210
ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option)
211211

212+
// StartWorkflowBeta1 starts a workflow.
213+
StartWorkflowBeta1(ctx context.Context, req *StartWorkflowRequest) (*StartWorkflowResponse, error)
214+
215+
// GetWorkflowBeta1 gets a workflow.
216+
GetWorkflowBeta1(ctx context.Context, req *GetWorkflowRequest) (*GetWorkflowResponse, error)
217+
218+
// PurgeWorkflowBeta1 purges a workflow.
219+
PurgeWorkflowBeta1(ctx context.Context, req *PurgeWorkflowRequest) error
220+
221+
// TerminateWorkflowBeta1 terminates a workflow.
222+
TerminateWorkflowBeta1(ctx context.Context, req *TerminateWorkflowRequest) error
223+
224+
// PauseWorkflowBeta1 pauses a workflow.
225+
PauseWorkflowBeta1(ctx context.Context, req *PauseWorkflowRequest) error
226+
227+
// ResumeWorkflowBeta1 resumes a workflow.
228+
ResumeWorkflowBeta1(ctx context.Context, req *ResumeWorkflowRequest) error
229+
230+
// RaiseEventWorkflowBeta1 raises an event for a workflow.
231+
RaiseEventWorkflowBeta1(ctx context.Context, req *RaiseEventWorkflowRequest) error
232+
212233
// GrpcClient returns the base grpc client if grpc is used and nil otherwise
213234
GrpcClient() pb.DaprClient
235+
236+
GrpcClientConn() *grpc.ClientConn
214237
}
215238

216239
// NewClient instantiates Dapr client using DAPR_GRPC_PORT environment variable as port.

client/client_test.go

+59-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ import (
3939
)
4040

4141
const (
42-
testBufSize = 1024 * 1024
43-
testSocket = "/tmp/dapr.socket"
42+
testBufSize = 1024 * 1024
43+
testSocket = "/tmp/dapr.socket"
44+
testWorkflowFailureID = "test_failure_id"
4445
)
4546

4647
var testClient Client
@@ -500,6 +501,62 @@ func (s *testDaprServer) UnsubscribeConfiguration(ctx context.Context, in *pb.Un
500501
return &pb.UnsubscribeConfigurationResponse{Ok: true}, nil
501502
}
502503

504+
func (s *testDaprServer) StartWorkflowBeta1(ctx context.Context, in *pb.StartWorkflowRequest) (*pb.StartWorkflowResponse, error) {
505+
if in.GetInstanceId() == testWorkflowFailureID {
506+
return nil, errors.New("test failure")
507+
}
508+
return &pb.StartWorkflowResponse{
509+
InstanceId: in.GetInstanceId(),
510+
}, nil
511+
}
512+
513+
func (s *testDaprServer) GetWorkflowBeta1(ctx context.Context, in *pb.GetWorkflowRequest) (*pb.GetWorkflowResponse, error) {
514+
if in.GetInstanceId() == testWorkflowFailureID {
515+
return nil, errors.New("test failure")
516+
}
517+
return &pb.GetWorkflowResponse{
518+
InstanceId: in.GetInstanceId(),
519+
WorkflowName: "TestWorkflowName",
520+
RuntimeStatus: "Running",
521+
Properties: make(map[string]string),
522+
}, nil
523+
}
524+
525+
func (s *testDaprServer) PurgeWorkflowBeta1(ctx context.Context, in *pb.PurgeWorkflowRequest) (*emptypb.Empty, error) {
526+
if in.GetInstanceId() == testWorkflowFailureID {
527+
return nil, errors.New("test failure")
528+
}
529+
return &emptypb.Empty{}, nil
530+
}
531+
532+
func (s *testDaprServer) TerminateWorkflowBeta1(ctx context.Context, in *pb.TerminateWorkflowRequest) (*emptypb.Empty, error) {
533+
if in.GetInstanceId() == testWorkflowFailureID {
534+
return nil, errors.New("test failure")
535+
}
536+
return &emptypb.Empty{}, nil
537+
}
538+
539+
func (s *testDaprServer) PauseWorkflowBeta1(ctx context.Context, in *pb.PauseWorkflowRequest) (*emptypb.Empty, error) {
540+
if in.GetInstanceId() == testWorkflowFailureID {
541+
return nil, errors.New("test failure")
542+
}
543+
return &emptypb.Empty{}, nil
544+
}
545+
546+
func (s *testDaprServer) ResumeWorkflowBeta1(ctx context.Context, in *pb.ResumeWorkflowRequest) (*emptypb.Empty, error) {
547+
if in.GetInstanceId() == testWorkflowFailureID {
548+
return nil, errors.New("test failure")
549+
}
550+
return &emptypb.Empty{}, nil
551+
}
552+
553+
func (s *testDaprServer) RaiseEventWorkflowBeta1(ctx context.Context, in *pb.RaiseEventWorkflowRequest) (*emptypb.Empty, error) {
554+
if in.GetInstanceId() == testWorkflowFailureID {
555+
return nil, errors.New("test failure")
556+
}
557+
return &emptypb.Empty{}, nil
558+
}
559+
503560
func TestGrpcClient(t *testing.T) {
504561
protoClient := pb.NewDaprClient(nil)
505562
client := &GRPCClient{protoClient: protoClient}

0 commit comments

Comments
 (0)