diff --git a/cmd/proxygenerator/go.mod b/cmd/proxygenerator/go.mod index 041a469f..9f5d2cce 100644 --- a/cmd/proxygenerator/go.mod +++ b/cmd/proxygenerator/go.mod @@ -1,6 +1,6 @@ module go.temporal.io/api/cmd/proxygenerator -go 1.20 +go 1.21 replace go.temporal.io/api => ../.. @@ -16,8 +16,8 @@ require ( golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/grpc v1.65.0 // indirect google.golang.org/protobuf v1.34.2 // indirect ) diff --git a/cmd/proxygenerator/go.sum b/cmd/proxygenerator/go.sum index 0980d104..6fdfcb4e 100644 --- a/cmd/proxygenerator/go.sum +++ b/cmd/proxygenerator/go.sum @@ -1,9 +1,13 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI= github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= @@ -16,12 +20,13 @@ golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 h1:+/tmTy5zAieooKIXfzDm9KiA3Bv6JBwriRN9LY+yayk= -google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988/go.mod h1:4+X6GvPs+25wZKbQq9qyAXrwIRExv7w0Ea6MgZLZiDM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cmd/proxygenerator/interceptor.go b/cmd/proxygenerator/interceptor.go index 0e5d3fc6..0017ee56 100644 --- a/cmd/proxygenerator/interceptor.go +++ b/cmd/proxygenerator/interceptor.go @@ -457,9 +457,14 @@ func generateInterceptor(cfg config) error { if err != nil { return err } - service := serviceTypes[0] + exportTypes, err := lookupTypes("go.temporal.io/api/export/v1", []string{"WorkflowExecutions"}) + if err != nil { + return err + } + workflowExecutions := types.NewPointer(exportTypes[0]) + payloadRecords := map[string]*TypeRecord{} failureRecords := map[string]*TypeRecord{} @@ -475,6 +480,9 @@ func generateInterceptor(cfg config) error { walk(failureTypes, sig.Results().At(0).Type(), &failureRecords) } + walk(payloadTypes, workflowExecutions, &payloadRecords) + walk(failureTypes, workflowExecutions, &failureRecords) + payloadRecords = pruneRecords(payloadRecords) failureRecords = pruneRecords(failureRecords) diff --git a/go.mod b/go.mod index 05b5bbc9..164a3f78 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.temporal.io/api -go 1.20 +go 1.21 require ( github.com/golang/mock v1.6.0 diff --git a/go.sum b/go.sum index a399f2b9..4167792d 100644 --- a/go.sum +++ b/go.sum @@ -4,9 +4,11 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI= github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -54,5 +56,6 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/proxy/interceptor.go b/proxy/interceptor.go index f16d7194..9ff57ea8 100644 --- a/proxy/interceptor.go +++ b/proxy/interceptor.go @@ -31,6 +31,7 @@ import ( "go.temporal.io/api/batch/v1" "go.temporal.io/api/command/v1" "go.temporal.io/api/common/v1" + "go.temporal.io/api/export/v1" "go.temporal.io/api/failure/v1" "go.temporal.io/api/history/v1" "go.temporal.io/api/nexus/v1" @@ -478,6 +479,41 @@ func visitPayloads(ctx *VisitPayloadsContext, options *VisitPayloadsOptions, obj return err } + case []*export.WorkflowExecution: + for _, x := range o { + if err := visitPayloads(ctx, options, x); err != nil { + return err + } + } + + case *export.WorkflowExecution: + + if o == nil { + continue + } + ctx.Parent = o + if err := visitPayloads( + ctx, + options, + o.GetHistory(), + ); err != nil { + return err + } + + case *export.WorkflowExecutions: + + if o == nil { + continue + } + ctx.Parent = o + if err := visitPayloads( + ctx, + options, + o.GetItems(), + ); err != nil { + return err + } + case *failure.ApplicationFailureInfo: if o == nil { @@ -2263,6 +2299,39 @@ func visitFailures(ctx *VisitFailuresContext, options *VisitFailuresOptions, obj return err } + case []*export.WorkflowExecution: + for _, x := range o { + if err := visitFailures(ctx, options, x); err != nil { + return err + } + } + + case *export.WorkflowExecution: + if o == nil { + continue + } + ctx.Parent = o + if err := visitFailures( + ctx, + options, + o.GetHistory(), + ); err != nil { + return err + } + + case *export.WorkflowExecutions: + if o == nil { + continue + } + ctx.Parent = o + if err := visitFailures( + ctx, + options, + o.GetItems(), + ); err != nil { + return err + } + case *history.ActivityTaskFailedEventAttributes: if o == nil { continue diff --git a/proxy/interceptor_test.go b/proxy/interceptor_test.go index 4547d265..729392a1 100644 --- a/proxy/interceptor_test.go +++ b/proxy/interceptor_test.go @@ -34,7 +34,9 @@ import ( "github.com/stretchr/testify/require" "go.temporal.io/api/common/v1" + "go.temporal.io/api/export/v1" "go.temporal.io/api/failure/v1" + "go.temporal.io/api/history/v1" "go.temporal.io/api/workflowservice/v1" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -92,6 +94,28 @@ func TestVisitPayloads(t *testing.T) { ) require.NoError(err) + err = VisitPayloads( + context.Background(), + &export.WorkflowExecutions{Items: []*export.WorkflowExecution{{History: &history.History{ + Events: []*history.HistoryEvent{ + { + Attributes: &history.HistoryEvent_WorkflowExecutionStartedEventAttributes{ + WorkflowExecutionStartedEventAttributes: &history.WorkflowExecutionStartedEventAttributes{ + Input: inputPayloads(), + }, + }, + }, + }, + }}}}, + VisitPayloadsOptions{ + Visitor: func(vpc *VisitPayloadsContext, p []*common.Payload) ([]*common.Payload, error) { + require.False(vpc.SinglePayloadRequired) + require.Equal([]byte("test"), p[0].Data) + return p, nil + }, + }, + ) + require.NoError(err) } func TestVisitFailures(t *testing.T) {