From 99eb62906b862c6530498ca4e1e3343e9bc1560b Mon Sep 17 00:00:00 2001 From: Wit Riewrangboonya Date: Tue, 24 Aug 2021 23:28:05 -0700 Subject: [PATCH] unuse deprecated fields --- encoding/thrift/envelope_test.go | 4 ++-- encoding/thrift/inbound.go | 9 ++++++--- encoding/thrift/inbound_test.go | 1 + encoding/thrift/outbound.go | 3 ++- encoding/thrift/register.go | 3 ++- encoding/thrift/thriftrw-plugin-yarpc/roundtrip_test.go | 4 ++-- serialize/serialize.go | 6 +++--- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/encoding/thrift/envelope_test.go b/encoding/thrift/envelope_test.go index 136a65a19..72b5130af 100644 --- a/encoding/thrift/envelope_test.go +++ b/encoding/thrift/envelope_test.go @@ -30,7 +30,7 @@ import ( "time" "github.com/stretchr/testify/assert" - "go.uber.org/thriftrw/protocol" + "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/wire" ) @@ -63,7 +63,7 @@ func TestDisableEnveloperEncode(t *testing.T) { generate(&e.SeqID, rand) var buffer bytes.Buffer - proto := disableEnvelopingProtocol{protocol.Binary, wire.Reply} + proto := disableEnvelopingProtocol{binary.Default, wire.Reply} if !assert.NoError(t, proto.EncodeEnveloped(e, &buffer)) { continue } diff --git a/encoding/thrift/inbound.go b/encoding/thrift/inbound.go index 7d71e46ec..b777259ec 100644 --- a/encoding/thrift/inbound.go +++ b/encoding/thrift/inbound.go @@ -26,6 +26,7 @@ import ( "io" "go.uber.org/thriftrw/protocol" + "go.uber.org/thriftrw/protocol/envelope" "go.uber.org/thriftrw/wire" encodingapi "go.uber.org/yarpc/api/encoding" "go.uber.org/yarpc/api/transport" @@ -139,7 +140,7 @@ func decodeRequest( wire.Value, // how to encode the response, with the enveloping // strategy corresponding to the request. It is not used for oneway handlers. - protocol.Responder, + envelope.Responder, error, ) { if err := errors.ExpectEncodings(treq, Encoding); err != nil { @@ -166,7 +167,7 @@ func decodeEnvelopedRequest( reqEnvelopeType wire.EnvelopeType, proto protocol.Protocol, reader io.ReaderAt, -) (wire.Value, protocol.Responder, error) { +) (wire.Value, envelope.Responder, error) { var envelope wire.Envelope envelope, err := proto.DecodeEnveloped(reader) if err != nil { @@ -177,6 +178,7 @@ func decodeEnvelopedRequest( return wire.Value{}, nil, err } reqValue := envelope.Value + //lint:ignore SA1019 explicit use for known enveloping responder := protocol.EnvelopeV1Responder{Name: envelope.Name, SeqID: envelope.SeqID} return reqValue, responder, nil } @@ -184,11 +186,12 @@ func decodeEnvelopedRequest( func decodeUnenvelopedRequest( proto protocol.Protocol, reader io.ReaderAt, -) (wire.Value, protocol.Responder, error) { +) (wire.Value, envelope.Responder, error) { reqValue, err := proto.Decode(reader, wire.TStruct) if err != nil { return wire.Value{}, nil, err } + //lint:ignore SA1019 explicit use for known enveloping responder := protocol.NoEnvelopeResponder return reqValue, responder, err } diff --git a/encoding/thrift/inbound_test.go b/encoding/thrift/inbound_test.go index 04ec7cd44..be165c23a 100644 --- a/encoding/thrift/inbound_test.go +++ b/encoding/thrift/inbound_test.go @@ -18,6 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +//lint:file-ignore SA1019 'mock' usage package thrift import ( diff --git a/encoding/thrift/outbound.go b/encoding/thrift/outbound.go index 61a01c12a..6ec427120 100644 --- a/encoding/thrift/outbound.go +++ b/encoding/thrift/outbound.go @@ -28,6 +28,7 @@ import ( "go.uber.org/thriftrw/envelope" "go.uber.org/thriftrw/protocol" + "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/wire" "go.uber.org/yarpc" encodingapi "go.uber.org/yarpc/api/encoding" @@ -80,7 +81,7 @@ func New(c Config, opts ...ClientOption) Client { opt.applyClientOption(&cc) } - p := protocol.Binary + var p protocol.Protocol = binary.Default if cc.Protocol != nil { p = cc.Protocol } diff --git a/encoding/thrift/register.go b/encoding/thrift/register.go index 051fca526..40fe814bb 100644 --- a/encoding/thrift/register.go +++ b/encoding/thrift/register.go @@ -25,6 +25,7 @@ import ( "fmt" "go.uber.org/thriftrw/protocol" + "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/thriftreflect" "go.uber.org/thriftrw/wire" "go.uber.org/yarpc/api/transport" @@ -87,7 +88,7 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure { opt.applyRegisterOption(&rc) } - proto := protocol.Binary + var proto protocol.Protocol = binary.Default if rc.Protocol != nil { proto = rc.Protocol } diff --git a/encoding/thrift/thriftrw-plugin-yarpc/roundtrip_test.go b/encoding/thrift/thriftrw-plugin-yarpc/roundtrip_test.go index 8c2479f3e..2aeadc74f 100644 --- a/encoding/thrift/thriftrw-plugin-yarpc/roundtrip_test.go +++ b/encoding/thrift/thriftrw-plugin-yarpc/roundtrip_test.go @@ -30,7 +30,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/thriftrw/protocol" + "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/ptr" "go.uber.org/yarpc" "go.uber.org/yarpc/api/transport" @@ -389,7 +389,7 @@ func TestFromWireInvalidArg(t *testing.T) { require.NoError(t, err, "unable to covert type to wire.Value") var body bytes.Buffer - err = (protocol.Binary).Encode(val, &body) + err = binary.Default.Encode(val, &body) require.NoError(t, err, "could not marshal message to bytes") err = procedure.HandlerSpec.Unary().Handle(context.Background(), &transport.Request{ diff --git a/serialize/serialize.go b/serialize/serialize.go index 6d8161f83..e5623aa94 100644 --- a/serialize/serialize.go +++ b/serialize/serialize.go @@ -27,7 +27,7 @@ import ( "io/ioutil" "github.com/opentracing/opentracing-go" - "go.uber.org/thriftrw/protocol" + "go.uber.org/thriftrw/protocol/binary" "go.uber.org/thriftrw/wire" "go.uber.org/yarpc/api/transport" "go.uber.org/yarpc/serialize/internal" @@ -74,7 +74,7 @@ func ToBytes(tracer opentracing.Tracer, spanContext opentracing.SpanContext, req if err := writer.WriteByte(version); err != nil { return nil, err } - err = protocol.Binary.Encode(wireValue, &writer) + err = binary.Default.Encode(wireValue, &writer) return writer.Bytes(), err } @@ -93,7 +93,7 @@ func FromBytes(tracer opentracing.Tracer, request []byte) (opentracing.SpanConte } reader := bytes.NewReader(request[1:]) - wireValue, err := protocol.Binary.Decode(reader, wire.TStruct) + wireValue, err := binary.Default.Decode(reader, wire.TStruct) if err != nil { return nil, nil, err }