From 86a3357030c85d7b7feccac81b26429f016fd4ff Mon Sep 17 00:00:00 2001 From: evilolipop Date: Mon, 22 Jan 2024 16:48:05 +0800 Subject: [PATCH] fix: fix when *GrainErrorResponse is nil --- .../shared/protos_grain.pb.go | 20 +++++++++++++++- .../cluster-error-response/protos_grain.pb.go | 8 ++++++- .../cluster-grain/shared/protos_grain.pb.go | 5 +++- .../cluster-metrics/shared/protos_grain.pb.go | 11 ++++++++- examples/cluster-pubsub/protos_grain.pb.go | 5 +++- examples/cluster-reentrancy/hello_grain.pb.go | 8 ++++++- .../shared/protos_grain.pb.go | 11 ++++++++- go.mod | 2 +- go.sum | 24 +------------------ .../protoc-gen-go-grain/templates/grain.tmpl | 3 +++ .../testdata/error/hello_grain.pb.go | 5 +++- .../testdata/hello/hello_grain.pb.go | 5 +++- .../multi-services/services_grain.pb.go | 8 ++++++- .../testdata/reenter/hello_grain.pb.go | 8 ++++++- protobuf/protoc-gen-go-grain/version.go | 2 +- 15 files changed, 89 insertions(+), 36 deletions(-) diff --git a/examples/cluster-broadcast/shared/protos_grain.pb.go b/examples/cluster-broadcast/shared/protos_grain.pb.go index 19d702f8..d8639c33 100644 --- a/examples/cluster-broadcast/shared/protos_grain.pb.go +++ b/examples/cluster-broadcast/shared/protos_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: protos.proto @@ -87,6 +87,9 @@ func (g *CalculatorGrainClient) Add(r *NumberRequest, opts ...cluster.GrainCallO case *CountResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -108,6 +111,9 @@ func (g *CalculatorGrainClient) Subtract(r *NumberRequest, opts ...cluster.Grain case *CountResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -129,6 +135,9 @@ func (g *CalculatorGrainClient) GetCurrent(r *Noop, opts ...cluster.GrainCallOpt case *CountResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -308,6 +317,9 @@ func (g *TrackerGrainClient) RegisterGrain(r *RegisterMessage, opts ...cluster.G case *Noop: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -329,6 +341,9 @@ func (g *TrackerGrainClient) DeregisterGrain(r *RegisterMessage, opts ...cluster case *Noop: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -350,6 +365,9 @@ func (g *TrackerGrainClient) BroadcastGetCounts(r *Noop, opts ...cluster.GrainCa case *TotalsResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/examples/cluster-error-response/protos_grain.pb.go b/examples/cluster-error-response/protos_grain.pb.go index fbac0c14..42f4cee1 100644 --- a/examples/cluster-error-response/protos_grain.pb.go +++ b/examples/cluster-error-response/protos_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: protos.proto @@ -114,6 +114,9 @@ func (g *HelloGrainClient) Reenterable(r *ReenterableRequest, opts ...cluster.Gr case *ReenterableResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -135,6 +138,9 @@ func (g *HelloGrainClient) Hello(r *HelloRequest, opts ...cluster.GrainCallOptio case *HelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/examples/cluster-grain/shared/protos_grain.pb.go b/examples/cluster-grain/shared/protos_grain.pb.go index 1f8fc547..c6465eff 100644 --- a/examples/cluster-grain/shared/protos_grain.pb.go +++ b/examples/cluster-grain/shared/protos_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: protos.proto @@ -85,6 +85,9 @@ func (g *HelloGrainClient) SayHello(r *HelloRequest, opts ...cluster.GrainCallOp case *HelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/examples/cluster-metrics/shared/protos_grain.pb.go b/examples/cluster-metrics/shared/protos_grain.pb.go index 16449b7d..1f71e2eb 100644 --- a/examples/cluster-metrics/shared/protos_grain.pb.go +++ b/examples/cluster-metrics/shared/protos_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: protos.proto @@ -87,6 +87,9 @@ func (g *HelloGrainClient) SayHello(r *HelloRequest, opts ...cluster.GrainCallOp case *HelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -108,6 +111,9 @@ func (g *HelloGrainClient) Add(r *AddRequest, opts ...cluster.GrainCallOption) ( case *AddResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -129,6 +135,9 @@ func (g *HelloGrainClient) VoidFunc(r *AddRequest, opts ...cluster.GrainCallOpti case *Unit: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/examples/cluster-pubsub/protos_grain.pb.go b/examples/cluster-pubsub/protos_grain.pb.go index 31936c5f..f12ae3a5 100644 --- a/examples/cluster-pubsub/protos_grain.pb.go +++ b/examples/cluster-pubsub/protos_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: protos.proto @@ -85,6 +85,9 @@ func (g *UserActorGrainClient) Connect(r *Empty, opts ...cluster.GrainCallOption case *Empty: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/examples/cluster-reentrancy/hello_grain.pb.go b/examples/cluster-reentrancy/hello_grain.pb.go index 70a31a7e..4686ac4a 100644 --- a/examples/cluster-reentrancy/hello_grain.pb.go +++ b/examples/cluster-reentrancy/hello_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: hello.proto @@ -102,6 +102,9 @@ func (g *HelloGrainClient) InvokeService(r *InvokeServiceRequest, opts ...cluste case *InvokeServiceResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -139,6 +142,9 @@ func (g *HelloGrainClient) DoWork(r *DoWorkRequest, opts ...cluster.GrainCallOpt case *DoWorkResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/examples/cluster-restartgracefully/shared/protos_grain.pb.go b/examples/cluster-restartgracefully/shared/protos_grain.pb.go index b41c364a..fa456c07 100644 --- a/examples/cluster-restartgracefully/shared/protos_grain.pb.go +++ b/examples/cluster-restartgracefully/shared/protos_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.5.0 +// protoc-gen-grain v0.5.1 // protoc v4.25.0 // source: protos.proto @@ -87,6 +87,9 @@ func (g *CalculatorGrainClient) Add(r *NumberRequest, opts ...cluster.GrainCallO case *CountResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -108,6 +111,9 @@ func (g *CalculatorGrainClient) Subtract(r *NumberRequest, opts ...cluster.Grain case *CountResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -129,6 +135,9 @@ func (g *CalculatorGrainClient) GetCurrent(r *Void, opts ...cluster.GrainCallOpt case *CountResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/go.mod b/go.mod index 946afd66..51723038 100644 --- a/go.mod +++ b/go.mod @@ -104,7 +104,7 @@ require ( golang.org/x/oauth2 v0.13.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.14.0 golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect diff --git a/go.sum b/go.sum index ed3d9db1..a562c37f 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,6 @@ github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/consul/api v1.26.1 h1:5oSXOO5fboPZeW5SN+TdGFP/BILDgBm19OrPZ/pICIM= @@ -325,8 +323,6 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= @@ -339,7 +335,6 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -349,12 +344,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= -golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -393,14 +384,10 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= -golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -429,23 +416,14 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= -google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= -google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/protobuf/protoc-gen-go-grain/templates/grain.tmpl b/protobuf/protoc-gen-go-grain/templates/grain.tmpl index 5ca0c155..72ee056c 100644 --- a/protobuf/protoc-gen-go-grain/templates/grain.tmpl +++ b/protobuf/protoc-gen-go-grain/templates/grain.tmpl @@ -92,6 +92,9 @@ func (g *{{ $service.Name }}GrainClient) {{ $method.Name }}(r *{{ $method.Input case *{{ $method.Output }}: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/protobuf/protoc-gen-go-grain/testdata/error/hello_grain.pb.go b/protobuf/protoc-gen-go-grain/testdata/error/hello_grain.pb.go index 10d413ed..cd6966ea 100644 --- a/protobuf/protoc-gen-go-grain/testdata/error/hello_grain.pb.go +++ b/protobuf/protoc-gen-go-grain/testdata/error/hello_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.4.1 +// protoc-gen-grain v0.5.0 // protoc v4.25.0 // source: testdata/error/hello.proto @@ -110,6 +110,9 @@ func (g *HelloGrainClient) SayHello(r *emptypb.Empty, opts ...cluster.GrainCallO case *SayHelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/protobuf/protoc-gen-go-grain/testdata/hello/hello_grain.pb.go b/protobuf/protoc-gen-go-grain/testdata/hello/hello_grain.pb.go index ba88ea7f..f7230ecf 100644 --- a/protobuf/protoc-gen-go-grain/testdata/hello/hello_grain.pb.go +++ b/protobuf/protoc-gen-go-grain/testdata/hello/hello_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.4.1 +// protoc-gen-grain v0.5.0 // protoc v4.25.0 // source: testdata/hello/hello.proto @@ -86,6 +86,9 @@ func (g *HelloGrainClient) SayHello(r *emptypb.Empty, opts ...cluster.GrainCallO case *SayHelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/protobuf/protoc-gen-go-grain/testdata/multi-services/services_grain.pb.go b/protobuf/protoc-gen-go-grain/testdata/multi-services/services_grain.pb.go index 9e4eb6a8..61f4686b 100644 --- a/protobuf/protoc-gen-go-grain/testdata/multi-services/services_grain.pb.go +++ b/protobuf/protoc-gen-go-grain/testdata/multi-services/services_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.4.1 +// protoc-gen-grain v0.5.0 // protoc v4.25.0 // source: testdata/multi-services/services.proto @@ -86,6 +86,9 @@ func (g *HelloGrainClient) SayHello(r *emptypb.Empty, opts ...cluster.GrainCallO case *SayHelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -223,6 +226,9 @@ func (g *WorkGrainClient) DoWork(r *DoWorkRequest, opts ...cluster.GrainCallOpti case *DoWorkResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/protobuf/protoc-gen-go-grain/testdata/reenter/hello_grain.pb.go b/protobuf/protoc-gen-go-grain/testdata/reenter/hello_grain.pb.go index 26a2a561..3d14e505 100644 --- a/protobuf/protoc-gen-go-grain/testdata/reenter/hello_grain.pb.go +++ b/protobuf/protoc-gen-go-grain/testdata/reenter/hello_grain.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-grain. DO NOT EDIT. // versions: -// protoc-gen-grain v0.4.1 +// protoc-gen-grain v0.5.0 // protoc v4.25.0 // source: testdata/reenter/hello.proto @@ -86,6 +86,9 @@ func (g *HelloGrainClient) SayHello(r *SayHelloRequest, opts ...cluster.GrainCal case *SayHelloResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) @@ -123,6 +126,9 @@ func (g *HelloGrainClient) Dowork(r *DoworkRequest, opts ...cluster.GrainCallOpt case *DoworkResponse: return msg, nil case *cluster.GrainErrorResponse: + if msg == nil { + return nil, nil + } return nil, msg default: return nil, fmt.Errorf("unknown response type %T", resp) diff --git a/protobuf/protoc-gen-go-grain/version.go b/protobuf/protoc-gen-go-grain/version.go index 2916cf14..0454b2c7 100644 --- a/protobuf/protoc-gen-go-grain/version.go +++ b/protobuf/protoc-gen-go-grain/version.go @@ -1,3 +1,3 @@ package main -const version = "v0.5.0" +const version = "v0.5.1"