Skip to content

Commit d21ede2

Browse files
authoredDec 10, 2024··
Nexus error rehydration (#1751)
## What was changed Add support for full Temporal error rehydration. Any Temporal errors returned over the Nexus boundary will now automatically be fully rehydrated on the caller side. Some notable points: - The Nexus SDK was upgraded to `v0.1.0`, which is a breaking change. Temporal Nexus users should refer to the [release notes](https://github.com/nexus-rpc/sdk-go/releases/tag/v0.1.0) before upgrading the Temporal SDK. - `nexus.HandlerError` now has a `Failure` representation and is visible to the caller workflow. - Arbitrary errors are translated to `ApplicationError` as they do in the rest of the Temporal SDK. - `WorkflowExecutionError`, `QueryRejectedError`, and non retryable `ApplicationError`s are no longer translated to bad request handler errors, instead they're translated to `OperationError`s. ## Why? Provide a more consistent experience for Temporal users and on par debugging experience with workflows and activities. Note that the functional tests weren't committed since they depend on unmerged server changes. They will be added in a followup PR.
1 parent 41e9b33 commit d21ede2

23 files changed

+232
-221
lines changed
 

‎contrib/datadog/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/google/uuid v1.6.0 // indirect
3131
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
3232
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
33-
github.com/nexus-rpc/sdk-go v0.0.12 // indirect
33+
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
3434
github.com/outcaste-io/ristretto v0.2.3 // indirect
3535
github.com/pborman/uuid v1.2.1 // indirect
3636
github.com/philhofer/fwd v1.1.2 // indirect
@@ -40,7 +40,7 @@ require (
4040
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
4141
github.com/stretchr/objx v0.5.2 // indirect
4242
github.com/tinylib/msgp v1.1.8 // indirect
43-
go.temporal.io/api v1.40.0 // indirect
43+
go.temporal.io/api v1.43.0 // indirect
4444
go.uber.org/atomic v1.11.0 // indirect
4545
go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect
4646
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect

‎contrib/datadog/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
8585
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
8686
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
8787
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
88-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
89-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
88+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
89+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
9090
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
9191
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
9292
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
@@ -137,8 +137,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
137137
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
138138
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
139139
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
140-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
141-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
140+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
141+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
142142
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
143143
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
144144
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=

‎contrib/opentelemetry/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
require (
1414
github.com/go-logr/logr v1.4.1 // indirect
1515
github.com/go-logr/stdr v1.2.2 // indirect
16-
github.com/nexus-rpc/sdk-go v0.0.12 // indirect
16+
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
1717
golang.org/x/sync v0.8.0 // indirect
1818
)
1919

@@ -31,7 +31,7 @@ require (
3131
github.com/stretchr/objx v0.5.2 // indirect
3232
go.opentelemetry.io/otel/metric v1.27.0
3333
go.opentelemetry.io/otel/sdk/metric v1.27.0
34-
go.temporal.io/api v1.40.0 // indirect
34+
go.temporal.io/api v1.43.0 // indirect
3535
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
3636
golang.org/x/net v0.28.0 // indirect
3737
golang.org/x/sys v0.24.0 // indirect

‎contrib/opentelemetry/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
5252
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
5353
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
5454
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
55-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
56-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
55+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
56+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
5757
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
5858
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
5959
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
@@ -89,8 +89,8 @@ go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2N
8989
go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw=
9090
go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw=
9191
go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4=
92-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
93-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
92+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
93+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
9494
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
9595
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
9696
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=

‎contrib/opentracing/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ require (
1818
github.com/google/uuid v1.6.0 // indirect
1919
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
2020
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
21-
github.com/nexus-rpc/sdk-go v0.0.12 // indirect
21+
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
2222
github.com/pborman/uuid v1.2.1 // indirect
2323
github.com/pmezard/go-difflib v1.0.0 // indirect
2424
github.com/robfig/cron v1.2.0 // indirect
2525
github.com/stretchr/objx v0.5.2 // indirect
26-
go.temporal.io/api v1.40.0 // indirect
26+
go.temporal.io/api v1.43.0 // indirect
2727
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
2828
golang.org/x/net v0.28.0 // indirect
2929
golang.org/x/sync v0.8.0 // indirect

‎contrib/opentracing/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
4747
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
4848
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
4949
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
50-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
51-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
50+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
51+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
5252
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
5353
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
5454
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
@@ -76,8 +76,8 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf
7676
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7777
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7878
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
79-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
80-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
79+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
80+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
8181
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
8282
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
8383
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=

‎contrib/resourcetuner/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
2626
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
2727
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
28-
github.com/nexus-rpc/sdk-go v0.0.12 // indirect
28+
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
2929
github.com/opencontainers/runtime-spec v1.0.2 // indirect
3030
github.com/pborman/uuid v1.2.1 // indirect
3131
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -37,7 +37,7 @@ require (
3737
github.com/tklauser/go-sysconf v0.3.12 // indirect
3838
github.com/tklauser/numcpus v0.6.1 // indirect
3939
github.com/yusufpapurcu/wmi v1.2.4 // indirect
40-
go.temporal.io/api v1.40.0 // indirect
40+
go.temporal.io/api v1.43.0 // indirect
4141
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
4242
golang.org/x/net v0.28.0 // indirect
4343
golang.org/x/sync v0.8.0 // indirect

‎contrib/resourcetuner/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6262
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
6363
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
6464
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
65-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
66-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
65+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
66+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
6767
github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0=
6868
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
6969
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
@@ -109,8 +109,8 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo
109109
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
110110
go.einride.tech/pid v0.1.3 h1:yWAKSmD2Z10jxd4gYFhOjbBNqXeIQwAtnCO/XKCT7sQ=
111111
go.einride.tech/pid v0.1.3/go.mod h1:33JSUbKrH/4v8DZf/0K8IC8Enjd92wB2birp+bCYQso=
112-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
113-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
112+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
113+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
114114
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
115115
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
116116
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=

‎contrib/tally/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ require (
1818
github.com/google/uuid v1.6.0 // indirect
1919
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
2020
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
21-
github.com/nexus-rpc/sdk-go v0.0.12 // indirect
21+
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
2222
github.com/pborman/uuid v1.2.1 // indirect
2323
github.com/pmezard/go-difflib v1.0.0 // indirect
2424
github.com/robfig/cron v1.2.0 // indirect
2525
github.com/stretchr/objx v0.5.2 // indirect
2626
github.com/twmb/murmur3 v1.1.5 // indirect
27-
go.temporal.io/api v1.40.0 // indirect
27+
go.temporal.io/api v1.43.0 // indirect
2828
go.uber.org/atomic v1.9.0 // indirect
2929
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
3030
golang.org/x/net v0.28.0 // indirect

‎contrib/tally/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
9292
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
9393
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
9494
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
95-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
96-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
95+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
96+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
9797
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
9898
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
9999
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
@@ -141,8 +141,8 @@ github.com/uber-go/tally/v4 v4.1.1/go.mod h1:aXeSTDMl4tNosyf6rdU8jlgScHyjEGGtfJ/
141141
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
142142
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
143143
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
144-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
145-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
144+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
145+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
146146
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
147147
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
148148
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=

‎go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ require (
99
github.com/gogo/protobuf v1.3.2
1010
github.com/golang/mock v1.6.0
1111
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
12-
github.com/nexus-rpc/sdk-go v0.0.12
12+
github.com/nexus-rpc/sdk-go v0.1.0
1313
github.com/pborman/uuid v1.2.1
1414
github.com/robfig/cron v1.2.0
1515
github.com/stretchr/testify v1.10.0
16-
go.temporal.io/api v1.40.0
16+
go.temporal.io/api v1.43.0
1717
golang.org/x/sync v0.8.0
1818
golang.org/x/sys v0.24.0
1919
golang.org/x/time v0.3.0

‎go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
4747
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
4848
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
4949
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
50-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
51-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
50+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
51+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
5252
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
5353
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
5454
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
@@ -74,8 +74,8 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf
7474
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7575
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7676
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
77-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
78-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
77+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
78+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
7979
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
8080
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
8181
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=

‎internal/cmd/build/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ require (
1717
github.com/google/uuid v1.6.0 // indirect
1818
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
1919
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
20-
github.com/nexus-rpc/sdk-go v0.0.12 // indirect
20+
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
2121
github.com/pborman/uuid v1.2.1 // indirect
2222
github.com/pmezard/go-difflib v1.0.0 // indirect
2323
github.com/robfig/cron v1.2.0 // indirect
2424
github.com/stretchr/objx v0.5.2 // indirect
2525
github.com/stretchr/testify v1.10.0 // indirect
26-
go.temporal.io/api v1.40.0 // indirect
26+
go.temporal.io/api v1.43.0 // indirect
2727
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
2828
golang.org/x/exp/typeparams v0.0.0-20240409090435-93d18d7e34b8 // indirect
2929
golang.org/x/mod v0.17.0 // indirect

‎internal/cmd/build/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
5151
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
5252
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
5353
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
54-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
55-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
54+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
55+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
5656
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
5757
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
5858
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
@@ -78,8 +78,8 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf
7878
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7979
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
8080
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
81-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
82-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
81+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
82+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
8383
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
8484
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
8585
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=

‎internal/failure_converter.go

+11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"errors"
2727
"time"
2828

29+
"github.com/nexus-rpc/sdk-go/nexus"
2930
"google.golang.org/protobuf/proto"
3031
"google.golang.org/protobuf/types/known/durationpb"
3132

@@ -177,6 +178,11 @@ func (dfc *DefaultFailureConverter) ErrorToFailure(err error) *failurepb.Failure
177178
OperationId: err.OperationID,
178179
}
179180
failure.FailureInfo = &failurepb.Failure_NexusOperationExecutionFailureInfo{NexusOperationExecutionFailureInfo: failureInfo}
181+
case *nexus.HandlerError:
182+
failureInfo := &failurepb.NexusHandlerFailureInfo{
183+
Type: string(err.Type),
184+
}
185+
failure.FailureInfo = &failurepb.Failure_NexusHandlerFailureInfo{NexusHandlerFailureInfo: failureInfo}
180186
default: // All unknown errors are considered to be retryable ApplicationFailureInfo.
181187
failureInfo := &failurepb.ApplicationFailureInfo{
182188
Type: getErrType(err),
@@ -282,6 +288,11 @@ func (dfc *DefaultFailureConverter) FailureToError(failure *failurepb.Failure) e
282288
Operation: info.GetOperation(),
283289
OperationID: info.GetOperationId(),
284290
}
291+
} else if info := failure.GetNexusHandlerFailureInfo(); info != nil {
292+
err = &nexus.HandlerError{
293+
Type: nexus.HandlerErrorType(info.Type),
294+
Cause: dfc.FailureToError(failure.GetCause()),
295+
}
285296
}
286297

287298
if err == nil {

‎internal/internal_nexus_task_handler.go

+132-101
Large diffs are not rendered by default.

‎internal/internal_nexus_task_poller.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (ntp *nexusTaskPoller) ProcessTask(task interface{}) error {
133133
return nil
134134
}
135135

136-
metricsHandler, handlerErr := ntp.taskHandler.metricsHandlerForTask(response)
136+
nctx, handlerErr := ntp.taskHandler.newNexusOperationContext(response)
137137
if handlerErr != nil {
138138
// context wasn't propagated to us, use a background context.
139139
_, err := ntp.taskHandler.client.WorkflowService().RespondNexusTaskFailed(
@@ -145,13 +145,13 @@ func (ntp *nexusTaskPoller) ProcessTask(task interface{}) error {
145145

146146
// Schedule-to-start (from the time the request hit the frontend).
147147
scheduleToStartLatency := executionStartTime.Sub(response.GetRequest().GetScheduledTime().AsTime())
148-
metricsHandler.Timer(metrics.NexusTaskScheduleToStartLatency).Record(scheduleToStartLatency)
148+
nctx.MetricsHandler.Timer(metrics.NexusTaskScheduleToStartLatency).Record(scheduleToStartLatency)
149149

150150
// Process the nexus task.
151-
res, failure, err := ntp.taskHandler.Execute(response)
151+
res, failure, err := ntp.taskHandler.ExecuteContext(nctx, response)
152152

153153
// Execution latency (in-SDK processing time).
154-
metricsHandler.Timer(metrics.NexusTaskExecutionLatency).Record(time.Since(executionStartTime))
154+
nctx.MetricsHandler.Timer(metrics.NexusTaskExecutionLatency).Record(time.Since(executionStartTime))
155155

156156
// Increment failure in all forms of errors:
157157
// Internal error processing the task.
@@ -164,17 +164,18 @@ func (ntp *nexusTaskPoller) ProcessTask(task interface{}) error {
164164
} else {
165165
failureTag = "internal_sdk_error"
166166
}
167-
metricsHandler.
167+
nctx.Log.Error("Error processing nexus task", "error", err)
168+
nctx.MetricsHandler.
168169
WithTags(metrics.NexusTaskFailureTags(failureTag)).
169170
Counter(metrics.NexusTaskExecutionFailedCounter).
170171
Inc(1)
171172
} else if failure != nil {
172-
metricsHandler.
173+
nctx.MetricsHandler.
173174
WithTags(metrics.NexusTaskFailureTags("handler_error_" + failure.GetError().GetErrorType())).
174175
Counter(metrics.NexusTaskExecutionFailedCounter).
175176
Inc(1)
176177
} else if e := res.Response.GetStartOperation().GetOperationError(); e != nil {
177-
metricsHandler.
178+
nctx.MetricsHandler.
178179
WithTags(metrics.NexusTaskFailureTags("operation_" + e.GetOperationState())).
179180
Counter(metrics.NexusTaskExecutionFailedCounter).
180181
Inc(1)
@@ -194,7 +195,7 @@ func (ntp *nexusTaskPoller) ProcessTask(task interface{}) error {
194195
}
195196

196197
// E2E latency, from frontend until we finished reporting completion.
197-
metricsHandler.
198+
nctx.MetricsHandler.
198199
Timer(metrics.NexusTaskEndToEndLatency).
199200
Record(time.Since(response.GetRequest().GetScheduledTime().AsTime()))
200201
return nil

‎internal/internal_nexus_worker.go

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func newNexusWorker(opts nexusWorkerOptions) (*nexusWorker, error) {
5454
opts.executionParameters.TaskQueue,
5555
opts.client,
5656
opts.executionParameters.DataConverter,
57+
opts.executionParameters.FailureConverter,
5758
opts.executionParameters.Logger,
5859
opts.executionParameters.MetricsHandler,
5960
),

‎internal/internal_task_handlers_test.go

-24
Original file line numberDiff line numberDiff line change
@@ -626,30 +626,6 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_BinaryChecksum() {
626626
t.Equal(getBinaryChecksum(), checksums[2])
627627
}
628628

629-
func (t *TaskHandlersTestSuite) TestRespondsToWFTWithWorkerBinaryID() {
630-
taskQueue := "tq1"
631-
workerBuildID := "yaaaay"
632-
testEvents := []*historypb.HistoryEvent{
633-
createTestEventWorkflowExecutionStarted(1, &historypb.WorkflowExecutionStartedEventAttributes{TaskQueue: &taskqueuepb.TaskQueue{Name: taskQueue}}),
634-
createTestEventWorkflowTaskScheduled(2, &historypb.WorkflowTaskScheduledEventAttributes{TaskQueue: &taskqueuepb.TaskQueue{Name: taskQueue}}),
635-
createTestEventWorkflowTaskStarted(3),
636-
}
637-
task := createWorkflowTask(testEvents, 0, "HelloWorld_Workflow")
638-
params := t.getTestWorkerExecutionParams()
639-
params.WorkerBuildID = workerBuildID
640-
taskHandler := newWorkflowTaskHandler(params, nil, t.registry)
641-
wftask := workflowTask{task: task}
642-
wfctx := t.mustWorkflowContextImpl(&wftask, taskHandler)
643-
request, err := taskHandler.ProcessWorkflowTask(&wftask, wfctx, nil)
644-
wfctx.Unlock(err)
645-
response := request.(*workflowservice.RespondWorkflowTaskCompletedRequest)
646-
t.NoError(err)
647-
t.NotNil(response)
648-
t.Equal(workerBuildID, response.GetWorkerVersionStamp().GetBuildId())
649-
// clean up workflow left in cache
650-
params.cache.getWorkflowCache().Delete(task.WorkflowExecution.RunId)
651-
}
652-
653629
func (t *TaskHandlersTestSuite) TestStickyLegacyQueryTaskOnEvictedCache() {
654630
taskQueue := "tq1"
655631
testEvents := []*historypb.HistoryEvent{

‎internal/internal_workflow_testsuite.go

+1
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,7 @@ func (env *testWorkflowEnvironmentImpl) newTestNexusTaskHandler(
24052405
env.workflowInfo.TaskQueueName,
24062406
&testSuiteClientForNexusOperations{env: env},
24072407
env.dataConverter,
2408+
env.failureConverter,
24082409
env.logger,
24092410
env.metricsHandler,
24102411
)

‎test/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ toolchain go1.21.1
77
require (
88
github.com/golang/mock v1.6.0
99
github.com/google/uuid v1.6.0
10-
github.com/nexus-rpc/sdk-go v0.0.12
10+
github.com/nexus-rpc/sdk-go v0.1.0
1111
github.com/opentracing/opentracing-go v1.2.0
1212
github.com/pborman/uuid v1.2.1
1313
github.com/stretchr/testify v1.10.0
1414
github.com/uber-go/tally/v4 v4.1.1
1515
go.opentelemetry.io/otel v1.28.0
1616
go.opentelemetry.io/otel/sdk v1.28.0
1717
go.opentelemetry.io/otel/trace v1.28.0
18-
go.temporal.io/api v1.40.0
18+
go.temporal.io/api v1.43.0
1919
go.temporal.io/sdk v1.29.1
2020
go.temporal.io/sdk/contrib/opentelemetry v0.1.0
2121
go.temporal.io/sdk/contrib/opentracing v0.0.0-00010101000000-000000000000

‎test/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
112112
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
113113
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
114114
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
115-
github.com/nexus-rpc/sdk-go v0.0.12 h1:Bsjo3aKIaApgi/eohhzufwrAeK/sEphcbeZM1Z7S/nI=
116-
github.com/nexus-rpc/sdk-go v0.0.12/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
115+
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
116+
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
117117
github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0=
118118
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
119119
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
@@ -193,8 +193,8 @@ go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2N
193193
go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw=
194194
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
195195
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
196-
go.temporal.io/api v1.40.0 h1:rH3HvUUCFr0oecQTBW5tI6DdDQsX2Xb6OFVgt/bvLto=
197-
go.temporal.io/api v1.40.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
196+
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
197+
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
198198
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
199199
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
200200
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=

‎test/nexus_test.go

+30-40
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ func newTestContext(t *testing.T, ctx context.Context) *testContext {
111111
return tc
112112
}
113113

114-
func (tc *testContext) newNexusClient(t *testing.T, service string) *nexus.Client {
114+
func (tc *testContext) newNexusClient(t *testing.T, service string) *nexus.HTTPClient {
115115
httpClient := http.Client{
116116
Transport: &http.Transport{
117117
TLSClientConfig: tc.testConfig.TLS,
118118
},
119119
}
120-
nc, err := nexus.NewClient(nexus.ClientOptions{
120+
nc, err := nexus.NewHTTPClient(nexus.HTTPClientOptions{
121121
BaseURL: tc.endpointBaseURL,
122122
Service: service,
123123
HTTPCaller: func(r *http.Request) (*http.Response, error) {
@@ -178,12 +178,7 @@ var syncOp = temporalnexus.NewSyncOperation("sync-op", func(ctx context.Context,
178178
}
179179
return s, nil
180180
case "fail":
181-
return "", &nexus.UnsuccessfulOperationError{
182-
State: nexus.OperationStateFailed,
183-
Failure: nexus.Failure{
184-
Message: "fail",
185-
},
186-
}
181+
return "", nexus.NewFailedOperationError(errors.New("fail"))
187182
case "fmt-errorf":
188183
return "", fmt.Errorf("arbitrary error message")
189184
case "handlererror":
@@ -256,7 +251,7 @@ func TestNexusSyncOperation(t *testing.T) {
256251
var unsuccessfulOperationErr *nexus.UnsuccessfulOperationError
257252
require.ErrorAs(t, err, &unsuccessfulOperationErr)
258253
require.Equal(t, nexus.OperationStateFailed, unsuccessfulOperationErr.State)
259-
require.Equal(t, "fail", unsuccessfulOperationErr.Failure.Message)
254+
require.Equal(t, "fail", unsuccessfulOperationErr.Cause.Error())
260255

261256
require.EventuallyWithT(t, func(t *assert.CollectT) {
262257
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -272,7 +267,7 @@ func TestNexusSyncOperation(t *testing.T) {
272267
var handlerErr *nexus.HandlerError
273268
require.ErrorAs(t, err, &handlerErr)
274269
require.Equal(t, nexus.HandlerErrorTypeInternal, handlerErr.Type)
275-
require.Contains(t, handlerErr.Failure.Message, "arbitrary error message")
270+
require.Contains(t, handlerErr.Cause.Error(), "arbitrary error message")
276271

277272
require.EventuallyWithT(t, func(t *assert.CollectT) {
278273
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -287,7 +282,7 @@ func TestNexusSyncOperation(t *testing.T) {
287282
var handlerErr *nexus.HandlerError
288283
require.ErrorAs(t, err, &handlerErr)
289284
require.Equal(t, nexus.HandlerErrorTypeBadRequest, handlerErr.Type)
290-
require.Contains(t, handlerErr.Failure.Message, "handlererror")
285+
require.Contains(t, handlerErr.Cause.Error(), "handlererror")
291286

292287
require.EventuallyWithT(t, func(t *assert.CollectT) {
293288
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -302,7 +297,7 @@ func TestNexusSyncOperation(t *testing.T) {
302297
var handlerErr *nexus.HandlerError
303298
require.ErrorAs(t, err, &handlerErr)
304299
require.Equal(t, nexus.HandlerErrorTypeBadRequest, handlerErr.Type)
305-
require.Contains(t, handlerErr.Failure.Message, "faking workflow already started")
300+
require.Contains(t, handlerErr.Cause.Error(), "faking workflow already started")
306301

307302
require.EventuallyWithT(t, func(t *assert.CollectT) {
308303
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -317,7 +312,7 @@ func TestNexusSyncOperation(t *testing.T) {
317312
var handlerErr *nexus.HandlerError
318313
require.ErrorAs(t, err, &handlerErr)
319314
require.Equal(t, nexus.HandlerErrorTypeInternal, handlerErr.Type)
320-
require.Contains(t, handlerErr.Failure.Message, "fake app error for test")
315+
require.Contains(t, handlerErr.Cause.Error(), "fake app error for test")
321316

322317
require.EventuallyWithT(t, func(t *assert.CollectT) {
323318
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -329,10 +324,10 @@ func TestNexusSyncOperation(t *testing.T) {
329324

330325
t.Run("non-retryable-application-error", func(t *testing.T) {
331326
_, err := nexus.ExecuteOperation(ctx, nc, syncOp, "non-retryable-application-error", nexus.ExecuteOperationOptions{})
332-
var handlerErr *nexus.HandlerError
333-
require.ErrorAs(t, err, &handlerErr)
334-
require.Equal(t, nexus.HandlerErrorTypeBadRequest, handlerErr.Type)
335-
require.Contains(t, handlerErr.Failure.Message, "fake app error for test")
327+
var opErr *nexus.UnsuccessfulOperationError
328+
require.ErrorAs(t, err, &opErr)
329+
require.Equal(t, nexus.OperationStateFailed, opErr.State)
330+
require.Contains(t, opErr.Cause.Error(), "fake app error for test")
336331

337332
require.EventuallyWithT(t, func(t *assert.CollectT) {
338333
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -347,7 +342,7 @@ func TestNexusSyncOperation(t *testing.T) {
347342
var handlerErr *nexus.HandlerError
348343
require.ErrorAs(t, err, &handlerErr)
349344
require.Equal(t, nexus.HandlerErrorTypeInternal, handlerErr.Type)
350-
require.Contains(t, handlerErr.Failure.Message, "panic: panic requested")
345+
require.Contains(t, handlerErr.Cause.Error(), "panic: panic requested")
351346

352347
require.EventuallyWithT(t, func(t *assert.CollectT) {
353348
tc.requireTimer(t, metrics.NexusTaskEndToEndLatency, service.Name, syncOp.Name())
@@ -427,16 +422,19 @@ func TestSyncOperationFromWorkflow(t *testing.T) {
427422
switch outcome {
428423
case "successful":
429424
return outcome, nil
430-
case "failed":
431-
return "", &nexus.UnsuccessfulOperationError{
432-
State: nexus.OperationStateFailed,
433-
Failure: nexus.Failure{Message: "failed for test"},
425+
case "failed-plain-error":
426+
return "", nexus.NewFailedOperationError(errors.New("failed for test"))
427+
case "failed-app-error":
428+
return "", nexus.NewFailedOperationError(temporal.NewApplicationError("failed with app error", "TestType", "foo"))
429+
case "handler-plain-error":
430+
return "", nexus.HandlerErrorf(nexus.HandlerErrorTypeBadRequest, "bad request")
431+
case "handler-app-error":
432+
return "", &nexus.HandlerError{
433+
Type: nexus.HandlerErrorTypeBadRequest,
434+
Cause: temporal.NewApplicationError("failed with app error", "TestType", "foo"),
434435
}
435436
case "canceled":
436-
return "", &nexus.UnsuccessfulOperationError{
437-
State: nexus.OperationStateCanceled,
438-
Failure: nexus.Failure{Message: "canceled for test"},
439-
}
437+
return "", nexus.NewCanceledOperationError(errors.New("canceled for test"))
440438
default:
441439
panic(fmt.Errorf("unexpected outcome: %s", outcome))
442440
}
@@ -483,13 +481,13 @@ func TestSyncOperationFromWorkflow(t *testing.T) {
483481
require.NoError(t, run.Get(ctx, nil))
484482
})
485483

486-
t.Run("OpFailed", func(t *testing.T) {
484+
t.Run("OpFailedPlainError", func(t *testing.T) {
487485
run, err := tc.client.ExecuteWorkflow(ctx, client.StartWorkflowOptions{
488486
TaskQueue: tc.taskQueue,
489487
// The endpoint registry may take a bit to propagate to the history service, use a shorter workflow task
490488
// timeout to speed up the attempts.
491489
WorkflowTaskTimeout: time.Second,
492-
}, wf, "failed")
490+
}, wf, "failed-plain-error")
493491
require.NoError(t, err)
494492
var execErr *temporal.WorkflowExecutionError
495493
err = run.Get(ctx, nil)
@@ -539,6 +537,8 @@ func TestAsyncOperationFromWorkflow(t *testing.T) {
539537
return action, nil
540538
case "fail":
541539
return "", fmt.Errorf("handler workflow failed in test")
540+
case "fail-app-error":
541+
return "", temporal.NewApplicationError("failed with app error", "TestType", "foo")
542542
case "wait-for-cancel":
543543
return "", workflow.Await(ctx, func() bool { return false })
544544
default:
@@ -825,19 +825,9 @@ func TestWorkflowTestSuite_NexusSyncOperation(t *testing.T) {
825825
case "ok":
826826
return outcome, nil
827827
case "failure":
828-
return "", &nexus.UnsuccessfulOperationError{
829-
State: nexus.OperationStateFailed,
830-
Failure: nexus.Failure{
831-
Message: "test operation failed",
832-
},
833-
}
828+
return "", nexus.NewFailedOperationError(errors.New("test operation failed"))
834829
case "handler-error":
835-
return "", &nexus.HandlerError{
836-
Type: nexus.HandlerErrorTypeBadRequest,
837-
Failure: &nexus.Failure{
838-
Message: "test operation failed",
839-
},
840-
}
830+
return "", nexus.HandlerErrorf(nexus.HandlerErrorTypeBadRequest, "test operation failed")
841831
}
842832
panic(fmt.Errorf("invalid outcome: %q", outcome))
843833
})

0 commit comments

Comments
 (0)
Please sign in to comment.