mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-20 01:10:44 +00:00
Use msgpack instead of gob; Added data persistance for badger data store
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
package badgerdatastore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
"github.com/pikami/cosmium/internal/datastore"
|
||||
"github.com/pikami/cosmium/internal/logger"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
)
|
||||
|
||||
type BadgerDocumentIterator struct {
|
||||
@@ -43,7 +41,7 @@ func (i *BadgerDocumentIterator) Next() (datastore.Document, datastore.DataStore
|
||||
}
|
||||
|
||||
current := &datastore.Document{}
|
||||
err = gob.NewDecoder(bytes.NewReader(val)).Decode(current)
|
||||
err = msgpack.Unmarshal(val, ¤t)
|
||||
if err != nil {
|
||||
logger.ErrorLn("Error while decoding value:", err)
|
||||
return datastore.Document{}, datastore.Unknown
|
||||
|
||||
Reference in New Issue
Block a user