Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

downgrade thrift to backend compatible version #1306

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,6 @@ retract (
v0.3.0 // Published accidentally
v0.2.0 // Published accidentally
)

// Cadence backend depends on older version of thrift, so we cannot use the latest version.
replace github.com/apache/thrift => github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 h1:Fv9bK1Q+ly/ROk4aJsVMeuIwPel4bEnD8EPiI91nZMg=
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY=
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
18 changes: 7 additions & 11 deletions internal/common/thrift_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

// TSerialize is used to serialize thrift TStruct to []byte
func TSerialize(ctx context.Context, t thrift.TStruct) (b []byte, err error) {
return thrift.NewTSerializer().Write(ctx, t)
return thrift.NewTSerializer().Write(t)
}

// TListSerialize is used to serialize list of thrift TStruct to []byte
Expand All @@ -43,21 +43,19 @@ func TListSerialize(ts []thrift.TStruct) (b []byte, err error) {

// NOTE: we don't write any markers as thrift by design being a streaming protocol doesn't
// recommend writing length.

// TODO populate context from argument
ctx := context.Background()

for _, v := range ts {
if e := v.Write(ctx, t.Protocol); e != nil {
if e := v.Write(t.Protocol); e != nil {
err = thrift.PrependError("error writing TStruct: ", e)
return
}
}

if err = t.Protocol.Flush(ctx); err != nil {
if err = t.Protocol.Flush(); err != nil {
return
}

if err = t.Transport.Flush(ctx); err != nil {
if err = t.Transport.Flush(); err != nil {
return
}

Expand All @@ -67,7 +65,7 @@ func TListSerialize(ts []thrift.TStruct) (b []byte, err error) {

// TDeserialize is used to deserialize []byte to thrift TStruct
func TDeserialize(ctx context.Context, t thrift.TStruct, b []byte) (err error) {
return thrift.NewTDeserializer().Read(ctx, t, b)
return thrift.NewTDeserializer().Read(t, b)
}

// TListDeserialize is used to deserialize []byte to list of thrift TStruct
Expand All @@ -78,10 +76,8 @@ func TListDeserialize(ts []thrift.TStruct, b []byte) (err error) {
return
}

// TODO populate context from argument
ctx := context.Background()
for i := 0; i < len(ts); i++ {
if e := ts[i].Read(ctx, t.Protocol); e != nil {
if e := ts[i].Read(t.Protocol); e != nil {
err = thrift.PrependError("error reading TStruct: ", e)
return
}
Expand Down