Skip to content

Commit

Permalink
unuse deprecated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
witriew committed Aug 27, 2021
1 parent 8106b8e commit 97c57f6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions encoding/thrift/envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 6 additions & 3 deletions encoding/thrift/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -177,18 +178,20 @@ 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
}

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
}
Expand Down
1 change: 1 addition & 0 deletions encoding/thrift/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion encoding/thrift/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion encoding/thrift/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions encoding/thrift/thriftrw-plugin-yarpc/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 3 additions & 3 deletions serialize/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down

0 comments on commit 97c57f6

Please sign in to comment.