diff --git a/go.mod b/go.mod index c339b6e9..62afc63b 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.3 require ( github.com/dapr/dapr v1.15.0-rc.1 - github.com/dapr/durabletask-go v0.5.1-0.20241127212625-4232880fd198 + github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530 github.com/go-chi/chi/v5 v5.1.0 github.com/golang/mock v1.6.0 github.com/google/uuid v1.6.0 @@ -19,7 +19,6 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/kr/text v0.2.0 // indirect github.com/marusama/semaphore/v2 v2.5.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect diff --git a/go.sum b/go.sum index 598ec4b8..1d3f8899 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dapr/dapr v1.15.0-rc.1 h1:7JP3zSannxQwV27A9pPR2b/DSNmgcSjJOhRDwM4eFpQ= github.com/dapr/dapr v1.15.0-rc.1/go.mod h1:SycZrBWgfmog+C5T4p0X6VIpnREQ3xajrYxdih+gn9w= -github.com/dapr/durabletask-go v0.5.1-0.20241127212625-4232880fd198 h1:vTq9HmTXow4iVb/1dO4qVZhK7XC5KlwbLl2iNIE23Qc= -github.com/dapr/durabletask-go v0.5.1-0.20241127212625-4232880fd198/go.mod h1:C4ykYCSNv1k2C4wvZv11h2ClkE/qsXw0tv6idOWVmDc= +github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530 h1:bfTcj9ewG6vYqV2Xm9fSGzXlLN5IzpeeBUUgoNiqcOg= +github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530/go.mod h1:C4ykYCSNv1k2C4wvZv11h2ClkE/qsXw0tv6idOWVmDc= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= diff --git a/workflow/client.go b/workflow/client.go index aace75a0..092dd6dc 100644 --- a/workflow/client.go +++ b/workflow/client.go @@ -21,6 +21,7 @@ import ( "time" "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/wrapperspb" "github.com/dapr/durabletask-go/api" "github.com/dapr/durabletask-go/backend" @@ -61,7 +62,7 @@ func WithInput(input any) api.NewOrchestrationOptions { // WithRawInput is an option to pass a byte slice as an input when scheduling a new workflow. func WithRawInput(input string) api.NewOrchestrationOptions { - return api.WithRawInput(input) + return api.WithRawInput(wrapperspb.String(input)) } // WithStartTime is an option to set the start time when scheduling a new workflow. @@ -88,7 +89,7 @@ func WithEventPayload(data any) api.RaiseEventOptions { // WithRawEventData is an option to send a byte slice with an event to a workflow. func WithRawEventData(data string) api.RaiseEventOptions { - return api.WithRawEventData(data) + return api.WithRawEventData(wrapperspb.String(data)) } // WithOutput is an option to define an output when terminating a workflow. @@ -98,7 +99,7 @@ func WithOutput(data any) api.TerminateOptions { // WithRawOutput is an option to define a byte slice to output when terminating a workflow. func WithRawOutput(data string) api.TerminateOptions { - return api.WithRawOutput(data) + return api.WithRawOutput(wrapperspb.String(data)) } // WithRecursiveTerminate configures whether to terminate all sub-workflows created by the target workflow. diff --git a/workflow/context.go b/workflow/context.go index ea9dca02..7c293514 100644 --- a/workflow/context.go +++ b/workflow/context.go @@ -68,7 +68,7 @@ func (wfc *WorkflowContext) CallActivity(activity interface{}, opts ...callActiv } } - return wfc.orchestrationContext.CallActivity(activity, task.WithRawActivityInput(options.rawInput.GetValue()), task.WithActivityRetryPolicy(options.getRetryPolicy())) + return wfc.orchestrationContext.CallActivity(activity, task.WithRawActivityInput(options.rawInput), task.WithActivityRetryPolicy(options.getRetryPolicy())) } // CallChildWorkflow returns a completable task for a given workflow. @@ -84,9 +84,9 @@ func (wfc *WorkflowContext) CallChildWorkflow(workflow interface{}, opts ...call } } if options.instanceID != "" { - return wfc.orchestrationContext.CallSubOrchestrator(workflow, task.WithRawSubOrchestratorInput(options.rawInput.GetValue()), task.WithSubOrchestrationInstanceID(options.instanceID), task.WithSubOrchestrationRetryPolicy(options.getRetryPolicy())) + return wfc.orchestrationContext.CallSubOrchestrator(workflow, task.WithRawSubOrchestratorInput(options.rawInput), task.WithSubOrchestrationInstanceID(options.instanceID), task.WithSubOrchestrationRetryPolicy(options.getRetryPolicy())) } - return wfc.orchestrationContext.CallSubOrchestrator(workflow, task.WithRawSubOrchestratorInput(options.rawInput.GetValue()), task.WithSubOrchestrationRetryPolicy(options.getRetryPolicy())) + return wfc.orchestrationContext.CallSubOrchestrator(workflow, task.WithRawSubOrchestratorInput(options.rawInput), task.WithSubOrchestrationRetryPolicy(options.getRetryPolicy())) } // CreateTimer returns a completable task that blocks for a given duration. diff --git a/workflow/state.go b/workflow/state.go index ab87cc5e..89387df7 100644 --- a/workflow/state.go +++ b/workflow/state.go @@ -14,7 +14,10 @@ limitations under the License. */ package workflow -import "github.com/dapr/durabletask-go/api" +import ( + "github.com/dapr/durabletask-go/api" + "github.com/dapr/durabletask-go/api/protos" +) type Status int @@ -71,12 +74,12 @@ func (s Status) RuntimeStatus() api.OrchestrationStatus { } type WorkflowState struct { - Metadata api.OrchestrationMetadata + Metadata protos.OrchestrationMetadata } // RuntimeStatus returns the status from a workflow state. func (wfs *WorkflowState) RuntimeStatus() Status { - s := Status(wfs.Metadata.RuntimeStatus.Number()) + s := Status(wfs.Metadata.GetRuntimeStatus().Number()) return s } diff --git a/workflow/state_test.go b/workflow/state_test.go index 7521bf55..ecbd868b 100644 --- a/workflow/state_test.go +++ b/workflow/state_test.go @@ -19,11 +19,11 @@ import ( "github.com/stretchr/testify/assert" - "github.com/dapr/durabletask-go/api" + "github.com/dapr/durabletask-go/api/protos" ) func TestString(t *testing.T) { - wfState := WorkflowState{Metadata: api.OrchestrationMetadata{RuntimeStatus: 0}} + wfState := WorkflowState{Metadata: protos.OrchestrationMetadata{RuntimeStatus: 0}} t.Run("test running", func(t *testing.T) { s := wfState.RuntimeStatus() diff --git a/workflow/workflow.go b/workflow/workflow.go index f6a1b15f..b40ba4c8 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -20,7 +20,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" - "github.com/dapr/durabletask-go/api" + "github.com/dapr/durabletask-go/api/protos" "github.com/dapr/durabletask-go/task" ) @@ -44,29 +44,29 @@ type FailureDetails struct { IsNonRetriable bool `json:"IsNonRetriable"` } -func convertMetadata(orchestrationMetadata *api.OrchestrationMetadata) *Metadata { +func convertMetadata(orchestrationMetadata *protos.OrchestrationMetadata) *Metadata { metadata := Metadata{ - InstanceID: string(orchestrationMetadata.InstanceID), - Name: orchestrationMetadata.Name, - RuntimeStatus: Status(orchestrationMetadata.RuntimeStatus.Number()), - CreatedAt: orchestrationMetadata.CreatedAt, - LastUpdatedAt: orchestrationMetadata.LastUpdatedAt, - SerializedInput: orchestrationMetadata.SerializedInput, - SerializedOutput: orchestrationMetadata.SerializedOutput, - SerializedCustomStatus: orchestrationMetadata.SerializedCustomStatus, + InstanceID: orchestrationMetadata.GetInstanceId(), + Name: orchestrationMetadata.GetName(), + RuntimeStatus: Status(orchestrationMetadata.GetRuntimeStatus().Number()), + CreatedAt: orchestrationMetadata.GetCreatedAt().AsTime(), + LastUpdatedAt: orchestrationMetadata.GetLastUpdatedAt().AsTime(), + SerializedInput: orchestrationMetadata.GetInput().GetValue(), + SerializedOutput: orchestrationMetadata.GetOutput().GetValue(), + SerializedCustomStatus: orchestrationMetadata.GetCustomStatus().GetValue(), } - if orchestrationMetadata.FailureDetails != nil { + if orchestrationMetadata.GetFailureDetails() != nil { metadata.FailureDetails = &FailureDetails{ - Type: orchestrationMetadata.FailureDetails.GetErrorType(), - Message: orchestrationMetadata.FailureDetails.GetErrorMessage(), - StackTrace: orchestrationMetadata.FailureDetails.GetStackTrace().GetValue(), - IsNonRetriable: orchestrationMetadata.FailureDetails.GetIsNonRetriable(), + Type: orchestrationMetadata.GetFailureDetails().GetErrorType(), + Message: orchestrationMetadata.GetFailureDetails().GetErrorMessage(), + StackTrace: orchestrationMetadata.GetFailureDetails().GetStackTrace().GetValue(), + IsNonRetriable: orchestrationMetadata.GetFailureDetails().GetIsNonRetriable(), } - if orchestrationMetadata.FailureDetails.GetInnerFailure() != nil { + if orchestrationMetadata.GetFailureDetails().GetInnerFailure() != nil { var root *FailureDetails current := root - failure := orchestrationMetadata.FailureDetails.GetInnerFailure() + failure := orchestrationMetadata.GetFailureDetails().GetInnerFailure() for { current.Type = failure.GetErrorType() current.Message = failure.GetErrorMessage() diff --git a/workflow/workflow_test.go b/workflow/workflow_test.go index d4b1bacb..3def77cb 100644 --- a/workflow/workflow_test.go +++ b/workflow/workflow_test.go @@ -6,14 +6,14 @@ import ( "github.com/stretchr/testify/assert" - "github.com/dapr/durabletask-go/api" + "github.com/dapr/durabletask-go/api/protos" "github.com/dapr/durabletask-go/task" ) func TestConvertMetadata(t *testing.T) { t.Run("convert metadata", func(t *testing.T) { - rawMetadata := &api.OrchestrationMetadata{ - InstanceID: api.InstanceID("test"), + rawMetadata := &protos.OrchestrationMetadata{ + InstanceId: "test", } metadata := convertMetadata(rawMetadata) assert.NotEmpty(t, metadata)