Skip to content

Commit

Permalink
Change msgpack/codes to msgpack/msgpcode
Browse files Browse the repository at this point in the history
The msgpack library made a breaking change to its API, renaming the
msgpack/codes to msgpakc/msgpcodes and removed the msgpcodes.Code type
(converted it to a plain byte).

This commit fixes the the relevant changes, and updates and cleans the go.{mod,sum}
files.
  • Loading branch information
kenshaw authored and asdine committed Jan 26, 2021
1 parent b013422 commit 56d6e0e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
18 changes: 9 additions & 9 deletions document/encoding/msgpack/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/genjidb/genji/document"
"github.com/genjidb/genji/document/encoding"
"github.com/vmihailenco/msgpack/v5"
"github.com/vmihailenco/msgpack/v5/codes"
"github.com/vmihailenco/msgpack/v5/msgpcode"
)

// A Codec is a MessagePack implementation of an encoding.Codec.
Expand Down Expand Up @@ -161,7 +161,7 @@ func (d *Decoder) DecodeValue() (v document.Value, err error) {
}

// decode array
if (codes.IsFixedArray(c)) || (c == codes.Array16) || (c == codes.Array32) {
if (msgpcode.IsFixedArray(c)) || (c == msgpcode.Array16) || (c == msgpcode.Array32) {
var a document.Array
a, err = d.DecodeArray()
if err != nil {
Expand All @@ -173,7 +173,7 @@ func (d *Decoder) DecodeValue() (v document.Value, err error) {
}

// decode document
if (codes.IsFixedMap(c)) || (c == codes.Map16) || (c == codes.Map32) {
if (msgpcode.IsFixedMap(c)) || (c == msgpcode.Map16) || (c == msgpcode.Map32) {
var doc document.Document
doc, err = d.DecodeDocument()
if err != nil {
Expand All @@ -185,7 +185,7 @@ func (d *Decoder) DecodeValue() (v document.Value, err error) {
}

// decode string
if codes.IsString(c) {
if msgpcode.IsString(c) {
var s string
s, err = d.dec.DecodeString()
if err != nil {
Expand All @@ -197,35 +197,35 @@ func (d *Decoder) DecodeValue() (v document.Value, err error) {

// decode the rest
switch c {
case codes.Nil:
case msgpcode.Nil:
err = d.dec.DecodeNil()
if err != nil {
return
}
v.Type = document.NullValue
return
case codes.Bin8, codes.Bin16, codes.Bin32:
case msgpcode.Bin8, msgpcode.Bin16, msgpcode.Bin32:
v.V, err = d.dec.DecodeBytes()
if err != nil {
return
}
v.Type = document.BlobValue
return
case codes.True, codes.False:
case msgpcode.True, msgpcode.False:
v.V, err = d.dec.DecodeBool()
if err != nil {
return
}
v.Type = document.BoolValue
return
case codes.Int8, codes.Int16, codes.Int32, codes.Int64, codes.Uint8, codes.Uint16, codes.Uint32, codes.Uint64:
case msgpcode.Int8, msgpcode.Int16, msgpcode.Int32, msgpcode.Int64, msgpcode.Uint8, msgpcode.Uint16, msgpcode.Uint32, msgpcode.Uint64:
v.V, err = d.dec.DecodeInt64()
if err != nil {
return
}
v.Type = document.IntegerValue
return
case codes.Double:
case msgpcode.Double:
v.V, err = d.dec.DecodeFloat64()
if err != nil {
return
Expand Down
12 changes: 6 additions & 6 deletions document/encoding/msgpack/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/genjidb/genji/document"
"github.com/vmihailenco/msgpack/v5"
"github.com/vmihailenco/msgpack/v5/codes"
"github.com/vmihailenco/msgpack/v5/msgpcode"
)

// An EncodedDocument implements the document.Document
Expand All @@ -20,13 +20,13 @@ type EncodedDocument []byte
// based on c.
// It is originally copied from https://github.com/vmihailenco/msgpack/blob/e7759683b74a27e455669b525427cfd9aec0790e/decode_string.go#L10:19
// then adapted to our needs.
func bytesLen(c codes.Code, dec *msgpack.Decoder) (int, error) {
if c == codes.Nil {
func bytesLen(c byte, dec *msgpack.Decoder) (int, error) {
if c == msgpcode.Nil {
return -1, nil
}

if codes.IsFixedString(c) {
return int(c & codes.FixedStrMask), nil
if msgpcode.IsFixedString(c) {
return int(c & msgpcode.FixedStrMask), nil
}

return 0, fmt.Errorf("msgpack: invalid code=%x decoding bytes length", c)
Expand All @@ -46,7 +46,7 @@ func (e EncodedDocument) GetByField(field string) (v document.Value, err error)

buf := make([]byte, 32)

var c codes.Code
var c byte
var n int
for i := 0; i < l; i++ {
// this loop does basically two things:
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ module github.com/genjidb/genji
go 1.15

require (
github.com/buger/jsonparser v1.0.0
github.com/buger/jsonparser v1.1.1
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/btree v1.0.0
github.com/kr/pretty v0.1.0 // indirect
github.com/stretchr/testify v1.6.1
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1
github.com/vmihailenco/msgpack/v5 v5.1.4
go.etcd.io/bbolt v1.3.5
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)
33 changes: 8 additions & 25 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
github.com/buger/jsonparser v1.0.0 h1:etJTGF5ESxjI0Ic2UaLQs2LQQpa8G9ykQScukbh4L8A=
github.com/buger/jsonparser v1.0.0/go.mod h1:tgcrVJ81GPSF0mz+0nu1Xaz0fazGPrmmJfJtxjbHhUQ=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand All @@ -18,33 +14,20 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1 h1:d71/KA0LhvkrJ/Ok+Wx9qK7bU8meKA1Hk0jpVI5kJjk=
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1/go.mod h1:xlngVLeyQ/Qi05oQxhQ+oTuqa03RjMwMfk/7/TCs+QI=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmihailenco/msgpack/v5 v5.1.4 h1:6K44/cU6dMNGkVTGGuu7ef2NdSRFMhAFGGLfE3cqtHM=
github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI=
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 56d6e0e

Please sign in to comment.