Workflows: Make request types optional and use proto strings (#3624)

Signed-off-by: joshvanl <me@joshvanl.dev>
This commit is contained in:
Josh van Leeuwen 2024-12-16 17:07:50 +00:00 committed by GitHub
parent fc8636dbba
commit aca5116d95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 14 deletions

View File

@ -15,12 +15,12 @@ package workflows
import (
"context"
"encoding/json"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/wrapperspb"
"github.com/dapr/kit/logger"
@ -61,14 +61,12 @@ func ConformanceTests(t *testing.T, props map[string]string, workflowItem workfl
t.Run("start", func(t *testing.T) {
testLogger.Info("Start test running...")
inputBytes, _ := json.Marshal(10) // Time that the activity within the workflow runs for
testInstanceID := "TestID"
t.Run("start", func(t *testing.T) {
req := &workflows.StartRequest{
InstanceID: testInstanceID,
InstanceID: &testInstanceID,
WorkflowName: "TestWorkflow",
WorkflowInput: inputBytes,
WorkflowInput: wrapperspb.String("10"),
Options: map[string]string{
"task_queue": "TestTaskQueue",
},

View File

@ -1,11 +1,13 @@
package workflows
import "google.golang.org/protobuf/types/known/wrapperspb"
// StartRequest is the struct describing a start workflow request.
type StartRequest struct {
InstanceID string `json:"instanceID"`
Options map[string]string `json:"options"`
WorkflowName string `json:"workflowName"`
WorkflowInput []byte `json:"workflowInput"`
InstanceID *string `json:"instanceID"`
Options map[string]string `json:"options"`
WorkflowName string `json:"workflowName"`
WorkflowInput *wrapperspb.StringValue `json:"workflowInput"`
}
// GetRequest is the struct describing a get workflow state request.
@ -16,14 +18,14 @@ type GetRequest struct {
// TerminateRequest is the struct describing a terminate workflow request.
type TerminateRequest struct {
InstanceID string `json:"instanceID"`
Recursive bool `json:"recursive"`
Recursive *bool `json:"recursive"`
}
// RaiseEventRequest is the struct describing a raise workflow event request.
type RaiseEventRequest struct {
InstanceID string `json:"instanceID"`
EventName string `json:"name"`
EventData []byte `json:"data"`
InstanceID string `json:"instanceID"`
EventName string `json:"name"`
EventData *wrapperspb.StringValue `json:"data"`
}
// PauseRequest is the struct describing a pause workflow request.
@ -39,5 +41,5 @@ type ResumeRequest struct {
// PurgeRequest is the object describing a Purge request.
type PurgeRequest struct {
InstanceID string `json:"instanceID"`
Recursive bool `json:"recursive"`
Recursive *bool `json:"recursive"`
}