Skip to content

Commit eb2ab79

Browse files
authored
Not found failure (#18)
1 parent eeb1e66 commit eb2ab79

13 files changed

+588
-308
lines changed

failure/message.pb.go

Lines changed: 274 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

serviceerror/clientVersionNotSupported.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func (e *ClientVersionNotSupported) status() *status.Status {
7676
func newClientVersionNotSupported(st *status.Status, failure *failure.ClientVersionNotSupported) *ClientVersionNotSupported {
7777
return &ClientVersionNotSupported{
7878
Message: st.Message(),
79-
ClientVersion: failure.ClientVersion,
80-
ClientImpl: failure.ClientImpl,
81-
SupportedVersions: failure.SupportedVersions,
79+
ClientVersion: failure.GetClientVersion(),
80+
ClientImpl: failure.GetClientImpl(),
81+
SupportedVersions: failure.GetSupportedVersions(),
8282
st: st,
8383
}
8484
}

serviceerror/convert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ func FromStatus(st *status.Status) error {
6565
return newInternal(st)
6666
case codes.DataLoss:
6767
return newDataLoss(st)
68-
case codes.NotFound:
69-
return newNotFound(st)
7068
case codes.ResourceExhausted:
7169
return newResourceExhausted(st)
7270
case codes.PermissionDenied:
@@ -92,6 +90,8 @@ func FromStatus(st *status.Status) error {
9290
// Extract failure once to optimize performance.
9391
f := extractFailure(st)
9492
switch st.Code() {
93+
case codes.NotFound:
94+
return newNotFound(st, f.(*failure.NotFound))
9595
case codes.InvalidArgument:
9696
if f == nil {
9797
return newInvalidArgument(st)

serviceerror/currentBranchChanged.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (e *CurrentBranchChanged) status() *status.Status {
6868
func newCurrentBranchChanged(st *status.Status, failure *failure.CurrentBranchChanged) *CurrentBranchChanged {
6969
return &CurrentBranchChanged{
7070
Message: st.Message(),
71-
CurrentBranchToken: failure.CurrentBranchToken,
71+
CurrentBranchToken: failure.GetCurrentBranchToken(),
7272
st: st,
7373
}
7474
}

serviceerror/featureVersionNotSupported.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func (e *FeatureVersionNotSupported) status() *status.Status {
7676
func newFeatureVersionNotSupported(st *status.Status, failure *failure.FeatureVersionNotSupported) *FeatureVersionNotSupported {
7777
return &FeatureVersionNotSupported{
7878
Message: st.Message(),
79-
FeatureVersion: failure.FeatureVersion,
80-
Feature: failure.Feature,
81-
SupportedVersions: failure.SupportedVersions,
79+
FeatureVersion: failure.GetFeatureVersion(),
80+
Feature: failure.GetFeature(),
81+
SupportedVersions: failure.GetSupportedVersions(),
8282
st: st,
8383
}
8484
}

serviceerror/namespaceNotActive.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type (
3535
// NamespaceNotActive represents namespace not active error.
3636
NamespaceNotActive struct {
3737
Message string
38-
Namespace string
38+
Namespace string
3939
CurrentCluster string
4040
ActiveCluster string
4141
st *status.Status
@@ -45,13 +45,13 @@ type (
4545
// NewNamespaceNotActive returns new NamespaceNotActive error.
4646
func NewNamespaceNotActive(namespace, currentCluster, activeCluster string) *NamespaceNotActive {
4747
return &NamespaceNotActive{
48-
Message: fmt.Sprintf(
48+
Message: fmt.Sprintf(
4949
"Namespace: %s is active in cluster: %s, while current cluster %s is a standby cluster.",
5050
namespace,
5151
activeCluster,
5252
currentCluster,
5353
),
54-
Namespace: namespace,
54+
Namespace: namespace,
5555
CurrentCluster: currentCluster,
5656
ActiveCluster: activeCluster,
5757
}
@@ -70,7 +70,7 @@ func (e *NamespaceNotActive) status() *status.Status {
7070
st := status.New(codes.FailedPrecondition, e.Message)
7171
st, _ = st.WithDetails(
7272
&failure.NamespaceNotActive{
73-
Namespace: e.Namespace,
73+
Namespace: e.Namespace,
7474
CurrentCluster: e.CurrentCluster,
7575
ActiveCluster: e.ActiveCluster,
7676
},
@@ -81,9 +81,9 @@ func (e *NamespaceNotActive) status() *status.Status {
8181
func newNamespaceNotActive(st *status.Status, failure *failure.NamespaceNotActive) *NamespaceNotActive {
8282
return &NamespaceNotActive{
8383
Message: st.Message(),
84-
Namespace: failure.Namespace,
85-
CurrentCluster: failure.CurrentCluster,
86-
ActiveCluster: failure.ActiveCluster,
84+
Namespace: failure.GetNamespace(),
85+
CurrentCluster: failure.GetCurrentCluster(),
86+
ActiveCluster: failure.GetActiveCluster(),
8787
st: st,
8888
}
8989
}

serviceerror/notFound.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ package serviceerror
2525
import (
2626
"github.com/gogo/status"
2727
"google.golang.org/grpc/codes"
28+
29+
"go.temporal.io/temporal-proto/failure"
2830
)
2931

3032
type (
3133
// NotFound represents not found error.
3234
NotFound struct {
33-
Message string
34-
st *status.Status
35+
Message string
36+
CurrentCluster string
37+
ActiveCluster string
38+
st *status.Status
3539
}
3640
)
3741

@@ -48,16 +52,25 @@ func (e *NotFound) Error() string {
4852
}
4953

5054
func (e *NotFound) status() *status.Status {
51-
if e.st != nil{
55+
if e.st != nil {
5256
return e.st
5357
}
5458

55-
return status.New(codes.NotFound, e.Message)
59+
st := status.New(codes.NotFound, e.Message)
60+
st, _ = st.WithDetails(
61+
&failure.NotFound{
62+
CurrentCluster: e.CurrentCluster,
63+
ActiveCluster: e.ActiveCluster,
64+
},
65+
)
66+
return st
5667
}
5768

58-
func newNotFound(st *status.Status) *NotFound {
69+
func newNotFound(st *status.Status, failure *failure.NotFound) *NotFound {
5970
return &NotFound{
60-
Message: st.Message(),
61-
st: st,
71+
Message: st.Message(),
72+
CurrentCluster: failure.GetCurrentCluster(),
73+
ActiveCluster: failure.GetActiveCluster(),
74+
st: st,
6275
}
6376
}

serviceerror/retryTask.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type (
3333
// RetryTask represents retry task error.
3434
RetryTask struct {
3535
Message string
36-
NamespaceId string
36+
NamespaceId string
3737
WorkflowId string
3838
RunId string
3939
NextEventId int64
@@ -45,7 +45,7 @@ type (
4545
func NewRetryTask(message, namespaceId, workflowId, runId string, nextEventId int64) *RetryTask {
4646
return &RetryTask{
4747
Message: message,
48-
NamespaceId: namespaceId,
48+
NamespaceId: namespaceId,
4949
WorkflowId: workflowId,
5050
RunId: runId,
5151
NextEventId: nextEventId,
@@ -65,7 +65,7 @@ func (e *RetryTask) status() *status.Status {
6565
st := status.New(codes.Aborted, e.Message)
6666
st, _ = st.WithDetails(
6767
&failure.RetryTask{
68-
NamespaceId: e.NamespaceId,
68+
NamespaceId: e.NamespaceId,
6969
WorkflowId: e.WorkflowId,
7070
RunId: e.RunId,
7171
NextEventId: e.NextEventId,
@@ -77,10 +77,10 @@ func (e *RetryTask) status() *status.Status {
7777
func newRetryTask(st *status.Status, failure *failure.RetryTask) *RetryTask {
7878
return &RetryTask{
7979
Message: st.Message(),
80-
NamespaceId: failure.NamespaceId,
81-
WorkflowId: failure.WorkflowId,
82-
RunId: failure.RunId,
83-
NextEventId: failure.NextEventId,
80+
NamespaceId: failure.GetNamespaceId(),
81+
WorkflowId: failure.GetWorkflowId(),
82+
RunId: failure.GetRunId(),
83+
NextEventId: failure.GetNextEventId(),
8484
st: st,
8585
}
8686
}

serviceerror/retryTaskV2.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type (
3333
// RetryTaskV2 represents retry task v2 error.
3434
RetryTaskV2 struct {
3535
Message string
36-
NamespaceId string
36+
NamespaceId string
3737
WorkflowId string
3838
RunId string
3939
StartEventId int64
@@ -48,7 +48,7 @@ type (
4848
func NewRetryTaskV2(message, namespaceId, workflowId, runId string, startEventId, startEventVersion, endEventId, endEventVersion int64) *RetryTaskV2 {
4949
return &RetryTaskV2{
5050
Message: message,
51-
NamespaceId: namespaceId,
51+
NamespaceId: namespaceId,
5252
WorkflowId: workflowId,
5353
RunId: runId,
5454
StartEventId: startEventId,
@@ -71,7 +71,7 @@ func (e *RetryTaskV2) status() *status.Status {
7171
st := status.New(codes.Aborted, e.Message)
7272
st, _ = st.WithDetails(
7373
&failure.RetryTaskV2{
74-
NamespaceId: e.NamespaceId,
74+
NamespaceId: e.NamespaceId,
7575
WorkflowId: e.WorkflowId,
7676
RunId: e.RunId,
7777
StartEventId: e.StartEventId,
@@ -86,13 +86,13 @@ func (e *RetryTaskV2) status() *status.Status {
8686
func newRetryTaskV2(st *status.Status, failure *failure.RetryTaskV2) *RetryTaskV2 {
8787
return &RetryTaskV2{
8888
Message: st.Message(),
89-
NamespaceId: failure.NamespaceId,
90-
WorkflowId: failure.WorkflowId,
91-
RunId: failure.RunId,
92-
StartEventId: failure.StartEventId,
93-
StartEventVersion: failure.StartEventVersion,
94-
EndEventId: failure.EndEventId,
95-
EndEventVersion: failure.EndEventVersion,
89+
NamespaceId: failure.GetNamespaceId(),
90+
WorkflowId: failure.GetWorkflowId(),
91+
RunId: failure.GetRunId(),
92+
StartEventId: failure.GetStartEventId(),
93+
StartEventVersion: failure.GetStartEventVersion(),
94+
EndEventId: failure.GetEndEventId(),
95+
EndEventVersion: failure.GetEndEventVersion(),
9696
st: st,
9797
}
9898
}

serviceerror/shardOwnershipLost.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (e *ShardOwnershipLost) status() *status.Status {
6868
func newShardOwnershipLost(st *status.Status, failure *failure.ShardOwnershipLost) *ShardOwnershipLost {
6969
return &ShardOwnershipLost{
7070
Message: st.Message(),
71-
Owner: failure.Owner,
71+
Owner: failure.GetOwner(),
7272
st: st,
7373
}
7474
}

0 commit comments

Comments
 (0)