Skip to content

Commit

Permalink
Merge pull request #349 from yarpc/ronakj/release
Browse files Browse the repository at this point in the history
Yab Release v0.21.0
  • Loading branch information
jronak authored Sep 2, 2021
2 parents 5f8e469 + ec89c2d commit 5eef999
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

# 0.21.0 (2021-09-01)
* Fix gRPC server stream handling to be compatible with Java gRPC server.
* Fix parsing of protobuf responses/error-details containing Any type fields, by maintaining
reflection server connection until end of the request.

# 0.20.0 (2021-05-18)
* Add `stream-delay-close-send` option which delays client send stream closure.
* New: gRPC details are now printed along with the error if there are any.
Expand Down
8 changes: 7 additions & 1 deletion encoding/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type protoSerializer struct {
serviceName string
methodName string
method *desc.MethodDescriptor
anyResolver jsonpb.AnyResolver
anyResolver anyResolver
}

// bytesMsg wraps a raw byte slice for serialization purposes. Especially
Expand Down Expand Up @@ -264,6 +264,12 @@ func (p protoStreamRequestReader) NextBody() ([]byte, error) {
return p.proto.encode(body)
}

// Close stops the protobuf reflection/file based descriptor provider.
func (p protoSerializer) Close() error {
p.anyResolver.source.Close()
return nil
}

func splitMethod(fullMethod string) (svc, method string, err error) {
parts := strings.Split(fullMethod, "/")
switch len(parts) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
go.uber.org/zap v1.10.0
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17
golang.org/x/text v0.3.1-0.20180511172408-5c1cf69b5978 // indirect
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 // indirect
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
google.golang.org/grpc v1.24.0
gopkg.in/yaml.v2 v2.2.2
)
Expand Down
4 changes: 4 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ func makeServerStream(ctx context.Context, stream *yarpctransport.ClientStream,
return err
}

if err := closeSendStream(ctx, stream, 0); err != nil {
return err
}

for err == nil {
var resBody []byte
if resBody, err = receiveStreamMessage(ctx, stream); err != nil {
Expand Down
10 changes: 8 additions & 2 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"time"

"github.com/yarpc/yab/testdata/gen-go/integration"
testdataany "github.com/yarpc/yab/testdata/protobuf/any"
"github.com/yarpc/yab/testdata/protobuf/simple"
yintegration "github.com/yarpc/yab/testdata/yarpc/integration"
"github.com/yarpc/yab/testdata/yarpc/integration/fooserver"
Expand All @@ -54,9 +55,9 @@ import (
yhttp "go.uber.org/yarpc/transport/http"
ytchan "go.uber.org/yarpc/transport/tchannel"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/reflection"
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

Expand Down Expand Up @@ -383,7 +384,7 @@ func (s *simpleService) Baz(c context.Context, in *simple.Foo) (*simple.Foo, err

if in.Test == -1 {
st := status.New(codes.InvalidArgument, "invalid username")
st, err := st.WithDetails(in)
st, err := st.WithDetails(in, &testdataany.FooAny{Value: 123})
if err != nil {
// If this errored, it will always error
// here, so better panic so we can figure
Expand Down Expand Up @@ -1212,6 +1213,11 @@ func TestGRPCReflectionSource(t *testing.T) {
"type.googleapis.com/Foo": {
"test": -1
}
},
{
"type.googleapis.com/FooAny": {
"value": 123
}
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ func runWithOptions(opts Options, out output, logger *zap.Logger) {
if err != nil {
out.Fatalf("Failed while parsing input: %v\n", err)
}
if serializerWithClose, ok := serializer.(io.Closer); ok {
defer serializerWithClose.Close()
}

tracer, closer := getTracer(opts, out)
if closer != nil {
Expand Down
3 changes: 0 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ func NewSerializer(opts Options, resolved resolvedProtocolEncoding) (encoding.Se
return nil, err
}

// The descriptor is only used in the New function, so it's safe to defer Close.
defer descSource.Close()

return encoding.NewProtobuf(opts.ROpts.Procedure, descSource)
}

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ package main

// versionString is the sem-ver version string for yab.
// It will be bumped explicitly on releases.
var versionString = "0.20.0"
var versionString = "0.21.0"

0 comments on commit 5eef999

Please sign in to comment.