From ddc61032d3075fd7d00c7a8475b93d80bebfbcd1 Mon Sep 17 00:00:00 2001 From: Wit Riewrangboonya Date: Thu, 26 Aug 2021 16:23:30 -0700 Subject: [PATCH] Review comments --- encoding/thrift/envelope.go | 14 +- encoding/thrift/envelope_test.go | 48 ++++--- encoding/thrift/fakes_test.go | 7 +- .../test/testserviceclient/client.go | 6 +- encoding/thrift/multiplex.go | 2 +- encoding/thrift/outbound_nowire.go | 8 +- encoding/thrift/outbound_nowire_test.go | 134 ++++++++++-------- .../thrift/thriftrw-plugin-yarpc/client.go | 6 +- .../atomic/readonlystoreclient/client.go | 6 +- .../tests/atomic/storeclient/client.go | 12 +- .../tests/common/baseserviceclient/client.go | 6 +- .../tests/common/extendemptyclient/client.go | 6 +- .../tests/extends/nameclient/client.go | 6 +- .../tests/weather/weatherclient/client.go | 6 +- .../thrift/echo/echoclient/client.go | 6 +- .../gauntlet/secondserviceclient/client.go | 12 +- .../gauntlet/thrifttestclient/client.go | 120 ++++++---------- .../hello/echo/helloclient/client.go | 6 +- .../keyvalue/kv/keyvalueclient/client.go | 12 +- 19 files changed, 186 insertions(+), 237 deletions(-) diff --git a/encoding/thrift/envelope.go b/encoding/thrift/envelope.go index cb420782b..65a5c7c5c 100644 --- a/encoding/thrift/envelope.go +++ b/encoding/thrift/envelope.go @@ -76,7 +76,7 @@ func (evnw disableEnvelopingNoWireProtocol) Reader(r io.Reader) stream.Reader { } func (evnw disableEnvelopingNoWireProtocol) Writer(w io.Writer) stream.Writer { - return disableEnvelopingWriter{ + return disableEnvelopingNoWireWriter{ Writer: evnw.Protocol.Writer(w), } } @@ -89,18 +89,20 @@ type disableEnvelopingNoWireReader struct { Type wire.EnvelopeType } -func (evr disableEnvelopingNoWireReader) ReadEnvelopeBegin() (stream.EnvelopeHeader, error) { +func (evnwr disableEnvelopingNoWireReader) ReadEnvelopeBegin() (stream.EnvelopeHeader, error) { return stream.EnvelopeHeader{ Name: "", // we don't use the decoded name anywhere - Type: evr.Type, + Type: evnwr.Type, SeqID: 1, }, nil } -// disableEnvelopingWriter overrides the normal WriteEnvelopeBegin with not +// disableEnvelopingNoWireWriter overrides the normal WriteEnvelopeBegin with not // performing any writing of any enveloping. -type disableEnvelopingWriter struct { +type disableEnvelopingNoWireWriter struct { stream.Writer } -func (evw disableEnvelopingWriter) WriteEnvelopeBegin(stream.EnvelopeHeader) error { return nil } +func (evnww disableEnvelopingNoWireWriter) WriteEnvelopeBegin(stream.EnvelopeHeader) error { + return nil +} diff --git a/encoding/thrift/envelope_test.go b/encoding/thrift/envelope_test.go index d7e4d893d..335c83135 100644 --- a/encoding/thrift/envelope_test.go +++ b/encoding/thrift/envelope_test.go @@ -83,29 +83,8 @@ func TestDisableEnveloperEncode(t *testing.T) { } } -// generate generates a random value into the given pointer. -// -// var i int -// generate(&i, rand) -// -// If the type implements the quick.Generator interface, that is used. -func generate(v interface{}, r *rand.Rand) { - t := reflect.TypeOf(v) - if t.Kind() != reflect.Ptr { - panic(fmt.Sprintf("%v is not a pointer type", t)) - } - - out, ok := quick.Value(t.Elem(), r) - if !ok { - panic(fmt.Sprintf("could not generate a value for %v", t)) - } - - reflect.ValueOf(v).Elem().Set(out) -} - func TestDisableEnveloperNoWireRead(t *testing.T) { cont := "some buffered contents" - buf := bytes.NewBuffer([]byte(cont)) evnw := disableEnvelopingNoWireProtocol{Protocol: binary.Default, Type: wire.Call} sr := evnw.Reader(buf) @@ -126,7 +105,30 @@ func TestDisableEnveloperNoWireWrite(t *testing.T) { evnw := disableEnvelopingNoWireProtocol{Protocol: binary.Default, Type: wire.OneWay} sw := evnw.Writer(&buf) - assert.NoError(t, sw.WriteEnvelopeBegin(stream.EnvelopeHeader{Name: "foo", Type: wire.Exception})) - assert.NoError(t, sw.WriteEnvelopeEnd()) + err := sw.WriteEnvelopeBegin(stream.EnvelopeHeader{Name: "foo", Type: wire.Exception}) + require.NoError(t, err) + + err = sw.WriteEnvelopeEnd() + assert.NoError(t, err) assert.Zero(t, buf.Len(), "writeenvelope is not supposed to write to the buffer") } + +// generate generates a random value into the given pointer. +// +// var i int +// generate(&i, rand) +// +// If the type implements the quick.Generator interface, that is used. +func generate(v interface{}, r *rand.Rand) { + t := reflect.TypeOf(v) + if t.Kind() != reflect.Ptr { + panic(fmt.Sprintf("%v is not a pointer type", t)) + } + + out, ok := quick.Value(t.Elem(), r) + if !ok { + panic(fmt.Sprintf("could not generate a value for %v", t)) + } + + reflect.ValueOf(v).Elem().Set(out) +} diff --git a/encoding/thrift/fakes_test.go b/encoding/thrift/fakes_test.go index ba3f90b0a..8c5677d77 100644 --- a/encoding/thrift/fakes_test.go +++ b/encoding/thrift/fakes_test.go @@ -27,10 +27,7 @@ import ( "go.uber.org/thriftrw/wire" ) -const ( - _irrelevant = "irrelevant" - _response = "response" -) +const _irrelevant = "irrelevant" type fakeBodyReader struct { body string @@ -42,6 +39,8 @@ func (f *fakeBodyReader) Decode(sr stream.Reader) error { return err } +// TODO(witriew): fakeEnveloper should be created with a constructor, allowing +// its uses to dictate the returned values for MethodName and encoded string. type fakeEnveloper wire.EnvelopeType func (fakeEnveloper) MethodName() string { diff --git a/encoding/thrift/internal/observabilitytest/test/testserviceclient/client.go b/encoding/thrift/internal/observabilitytest/test/testserviceclient/client.go index c3827840a..763eee6c0 100644 --- a/encoding/thrift/internal/observabilitytest/test/testserviceclient/client.go +++ b/encoding/thrift/internal/observabilitytest/test/testserviceclient/client.go @@ -81,14 +81,12 @@ func (c client) Call( args := test.TestService_Call_Helper.Args(_Key) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/multiplex.go b/encoding/thrift/multiplex.go index 6dbe1b7d2..7bac1d575 100644 --- a/encoding/thrift/multiplex.go +++ b/encoding/thrift/multiplex.go @@ -89,7 +89,7 @@ func (w multiplexedNoWireWriter) WriteEnvelopeBegin(eh stream.EnvelopeHeader) er } // multiplexedNoWireReader overrides the normal ReadEnvelopeBegin with stripping -// away the service name from the envlope. +// away the service name from the envelope. type multiplexedNoWireReader struct { stream.Reader diff --git a/encoding/thrift/outbound_nowire.go b/encoding/thrift/outbound_nowire.go index eb80945da..920481aad 100644 --- a/encoding/thrift/outbound_nowire.go +++ b/encoding/thrift/outbound_nowire.go @@ -23,6 +23,7 @@ package thrift import ( "bytes" "context" + "fmt" "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/protocol/stream" @@ -56,7 +57,8 @@ type NoWireClient interface { Enabled() bool } -// NewNoWire creates a new Thrift client. +// NewNoWire creates a new Thrift client that leverages ThriftRW's "streaming" +// implementation. func NewNoWire(c Config, opts ...ClientOption) NoWireClient { // Code generated for Thrift client instantiation will probably be something // like this: @@ -82,6 +84,10 @@ func NewNoWire(c Config, opts ...ClientOption) NoWireClient { if cc.Protocol != nil { if val, ok := cc.Protocol.(stream.Protocol); ok { p = val + } else { + panic(fmt.Sprintf( + "You have found a bug in YARPC. Please file a bug report at https://github.com/yarpc/yarpc-go/issues with this message: "+ + "NewNoWire expected provided protocol %T to implement stream.Protocol", cc.Protocol)) } } diff --git a/encoding/thrift/outbound_nowire_test.go b/encoding/thrift/outbound_nowire_test.go index ab196255b..0710b5dc8 100644 --- a/encoding/thrift/outbound_nowire_test.go +++ b/encoding/thrift/outbound_nowire_test.go @@ -23,6 +23,7 @@ package thrift import ( "bytes" "context" + "encoding/binary" "errors" "io" "testing" @@ -31,7 +32,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/thriftrw/protocol" - "go.uber.org/thriftrw/protocol/binary" + tbinary "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/protocol/stream" "go.uber.org/thriftrw/thrifttest/streamtest" "go.uber.org/thriftrw/wire" @@ -41,123 +42,123 @@ import ( "go.uber.org/yarpc/internal/testtime" ) +const _response = "response" + func TestNoWireClientCall(t *testing.T) { tests := []struct { - msg string + desc string giveRequestBody stream.Enveloper - giveResponseBody []byte + giveResponseBody string clientOptions []ClientOption expectCall bool - wantRequestBody []byte + wantRequestBody string wantResponseBody string wantError string }{ { - msg: "positive case, without enveloping", + desc: "positive case, without enveloping", giveRequestBody: fakeEnveloper(wire.Call), - giveResponseBody: []byte("\x00\x00\x00\x08" + _response), // len(string) + string + giveResponseBody: encodeThriftString(_response), expectCall: true, - wantRequestBody: []byte("\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + wantRequestBody: encodeThriftString(_irrelevant), wantResponseBody: _response, }, { - msg: "positive case, with enveloping", + desc: "positive case, with enveloping", giveRequestBody: fakeEnveloper(wire.Call), - giveResponseBody: []byte("\x80\x01\x00\x02" + // strict envelope version + wire.Reply - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + giveResponseBody: "\x80\x01\x00\x02" + // strict envelope version + wire.Reply + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x08" + _response), // len(string) + string + encodeThriftString(_response), clientOptions: []ClientOption{Enveloped}, expectCall: true, - wantRequestBody: []byte("\x80\x01\x00\x01" + // strict envelope version + wire.Call - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + wantRequestBody: "\x80\x01\x00\x01" + // strict envelope version + wire.Call + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + encodeThriftString(_irrelevant), wantResponseBody: _response, }, { - msg: "unexpected request envelope type", + desc: "unexpected request envelope type", giveRequestBody: fakeEnveloper(wire.Exception), wantError: `failed to encode "thrift" request body for procedure "MyService::someMethod" of service "service": unexpected envelope type: Exception`, }, { - msg: "response envelope exception (TApplicationException) decoding error", + desc: "response envelope exception (TApplicationException) decoding error", giveRequestBody: fakeEnveloper(wire.Call), clientOptions: []ClientOption{Enveloped}, - giveResponseBody: []byte("\x80\x01\x00\x03" + // strict envelope version + wire.Exception - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string - "\x00\x00\x00\x01"), // seqID + giveResponseBody: "\x80\x01\x00\x03" + // strict envelope version + wire.Exception + encodeThriftString("someMethod") + + "\x00\x00\x00\x01", // seqID expectCall: true, - wantRequestBody: []byte("\x80\x01\x00\x01" + // strict envelope version + wire.Call - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + wantRequestBody: "\x80\x01\x00\x01" + // strict envelope version + wire.Call + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + encodeThriftString(_irrelevant), wantResponseBody: _response, wantError: `failed to decode "thrift" response body for procedure "MyService::someMethod" of service "service": unexpected EOF`, }, { - msg: "response envelope exception (TApplicationException) error", + desc: "response envelope exception (TApplicationException) error", giveRequestBody: fakeEnveloper(wire.Call), clientOptions: []ClientOption{Enveloped}, - giveResponseBody: []byte("\x80\x01\x00\x03" + // strict envelope version + wire.Exception - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + giveResponseBody: "\x80\x01\x00\x03" + // strict envelope version + wire.Exception + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x08" + _response), // len(string) + string + encodeThriftString(_response), expectCall: true, - wantRequestBody: []byte("\x80\x01\x00\x01" + // strict envelope version + wire.Call - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + wantRequestBody: "\x80\x01\x00\x01" + // strict envelope version + wire.Call + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + encodeThriftString(_irrelevant), wantResponseBody: _response, wantError: "encountered an internal failure: TApplicationException{}", }, { - msg: "unexpected response envelope type", + desc: "unexpected response envelope type", giveRequestBody: fakeEnveloper(wire.Call), - giveResponseBody: []byte("\x80\x01\x00\x01" + // strict envelope version + wire.Reply - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + giveResponseBody: "\x80\x01\x00\x01" + // strict envelope version + wire.Reply + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x08" + _response), // len(string) + string + encodeThriftString(_response), clientOptions: []ClientOption{Enveloped}, expectCall: true, - wantRequestBody: []byte("\x80\x01\x00\x01" + // strict envelope version + wire.Call - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + wantRequestBody: "\x80\x01\x00\x01" + // strict envelope version + wire.Call + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + encodeThriftString(_irrelevant), wantResponseBody: _response, wantError: `failed to decode "thrift" response body for procedure "MyService::someMethod" of service "service": unexpected envelope type: Call`, }, } + // This type aliasing is needed because it's not possible to embed two types + // with the same name without collision. type streamProtocol = stream.Protocol type fakeProtocol struct { protocol.Protocol streamProtocol } - var _ stream.Protocol = &fakeProtocol{} - for _, tt := range tests { - t.Run(tt.msg, func(t *testing.T) { + t.Run(tt.desc, func(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() sp := streamtest.NewMockProtocol(mockCtrl) - if tt.wantRequestBody != nil { + if tt.wantRequestBody != "" { sp.EXPECT().Writer(gomock.Any()). DoAndReturn(func(w io.Writer) stream.Writer { - return binary.Default.Writer(w) - }). - Times(1) + return tbinary.Default.Writer(w) + }) } if tt.wantResponseBody != "" { sp.EXPECT().Reader(gomock.Any()). DoAndReturn(func(r io.Reader) stream.Reader { - return binary.Default.Reader(r) - }). - Times(1) + return tbinary.Default.Reader(r) + }) } ctx, cancel := context.WithTimeout(context.Background(), testtime.Second) @@ -171,10 +172,10 @@ func TestNoWireClientCall(t *testing.T) { Service: "service", Encoding: Encoding, Procedure: "MyService::someMethod", - Body: bytes.NewReader(tt.wantRequestBody), + Body: bytes.NewReader([]byte(tt.wantRequestBody)), }), ).Return(&transport.Response{ - Body: readCloser{bytes.NewReader(tt.giveResponseBody)}, + Body: readCloser{bytes.NewReader([]byte(tt.giveResponseBody))}, }, nil) } @@ -209,24 +210,24 @@ func TestNoWireClientOneway(t *testing.T) { clientOptions []ClientOption expectCall bool - wantRequestBody []byte + wantRequestBody string wantError string }{ { msg: "positive case, without enveloping", giveRequestBody: fakeEnveloper(wire.OneWay), expectCall: true, - wantRequestBody: []byte("\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + wantRequestBody: encodeThriftString(_irrelevant), }, { msg: "positive case, with enveloping", giveRequestBody: fakeEnveloper(wire.OneWay), clientOptions: []ClientOption{Enveloped}, expectCall: true, - wantRequestBody: []byte("\x80\x01\x00\x04" + // strict envelope version + wire.Oneway - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + wantRequestBody: "\x80\x01\x00\x04" + // strict envelope version + wire.Oneway + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + encodeThriftString(_irrelevant), }, { msg: "unexpected request envelope type", @@ -238,10 +239,10 @@ func TestNoWireClientOneway(t *testing.T) { giveRequestBody: fakeEnveloper(wire.OneWay), clientOptions: []ClientOption{Enveloped}, expectCall: true, - wantRequestBody: []byte("\x80\x01\x00\x04" + // strict envelope version + wire.Oneway - "\x00\x00\x00\x0A" + "someMethod" + // len(string) + string + wantRequestBody: "\x80\x01\x00\x04" + // strict envelope version + wire.Oneway + encodeThriftString("someMethod") + "\x00\x00\x00\x01" + // seqID - "\x00\x00\x00\x0A" + _irrelevant), // len(string) + string + encodeThriftString(_irrelevant), wantError: "oneway outbound error", }, } @@ -260,12 +261,11 @@ func TestNoWireClientOneway(t *testing.T) { defer mockCtrl.Finish() sp := streamtest.NewMockProtocol(mockCtrl) - if tt.wantRequestBody != nil { + if tt.wantRequestBody != "" { sp.EXPECT().Writer(gomock.Any()). DoAndReturn(func(w io.Writer) stream.Writer { - return binary.Default.Writer(w) - }). - Times(1) + return tbinary.Default.Writer(w) + }) } ctx, cancel := context.WithTimeout(context.Background(), testtime.Second) @@ -280,7 +280,7 @@ func TestNoWireClientOneway(t *testing.T) { Service: "service", Encoding: Encoding, Procedure: "MyService::someMethod", - Body: bytes.NewReader(tt.wantRequestBody), + Body: bytes.NewReader([]byte(tt.wantRequestBody)), }), ).Return(nil, errors.New("oneway outbound error")) } else { @@ -290,7 +290,7 @@ func TestNoWireClientOneway(t *testing.T) { Service: "service", Encoding: Encoding, Procedure: "MyService::someMethod", - Body: bytes.NewReader(tt.wantRequestBody), + Body: bytes.NewReader([]byte(tt.wantRequestBody)), }), ).Return(&successAck{}, nil) } @@ -318,3 +318,13 @@ func TestNoWireClientOneway(t *testing.T) { }) } } + +// encodeThriftString prefixes the passed in string with an int32 that contains +// the length of the string, compliant to the Thrift protocol. +func encodeThriftString(s string) string { + buf := make([]byte, 4) + bigEndian := binary.BigEndian + bigEndian.PutUint32(buf, uint32(len(s))) + + return string(buf) + s +} diff --git a/encoding/thrift/thriftrw-plugin-yarpc/client.go b/encoding/thrift/thriftrw-plugin-yarpc/client.go index 31552ceab..59b8cbef2 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/client.go @@ -124,14 +124,12 @@ func (c client) <.Name>( ctx = .WithoutHeaders(ctx) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body <$wire>.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/readonlystoreclient/client.go b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/readonlystoreclient/client.go index 427d3c866..3ce7d0f1c 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/readonlystoreclient/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/readonlystoreclient/client.go @@ -74,14 +74,12 @@ func (c client) Integer( args := atomic.ReadOnlyStore_Integer_Helper.Args(_Key) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/storeclient/client.go b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/storeclient/client.go index 998fc5b64..4f567bd0a 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/storeclient/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/storeclient/client.go @@ -87,14 +87,12 @@ func (c client) CompareAndSwap( args := atomic.Store_CompareAndSwap_Helper.Args(_Request) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -127,14 +125,12 @@ func (c client) Increment( args := atomic.Store_Increment_Helper.Args(_Key, _Value) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/baseserviceclient/client.go b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/baseserviceclient/client.go index 5a32d6504..40ae6e5ff 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/baseserviceclient/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/baseserviceclient/client.go @@ -59,14 +59,12 @@ func (c client) Healthy( args := common.BaseService_Healthy_Helper.Args() if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/extendemptyclient/client.go b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/extendemptyclient/client.go index 1f1b2c9e9..1f41e94d3 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/extendemptyclient/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/extendemptyclient/client.go @@ -72,14 +72,12 @@ func (c client) Hello( args := common.ExtendEmpty_Hello_Helper.Args() if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends/nameclient/client.go b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends/nameclient/client.go index 2a8dc0f47..78e989611 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends/nameclient/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends/nameclient/client.go @@ -59,14 +59,12 @@ func (c client) Name( args := extends.Name_Name_Helper.Args() if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/weather/weatherclient/client.go b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/weather/weatherclient/client.go index 1d6097f01..4d9784084 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/weather/weatherclient/client.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/weather/weatherclient/client.go @@ -61,14 +61,12 @@ func (c client) Check( ctx = tchannel.WithoutHeaders(ctx) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/internal/crossdock/thrift/echo/echoclient/client.go b/internal/crossdock/thrift/echo/echoclient/client.go index ffc7deb70..b8c88178d 100644 --- a/internal/crossdock/thrift/echo/echoclient/client.go +++ b/internal/crossdock/thrift/echo/echoclient/client.go @@ -81,14 +81,12 @@ func (c client) Echo( args := echo.Echo_Echo_Helper.Args(_Ping) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/internal/crossdock/thrift/gauntlet/secondserviceclient/client.go b/internal/crossdock/thrift/gauntlet/secondserviceclient/client.go index 71862b861..2e42f18ad 100644 --- a/internal/crossdock/thrift/gauntlet/secondserviceclient/client.go +++ b/internal/crossdock/thrift/gauntlet/secondserviceclient/client.go @@ -85,14 +85,12 @@ func (c client) BlahBlah( args := gauntlet.SecondService_BlahBlah_Helper.Args() if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -115,14 +113,12 @@ func (c client) SecondtestString( args := gauntlet.SecondService_SecondtestString_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/internal/crossdock/thrift/gauntlet/thrifttestclient/client.go b/internal/crossdock/thrift/gauntlet/thrifttestclient/client.go index 94f7ac1b2..3d951b15a 100644 --- a/internal/crossdock/thrift/gauntlet/thrifttestclient/client.go +++ b/internal/crossdock/thrift/gauntlet/thrifttestclient/client.go @@ -206,14 +206,12 @@ func (c client) TestBinary( args := gauntlet.ThriftTest_TestBinary_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -236,14 +234,12 @@ func (c client) TestByte( args := gauntlet.ThriftTest_TestByte_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -266,14 +262,12 @@ func (c client) TestDouble( args := gauntlet.ThriftTest_TestDouble_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -296,14 +290,12 @@ func (c client) TestEnum( args := gauntlet.ThriftTest_TestEnum_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -326,14 +318,12 @@ func (c client) TestException( args := gauntlet.ThriftTest_TestException_Helper.Args(_Arg) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -356,14 +346,12 @@ func (c client) TestI32( args := gauntlet.ThriftTest_TestI32_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -386,14 +374,12 @@ func (c client) TestI64( args := gauntlet.ThriftTest_TestI64_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -416,14 +402,12 @@ func (c client) TestInsanity( args := gauntlet.ThriftTest_TestInsanity_Helper.Args(_Argument) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -446,14 +430,12 @@ func (c client) TestList( args := gauntlet.ThriftTest_TestList_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -476,14 +458,12 @@ func (c client) TestMap( args := gauntlet.ThriftTest_TestMap_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -506,14 +486,12 @@ func (c client) TestMapMap( args := gauntlet.ThriftTest_TestMapMap_Helper.Args(_Hello) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -541,14 +519,12 @@ func (c client) TestMulti( args := gauntlet.ThriftTest_TestMulti_Helper.Args(_Arg0, _Arg1, _Arg2, _Arg3, _Arg4, _Arg5) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -572,14 +548,12 @@ func (c client) TestMultiException( args := gauntlet.ThriftTest_TestMultiException_Helper.Args(_Arg0, _Arg1) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -602,14 +576,12 @@ func (c client) TestNest( args := gauntlet.ThriftTest_TestNest_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -641,14 +613,12 @@ func (c client) TestSet( args := gauntlet.ThriftTest_TestSet_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -671,14 +641,12 @@ func (c client) TestString( args := gauntlet.ThriftTest_TestString_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -701,14 +669,12 @@ func (c client) TestStringMap( args := gauntlet.ThriftTest_TestStringMap_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -731,14 +697,12 @@ func (c client) TestStruct( args := gauntlet.ThriftTest_TestStruct_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -761,14 +725,12 @@ func (c client) TestTypedef( args := gauntlet.ThriftTest_TestTypedef_Helper.Args(_Thing) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -790,14 +752,12 @@ func (c client) TestVoid( args := gauntlet.ThriftTest_TestVoid_Helper.Args() if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/internal/examples/thrift-hello/hello/echo/helloclient/client.go b/internal/examples/thrift-hello/hello/echo/helloclient/client.go index 081943688..d255c51ce 100644 --- a/internal/examples/thrift-hello/hello/echo/helloclient/client.go +++ b/internal/examples/thrift-hello/hello/echo/helloclient/client.go @@ -81,14 +81,12 @@ func (c client) Echo( args := echo.Hello_Echo_Helper.Args(_Echo) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } diff --git a/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueclient/client.go b/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueclient/client.go index b29a9f5c0..93c4df48f 100644 --- a/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueclient/client.go +++ b/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueclient/client.go @@ -88,14 +88,12 @@ func (c client) GetValue( args := kv.KeyValue_GetValue_Helper.Args(_Key) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return } @@ -119,14 +117,12 @@ func (c client) SetValue( args := kv.KeyValue_SetValue_Helper.Args(_Key, _Value) if c.nwc != nil && c.nwc.Enabled() { - err = c.nwc.Call(ctx, args, &result, opts...) - if err != nil { + if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { return } } else { var body wire.Value - body, err = c.c.Call(ctx, args, opts...) - if err != nil { + if body, err = c.c.Call(ctx, args, opts...); err != nil { return }