Skip to content

Commit

Permalink
Use the new temporalproto JSON APIs
Browse files Browse the repository at this point in the history
These offer better performance than the previous versions.
  • Loading branch information
tdeebswihart committed Nov 28, 2023
1 parent 46d78ca commit 8d9d173
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 200 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ jobs:
feature-tests-go:
uses: ./.github/workflows/go.yaml
with:
# First commit that supports google/protobuf
version: f9d73bfdf7c8d3ec0311306140fbfafa7fb6f9cf
# First commit that supports the new temporalproto APIs
version: 8f2a3c8f967a5898f45df92f6bc42196e4702a2d
version-is-repo-ref: true
features-repo-ref: ${{ github.head_ref }}
features-repo-path: ${{ github.event.pull_request.head.repo.full_name }}
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
# TODO: Find some way to automatically upgrade to "latest"
with:
do-push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
go-repo-ref: 'f9d73bfdf7c8d3ec0311306140fbfafa7fb6f9cf'
go-repo-ref: '8f2a3c8f967a5898f45df92f6bc42196e4702a2d'
ts-ver: 'v1.5.2'
java-ver: 'v1.22.0'
py-ver: 'v1.4.0'
Expand Down
6 changes: 3 additions & 3 deletions features/data_converter/binary/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ func CheckResult(ctx context.Context, runner *harness.Runner, run client.Workflo
}

// load JSON payload from `./payload.json` and compare it to result payload
file, err := os.Open(filepath.Join(runner.Feature.AbsDir, "../../../features/data_converter/binary/payload.json"))
contents, err := os.ReadFile(filepath.Join(runner.Feature.AbsDir, "../../../features/data_converter/binary/payload.json"))
if err != nil {
return err
}

expectedPayload := &common.Payload{}
decoder := temporalproto.NewJSONDecoder(file, false)
if err := decoder.Decode(expectedPayload); err != nil {
var opts temporalproto.CustomJSONUnmarshalOptions
if err := opts.Unmarshal(contents, expectedPayload); err != nil {
return err
}
runner.Require.True(proto.Equal(expectedPayload, payload))
Expand Down
6 changes: 3 additions & 3 deletions features/data_converter/empty/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ func CheckResult(ctx context.Context, runner *harness.Runner, run client.Workflo
payload := attrs.GetInput().GetPayloads()[0]

// load JSON payload from `./payload.json` and compare it to result payload
file, err := os.Open(path.Join(runner.Feature.AbsDir, "payload.json"))
contents, err := os.ReadFile(path.Join(runner.Feature.AbsDir, "payload.json"))
if err != nil {
return err
}

expectedPayload := &common.Payload{}
decoder := temporalproto.NewJSONDecoder(file, false)
if err := decoder.Decode(expectedPayload); err != nil {
var opts temporalproto.CustomJSONUnmarshalOptions
if err := opts.Unmarshal(contents, expectedPayload); err != nil {
return err
}
runner.Require.True(proto.Equal(expectedPayload, payload))
Expand Down
3 changes: 2 additions & 1 deletion features/data_converter/json_protobuf/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func CheckResult(ctx context.Context, runner *harness.Runner, run client.Workflo
runner.Require.Equal("temporal.api.common.v1.DataBlob", messageType)

resultInHistory := commonpb.DataBlob{}
if err := temporalproto.UnmarshalJSON(payload.GetData(), &resultInHistory); err != nil {
var opts temporalproto.CustomJSONUnmarshalOptions
if err := opts.Unmarshal(payload.GetData(), &resultInHistory); err != nil {
return err
}

Expand Down
16 changes: 8 additions & 8 deletions features/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
github.com/google/uuid v1.3.1
github.com/temporalio/features/harness/go v1.0.0
github.com/uber-go/tally/v4 v4.1.1
go.temporal.io/api v1.26.1-0.20231121220434-5a4d95cc60c0
go.temporal.io/sdk v1.25.2-0.20231121222453-f9d73bfdf7c8
go.temporal.io/sdk/contrib/tally v0.1.0
go.temporal.io/api v1.26.1-0.20231128184747-3be2272d0651
go.temporal.io/sdk v1.25.2-0.20231128192636-8f2a3c8f967a
go.temporal.io/sdk/contrib/tally v0.2.1-0.20231128192636-8f2a3c8f967a
golang.org/x/mod v0.11.0
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
Expand All @@ -31,13 +31,13 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
88 changes: 16 additions & 72 deletions features/go.sum

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/temporalio/features/features v1.0.0
github.com/temporalio/features/harness/go v1.0.0
github.com/urfave/cli/v2 v2.25.7
go.temporal.io/sdk v1.25.2-0.20231121222453-f9d73bfdf7c8
go.temporal.io/sdk v1.25.2-0.20231128192636-8f2a3c8f967a
golang.org/x/mod v0.12.0
)

Expand All @@ -30,18 +30,18 @@ require (
github.com/twmb/murmur3 v1.1.8 // indirect
github.com/uber-go/tally/v4 v4.1.7 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.temporal.io/api v1.26.1-0.20231121220434-5a4d95cc60c0 // indirect
go.temporal.io/sdk/contrib/tally v0.2.0 // indirect
go.temporal.io/api v1.26.1-0.20231128184747-3be2272d0651 // indirect
go.temporal.io/sdk/contrib/tally v0.2.1-0.20231128192636-8f2a3c8f967a // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 8d9d173

Please sign in to comment.