From 1f8270130e51f2e43e0942ced5174b204aa9569f Mon Sep 17 00:00:00 2001 From: Alex Shtin Date: Fri, 5 Jun 2020 12:48:58 -0700 Subject: [PATCH] Remove workflow timeout type (#154) --- error.go | 8 ++--- go.mod | 13 ++++---- go.sum | 36 ++++++++++----------- internal/error.go | 32 +++++++++--------- internal/error_test.go | 32 +++++++++--------- internal/internal_event_handlers.go | 10 +++--- internal/internal_workflow_client.go | 3 +- internal/internal_workflow_client_test.go | 5 ++- internal/workflow.go | 8 ++--- internal/workflow_testsuite.go | 2 +- test/fixtures/activity.cancel.sm.repro.json | 1 - workflow/workflow.go | 8 ++--- 12 files changed, 76 insertions(+), 82 deletions(-) diff --git a/error.go b/error.go index a6e35714a..9cb2d2e1b 100644 --- a/error.go +++ b/error.go @@ -34,7 +34,7 @@ import ( ) /* -If activity fails then *ActivityTaskError is returned to the workflow code. The error has important information about activity +If activity fails then *ActivityError is returned to the workflow code. The error has important information about activity and actual error which caused activity failure. This internal error can be unwrapped using errors.Unwrap() or checked using errors.As(). Below are the possible types of internal error: 1) *ApplicationError: (this should be the most common one) @@ -105,7 +105,7 @@ if err != nil { } } Errors from child workflow should be handled in a similar way, except that instance of *ChildWorkflowExecutionError is returned to -workflow code. It might contain *ActivityTaskError in case if error comes from activity (which in turn will contain on of the errors above), +workflow code. It might contain *ActivityError in case if error comes from activity (which in turn will contain on of the errors above), or *ApplicationError in case if error comes from child workflow itslef. When panic happen in workflow implementation code, SDK catches that panic and causing the decision timeout. @@ -120,8 +120,8 @@ type ( // CanceledError returned when operation was canceled. CanceledError = internal.CanceledError - // ActivityTaskError returned from workflow when activity returned an error. - ActivityTaskError = internal.ActivityTaskError + // ActivityError returned from workflow when activity returned an error. + ActivityError = internal.ActivityError // ServerError can be returned from server. ServerError = internal.ServerError diff --git a/go.mod b/go.mod index 051deb85f..71ecb4f04 100644 --- a/go.mod +++ b/go.mod @@ -9,28 +9,27 @@ require ( github.com/gogo/status v1.1.0 github.com/golang/mock v1.4.3 github.com/google/uuid v1.1.1 // indirect - github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/opentracing/opentracing-go v1.1.0 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 // indirect github.com/robfig/cron v1.2.0 - github.com/sirupsen/logrus v1.5.0 + github.com/sirupsen/logrus v1.6.0 github.com/stretchr/objx v0.2.0 // indirect - github.com/stretchr/testify v1.6.0 + github.com/stretchr/testify v1.6.1 github.com/uber-go/tally v3.3.17+incompatible - github.com/uber/jaeger-client-go v2.22.1+incompatible + github.com/uber/jaeger-client-go v2.23.1+incompatible github.com/uber/jaeger-lib v2.2.0+incompatible // indirect - go.temporal.io/temporal-proto v0.23.4 + go.temporal.io/temporal-proto v0.23.5 go.uber.org/atomic v1.6.0 go.uber.org/goleak v1.0.0 go.uber.org/zap v1.15.0 golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 - golang.org/x/tools v0.0.0-20200327195553-82bb89366a1e // indirect + golang.org/x/tools v0.0.0-20200605181038-cef9fc3bc8f0 // indirect google.golang.org/grpc v1.29.1 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect - gopkg.in/yaml.v3 v3.0.0-20200603094226-e3079894b1e8 // indirect + gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect honnef.co/go/tools v0.0.1-2020.1.3 // indirect ) diff --git a/go.sum b/go.sum index 6d78fa9a5..a5d3be341 100644 --- a/go.sum +++ b/go.sum @@ -55,10 +55,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -83,8 +81,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= -github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= +github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -92,17 +90,17 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho= -github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/uber-go/tally v3.3.17+incompatible h1:nFHIuW3VQ22wItiE9kPXic8dEgExWOsVOHwpmoIvsMw= github.com/uber-go/tally v3.3.17+incompatible/go.mod h1:YDTIBxdXyOU/sCWilKB4bgyufu1cEi0jdVnRdxvjnmU= -github.com/uber/jaeger-client-go v2.22.1+incompatible h1:NHcubEkVbahf9t3p75TOCR83gdUHXjRJvjoBh1yACsM= -github.com/uber/jaeger-client-go v2.22.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-client-go v2.23.1+incompatible h1:uArBYHQR0HqLFFAypI7RsWTzPSj/bDpmZZuQjMLSg1A= +github.com/uber/jaeger-client-go v2.23.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw= github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.temporal.io/temporal-proto v0.23.4 h1:PnQmmTWpQJXapzcBKQ8FgVDeK/B7Z3G08YjmomurJDs= -go.temporal.io/temporal-proto v0.23.4/go.mod h1:B5DnsWAGFpqd9M6bg2OUVzC3Y5/7UVDM0wEkZm7rYN0= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.temporal.io/temporal-proto v0.23.5 h1:xJzulgFaaO5UvpkxeKRweZmOunLqqSS5QP103AG6GBQ= +go.temporal.io/temporal-proto v0.23.5/go.mod h1:U85R39c1zPKnKMJ/QXk6KC21Y3R9j7FUIhUwzxxMY+Y= go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/goleak v1.0.0 h1:qsup4IcBdlmsnGfqyLl4Ntn3C2XCCuKAE7DwHpScyUo= @@ -173,8 +171,8 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200327195553-82bb89366a1e h1:qCZ8SbsZMjT0OuDPCEBxgLZic4NMj8Gj4vNXiTVRAaA= -golang.org/x/tools v0.0.0-20200327195553-82bb89366a1e/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200605181038-cef9fc3bc8f0 h1:gxU2P+MOOGAWge5BKP+BzqSeegxvDBRib5rk3yZDDuI= +golang.org/x/tools v0.0.0-20200605181038-cef9fc3bc8f0/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= @@ -186,8 +184,8 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200604104852-0b0486081ffb h1:ek2py5bOqzR7MR/6obzk0rXUgYCLmjyLnaO9ssT+l6w= -google.golang.org/genproto v0.0.0-20200604104852-0b0486081ffb/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200605102947-12044bf5ea91 h1:ES+5k7Xz+sYByd2L7mvcanaIuY0Iz3L3O6OhN+cRdu8= +google.golang.org/genproto v0.0.0-20200605102947-12044bf5ea91/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -216,8 +214,8 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200603094226-e3079894b1e8 h1:jL/vaozO53FMfZLySWM+4nulF3gQEC6q5jH90LPomDo= -gopkg.in/yaml.v3 v3.0.0-20200603094226-e3079894b1e8/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= diff --git a/internal/error.go b/internal/error.go index 7299c35ed..7d1b227d9 100644 --- a/internal/error.go +++ b/internal/error.go @@ -34,7 +34,7 @@ import ( ) /* -If activity fails then *ActivityTaskError is returned to the workflow code. The error has important information about activity +If activity fails then *ActivityError is returned to the workflow code. The error has important information about activity and actual error which caused activity failure. This internal error can be unwrapped using errors.Unwrap() or checked using errors.As(). Below are the possible types of internal error: 1) *ApplicationError: (this should be the most common one) @@ -107,7 +107,7 @@ if err != nil { } Errors from child workflow should be handled in a similar way, except that instance of *ChildWorkflowExecutionError is returned to -workflow code. It will contains *ActivityTaskError, which in turn will contains on of the errors above. +workflow code. It will contains *ActivityError, which in turn will contains on of the errors above. When panic happen in workflow implementation code, SDK catches that panic and causing the decision timeout. That decision task will be retried at a later time (with exponential backoff retry intervals). @@ -176,9 +176,9 @@ type ( cause error } - // ActivityTaskError is returned from workflow when activity returned an error. + // ActivityError is returned from workflow when activity returned an error. // Unwrap this error to get actual cause. - ActivityTaskError struct { + ActivityError struct { temporalError scheduledEventID int64 startedEventID int64 @@ -294,8 +294,8 @@ func NewServerError(message string, nonRetryable bool, cause error) *ServerError return &ServerError{message: message, nonRetryable: nonRetryable, cause: cause} } -// NewActivityTaskError creates ActivityTaskError instance. -func NewActivityTaskError( +// NewActivityError creates ActivityError instance. +func NewActivityError( scheduledEventID int64, startedEventID int64, identity string, @@ -303,8 +303,8 @@ func NewActivityTaskError( activityID string, retryStatus commonpb.RetryStatus, cause error, -) *ActivityTaskError { - return &ActivityTaskError{ +) *ActivityError { + return &ActivityError{ scheduledEventID: scheduledEventID, startedEventID: startedEventID, identity: identity, @@ -549,11 +549,11 @@ func (e *ServerError) Unwrap() error { return e.cause } -func (e *ActivityTaskError) Error() string { +func (e *ActivityError) Error() string { return fmt.Sprintf("activity task error (scheduledEventID: %d, startedEventID: %d, identity: %s): %v", e.scheduledEventID, e.startedEventID, e.identity, e.cause) } -func (e *ActivityTaskError) Unwrap() error { +func (e *ActivityError) Unwrap() error { return e.cause } @@ -711,8 +711,8 @@ func convertErrorToFailure(err error, dc DataConverter) *failurepb.Failure { NonRetryable: err.nonRetryable, } failure.FailureInfo = &failurepb.Failure_ServerFailureInfo{ServerFailureInfo: failureInfo} - case *ActivityTaskError: - failureInfo := &failurepb.ActivityTaskFailureInfo{ + case *ActivityError: + failureInfo := &failurepb.ActivityFailureInfo{ ScheduledEventId: err.scheduledEventID, StartedEventId: err.startedEventID, Identity: err.identity, @@ -720,7 +720,7 @@ func convertErrorToFailure(err error, dc DataConverter) *failurepb.Failure { ActivityId: err.activityID, RetryStatus: err.retryStatus, } - failure.FailureInfo = &failurepb.Failure_ActivityTaskFailureInfo{ActivityTaskFailureInfo: failureInfo} + failure.FailureInfo = &failurepb.Failure_ActivityFailureInfo{ActivityFailureInfo: failureInfo} case *ChildWorkflowExecutionError: failureInfo := &failurepb.ChildWorkflowExecutionFailureInfo{ Namespace: err.namespace, @@ -784,9 +784,9 @@ func convertFailureToError(failure *failurepb.Failure, dc DataConverter) error { err = NewServerError(failure.GetMessage(), failure.GetServerFailureInfo().GetNonRetryable(), convertFailureToError(failure.GetCause(), dc)) } else if failure.GetResetWorkflowFailureInfo() != nil { err = NewApplicationError(failure.GetMessage(), true, convertFailureToError(failure.GetCause(), dc), failure.GetResetWorkflowFailureInfo().GetLastHeartbeatDetails()) - } else if failure.GetActivityTaskFailureInfo() != nil { - activityTaskInfoFailure := failure.GetActivityTaskFailureInfo() - err = NewActivityTaskError( + } else if failure.GetActivityFailureInfo() != nil { + activityTaskInfoFailure := failure.GetActivityFailureInfo() + err = NewActivityError( activityTaskInfoFailure.GetScheduledEventId(), activityTaskInfoFailure.GetStartedEventId(), activityTaskInfoFailure.GetIdentity(), diff --git a/internal/error_test.go b/internal/error_test.go index e48c8027a..7a8e33034 100644 --- a/internal/error_test.go +++ b/internal/error_test.go @@ -431,7 +431,7 @@ func Test_SignalExternalWorkflowExecutionFailedError(t *testing.T) { weh := &workflowExecutionEventHandlerImpl{context, nil} event := createTestEventSignalExternalWorkflowExecutionFailed(1, &eventpb.SignalExternalWorkflowExecutionFailedEventAttributes{ InitiatedEventId: initiatedEventID, - Cause: eventpb.WorkflowExecutionFailedCause_UnknownExternalWorkflowExecution, + Cause: eventpb.SignalExternalWorkflowExecutionFailedCause_ExternalWorkflowExecutionNotFound2, }) require.NoError(t, weh.handleSignalExternalWorkflowExecutionFailed(event)) _, ok := actualErr.(*UnknownExternalWorkflowExecutionError) @@ -533,7 +533,7 @@ func Test_IsRetryable(t *testing.T) { require.True(IsRetryable(coolErr, []string{})) require.False(IsRetryable(coolErr, []string{"coolError"})) - workflowExecutionErr := NewWorkflowExecutionError("", "", "", NewActivityTaskError(0, 0, "", nil, "", commonpb.RetryStatus_NonRetryableFailure, coolErr)) + workflowExecutionErr := NewWorkflowExecutionError("", "", "", NewActivityError(0, 0, "", nil, "", commonpb.RetryStatus_NonRetryableFailure, coolErr)) require.True(IsRetryable(workflowExecutionErr, []string{})) require.False(IsRetryable(workflowExecutionErr, []string{"coolError"})) } @@ -653,23 +653,23 @@ func Test_convertErrorToFailure_ServerError(t *testing.T) { require.Equal(err.nonRetryable, serverErr.nonRetryable) } -func Test_convertErrorToFailure_ActivityTaskError(t *testing.T) { +func Test_convertErrorToFailure_ActivityError(t *testing.T) { require := require.New(t) applicationErr := NewApplicationError("app err", true, nil) - err := NewActivityTaskError(8, 22, "alex", &commonpb.ActivityType{Name: "activityType"}, "32283", commonpb.RetryStatus_NonRetryableFailure, applicationErr) + err := NewActivityError(8, 22, "alex", &commonpb.ActivityType{Name: "activityType"}, "32283", commonpb.RetryStatus_NonRetryableFailure, applicationErr) f := convertErrorToFailure(err, DefaultDataConverter) require.Equal("activity task error (scheduledEventID: 8, startedEventID: 22, identity: alex): app err", f.GetMessage()) - require.Equal(int64(8), f.GetActivityTaskFailureInfo().GetScheduledEventId()) - require.Equal(int64(22), f.GetActivityTaskFailureInfo().GetStartedEventId()) - require.Equal("alex", f.GetActivityTaskFailureInfo().GetIdentity()) - require.Equal("activityType", f.GetActivityTaskFailureInfo().GetActivityType().GetName()) - require.Equal("32283", f.GetActivityTaskFailureInfo().GetActivityId()) - require.Equal(commonpb.RetryStatus_NonRetryableFailure, f.GetActivityTaskFailureInfo().GetRetryStatus()) + require.Equal(int64(8), f.GetActivityFailureInfo().GetScheduledEventId()) + require.Equal(int64(22), f.GetActivityFailureInfo().GetStartedEventId()) + require.Equal("alex", f.GetActivityFailureInfo().GetIdentity()) + require.Equal("activityType", f.GetActivityFailureInfo().GetActivityType().GetName()) + require.Equal("32283", f.GetActivityFailureInfo().GetActivityId()) + require.Equal(commonpb.RetryStatus_NonRetryableFailure, f.GetActivityFailureInfo().GetRetryStatus()) require.Equal(convertErrorToFailure(applicationErr, DefaultDataConverter), f.GetCause()) err2 := convertFailureToError(f, DefaultDataConverter) - var activityTaskErr *ActivityTaskError + var activityTaskErr *ActivityError require.True(errors.As(err2, &activityTaskErr)) require.Equal(err.Error(), activityTaskErr.Error()) require.Equal(err.startedEventID, activityTaskErr.startedEventID) @@ -875,7 +875,7 @@ func Test_convertFailureToError_SaveFailure(t *testing.T) { NonRetryable: true, }}, }, - FailureInfo: &failurepb.Failure_ActivityTaskFailureInfo{ActivityTaskFailureInfo: &failurepb.ActivityTaskFailureInfo{ + FailureInfo: &failurepb.Failure_ActivityFailureInfo{ActivityFailureInfo: &failurepb.ActivityFailureInfo{ StartedEventId: 1, ScheduledEventId: 2, Identity: "alex", @@ -891,7 +891,7 @@ func Test_convertFailureToError_SaveFailure(t *testing.T) { applicationErr.originalType = "ApplicationError (is ignored)" applicationErr.nonRetryable = false - var activityErr *ActivityTaskError + var activityErr *ActivityError require.True(errors.As(err, &activityErr)) require.NotNil(activityErr.originalFailure) activityErr.startedEventID = 11 @@ -902,9 +902,9 @@ func Test_convertFailureToError_SaveFailure(t *testing.T) { require.Equal("message", f2.GetMessage()) require.Equal("long stack trace", f2.GetStackTrace()) require.Equal("JavaSDK", f2.GetSource()) - require.Equal(int64(1), f2.GetActivityTaskFailureInfo().GetStartedEventId()) - require.Equal(int64(2), f2.GetActivityTaskFailureInfo().GetScheduledEventId()) - require.Equal("alex", f2.GetActivityTaskFailureInfo().GetIdentity()) + require.Equal(int64(1), f2.GetActivityFailureInfo().GetStartedEventId()) + require.Equal(int64(2), f2.GetActivityFailureInfo().GetScheduledEventId()) + require.Equal("alex", f2.GetActivityFailureInfo().GetIdentity()) require.Equal("application message", f2.GetCause().GetMessage()) require.Equal("application long stack trace", f2.GetCause().GetStackTrace()) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index 2d11a81b2..5e2abef88 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -986,7 +986,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskFailed(event *ev } attributes := event.GetActivityTaskFailedEventAttributes() - activityTaskErr := NewActivityTaskError( + activityTaskErr := NewActivityError( attributes.GetScheduledEventId(), attributes.GetStartedEventId(), attributes.GetIdentity(), @@ -1011,7 +1011,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskTimedOut(event * attributes := event.GetActivityTaskTimedOutEventAttributes() timeoutError := convertFailureToError(attributes.GetFailure(), weh.GetDataConverter()) - activityTaskErr := NewActivityTaskError( + activityTaskErr := NewActivityError( attributes.GetScheduledEventId(), attributes.GetStartedEventId(), "", @@ -1039,7 +1039,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCanceled(event * attributes := event.GetActivityTaskCanceledEventAttributes() details := newEncodedValues(attributes.GetDetails(), weh.GetDataConverter()) - activityTaskErr := NewActivityTaskError( + activityTaskErr := NewActivityError( attributes.GetScheduledEventId(), attributes.GetStartedEventId(), attributes.GetIdentity(), @@ -1331,7 +1331,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTimedO attributes.GetInitiatedEventId(), attributes.GetStartedEventId(), attributes.GetRetryStatus(), - NewTimeoutError(attributes.GetTimeoutType(), nil), + NewTimeoutError(commonpb.TimeoutType_StartToClose, nil), ) childWorkflow.handle(nil, childWorkflowExecutionError) return nil @@ -1433,7 +1433,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecut var err error switch attributes.GetCause() { - case eventpb.WorkflowExecutionFailedCause_UnknownExternalWorkflowExecution: + case eventpb.SignalExternalWorkflowExecutionFailedCause_ExternalWorkflowExecutionNotFound2: err = newUnknownExternalWorkflowExecutionError() default: err = fmt.Errorf("signal external workflow failed, %v", attributes.GetCause()) diff --git a/internal/internal_workflow_client.go b/internal/internal_workflow_client.go index 5b68d528a..d2e0e0237 100644 --- a/internal/internal_workflow_client.go +++ b/internal/internal_workflow_client.go @@ -1120,8 +1120,7 @@ func (workflowRun *workflowRunImpl) Get(ctx context.Context, valuePtr interface{ case eventpb.EventType_WorkflowExecutionTerminated: err = newTerminatedError() case eventpb.EventType_WorkflowExecutionTimedOut: - attributes := closeEvent.GetWorkflowExecutionTimedOutEventAttributes() - err = NewTimeoutError(attributes.GetTimeoutType(), nil) + err = NewTimeoutError(commonpb.TimeoutType_StartToClose, nil) case eventpb.EventType_WorkflowExecutionContinuedAsNew: attributes := closeEvent.GetWorkflowExecutionContinuedAsNewEventAttributes() workflowRun.currentRunID = attributes.GetNewExecutionRunId() diff --git a/internal/internal_workflow_client_test.go b/internal/internal_workflow_client_test.go index 98a0e341a..66742c32c 100644 --- a/internal/internal_workflow_client_test.go +++ b/internal/internal_workflow_client_test.go @@ -809,7 +809,6 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_TimedOut() { filterType := filterpb.HistoryEventFilterType_CloseEvent eventType := eventpb.EventType_WorkflowExecutionTimedOut - timeType := commonpb.TimeoutType_ScheduleToStart getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ History: &eventpb.History{ @@ -817,7 +816,7 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_TimedOut() { { EventType: eventType, Attributes: &eventpb.HistoryEvent_WorkflowExecutionTimedOutEventAttributes{WorkflowExecutionTimedOutEventAttributes: &eventpb.WorkflowExecutionTimedOutEventAttributes{ - TimeoutType: timeType, + RetryStatus: commonpb.RetryStatus_Timeout, }}, }, }, @@ -847,7 +846,7 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_TimedOut() { s.True(ok) var timeoutErr *TimeoutError s.True(errors.As(err, &timeoutErr)) - s.Equal(timeType, timeoutErr.TimeoutType()) + s.Equal(commonpb.TimeoutType_StartToClose, timeoutErr.TimeoutType()) s.Equal(time.Minute, decodedResult) } diff --git a/internal/workflow.go b/internal/workflow.go index d3e755e76..52ad5f16a 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -391,12 +391,12 @@ func (wc *workflowEnvironmentInterceptor) ExecuteWorkflow(ctx Context, workflowT // Input args are the arguments that need to be passed to the scheduled activity. // // If the activity failed to complete then the future get error would indicate the failure. -// The error will be of type *ActivityTaskError. It will have important activity information and actual error that caused +// The error will be of type *ActivityError. It will have important activity information and actual error that caused // activity failure. Use errors.Unwrap to get this error or errors.As to check it type which can be one of // *ApplicationError, *TimeoutError, *CanceledError, or *PanicError. // // You can cancel the pending activity using context(workflow.WithCancel(ctx)) and that will fail the activity with -// *CanceledError set as cause for *ActivityTaskError. +// *CanceledError set as cause for *ActivityError. // // ExecuteActivity returns Future with activity result or failure. func ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future { @@ -503,12 +503,12 @@ func (wc *workflowEnvironmentInterceptor) ExecuteActivity(ctx Context, typeName // the local activity again. // // If the activity failed to complete then the future get error would indicate the failure. -// The error will be of type *ActivityTaskError. It will have important activity information and actual error that caused +// The error will be of type *ActivityError. It will have important activity information and actual error that caused // activity failure. Use errors.Unwrap to get this error or errors.As to check it type which can be one of // *ApplicationError, *TimeoutError, *CanceledError, or *PanicError. // // You can cancel the pending activity using context(workflow.WithCancel(ctx)) and that will fail the activity with -// *CanceledError set as cause for *ActivityTaskError. +// *CanceledError set as cause for *ActivityError. // // ExecuteLocalActivity returns Future with local activity result or failure. func ExecuteLocalActivity(ctx Context, activity interface{}, args ...interface{}) Future { diff --git a/internal/workflow_testsuite.go b/internal/workflow_testsuite.go index 8433e445c..2c01a490e 100644 --- a/internal/workflow_testsuite.go +++ b/internal/workflow_testsuite.go @@ -310,7 +310,7 @@ func (e *TestWorkflowEnvironment) OnActivity(activity interface{}, args ...inter // ErrMockStartChildWorkflowFailed is special error used to indicate the mocked child workflow should fail to start. // This error is also exposed as public as testsuite.ErrMockStartChildWorkflowFailed -var ErrMockStartChildWorkflowFailed = fmt.Errorf("start child workflow failed: %v", eventpb.WorkflowExecutionFailedCause_WorkflowAlreadyRunning) +var ErrMockStartChildWorkflowFailed = fmt.Errorf("start child workflow failed: %v", eventpb.StartChildWorkflowExecutionFailedCause_WorkflowAlreadyExists) // OnWorkflow setup a mock call for workflow. Parameter workflow must be workflow function (func) or workflow name (string). // You must call Return() with appropriate parameters on the returned *MockCallWrapper instance. The supplied parameters to diff --git a/test/fixtures/activity.cancel.sm.repro.json b/test/fixtures/activity.cancel.sm.repro.json index 0ffbe17d8..7a0a28ab2 100755 --- a/test/fixtures/activity.cancel.sm.repro.json +++ b/test/fixtures/activity.cancel.sm.repro.json @@ -193,7 +193,6 @@ "eventType": "WorkflowExecutionTimedOut", "version": -24, "workflowExecutionTimedOutEventAttributes": { - "timeoutType": "StartToClose" } } ] diff --git a/workflow/workflow.go b/workflow/workflow.go index 0c60cd486..c7a30bfa6 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -79,12 +79,12 @@ type ( // Input args are the arguments that need to be passed to the scheduled activity. // // If the activity failed to complete then the future get error would indicate the failure. -// The error will be of type *ActivityTaskError. It will have important activity information and actual error that caused +// The error will be of type *ActivityError. It will have important activity information and actual error that caused // activity failure. Use errors.Unwrap to get this error or errors.As to check it type which can be one of // *ApplicationError, *TimeoutError, *CanceledError, or *PanicError. // // You can cancel the pending activity using context(workflow.WithCancel(ctx)) and that will fail the activity with -// *CanceledError set as cause for *ActivityTaskError. +// *CanceledError set as cause for *ActivityError. // // ExecuteActivity returns Future with activity result or failure. func ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future { @@ -123,12 +123,12 @@ func ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Fut // the local activity again. // // If the activity failed to complete then the future get error would indicate the failure. -// The error will be of type *ActivityTaskError. It will have important activity information and actual error that caused +// The error will be of type *ActivityError. It will have important activity information and actual error that caused // activity failure. Use errors.Unwrap to get this error or errors.As to check it type which can be one of // *ApplicationError, *TimeoutError, *CanceledError, or *PanicError. // // You can cancel the pending activity using context(workflow.WithCancel(ctx)) and that will fail the activity with -// *CanceledError set as cause for *ActivityTaskError. +// *CanceledError set as cause for *ActivityError. // // ExecuteLocalActivity returns Future with local activity result or failure. func ExecuteLocalActivity(ctx Context, activity interface{}, args ...interface{}) Future {