Skip to content

Commit

Permalink
update durabletask ref (#666)
Browse files Browse the repository at this point in the history
* update durabletask ref

Signed-off-by: Fabian Martinez <[email protected]>

* lint

Signed-off-by: Fabian Martinez <[email protected]>

---------

Signed-off-by: Fabian Martinez <[email protected]>
  • Loading branch information
famarting authored Jan 3, 2025
1 parent 495a389 commit 2ab3420
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 35 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 4 additions & 3 deletions workflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions workflow/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions workflow/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions workflow/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
34 changes: 17 additions & 17 deletions workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions workflow/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2ab3420

Please sign in to comment.