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

Upgrade to etcd/bbolt #22

Merged
merged 4 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions bolt_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package raftboltdb
import (
"errors"

"github.com/boltdb/bolt"
"go.etcd.io/bbolt"
"github.com/hashicorp/raft"
)

Expand All @@ -27,7 +27,7 @@ var (
// a LogStore and StableStore.
type BoltStore struct {
// conn is the underlying handle to the db.
conn *bolt.DB
conn *bbolt.DB

// The path to the Bolt database file
path string
Expand All @@ -40,7 +40,7 @@ type Options struct {

// BoltOptions contains any specific BoltDB options you might
// want to specify [e.g. open timeout]
BoltOptions *bolt.Options
BoltOptions *bbolt.Options

// NoSync causes the database to skip fsync calls after each
// write to the log. This is unsafe, so it should be used
Expand All @@ -63,7 +63,7 @@ func NewBoltStore(path string) (*BoltStore, error) {
// New uses the supplied options to open the BoltDB and prepare it for use as a raft backend.
func New(options Options) (*BoltStore, error) {
// Try to connect
handle, err := bolt.Open(options.Path, dbFileMode, options.BoltOptions)
handle, err := bbolt.Open(options.Path, dbFileMode, options.BoltOptions)
if err != nil {
return nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions bolt_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/boltdb/bolt"
"go.etcd.io/bbolt"
"github.com/hashicorp/raft"
)

Expand Down Expand Up @@ -54,7 +54,7 @@ func TestBoltOptionsTimeout(t *testing.T) {
defer os.Remove(fh.Name())
options := Options{
Path: fh.Name(),
BoltOptions: &bolt.Options{
BoltOptions: &bbolt.Options{
Timeout: time.Second / 10,
},
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestBoltOptionsReadOnly(t *testing.T) {
store.Close()
options := Options{
Path: fh.Name(),
BoltOptions: &bolt.Options{
BoltOptions: &bbolt.Options{
Timeout: time.Second / 10,
ReadOnly: true,
},
Expand All @@ -123,8 +123,8 @@ func TestBoltOptionsReadOnly(t *testing.T) {
}
// Attempt to store the log, should fail on a read-only store
err = roStore.StoreLog(log)
if err != bolt.ErrDatabaseReadOnly {
t.Errorf("expecting error %v, but got %v", bolt.ErrDatabaseReadOnly, err)
if err != bbolt.ErrDatabaseReadOnly {
t.Errorf("expecting error %v, but got %v", bbolt.ErrDatabaseReadOnly, err)
}
}

Expand Down Expand Up @@ -156,18 +156,18 @@ func TestNewBoltStore(t *testing.T) {
}

// Ensure our tables were created
db, err := bolt.Open(fh.Name(), dbFileMode, nil)
db, err := bbolt.Open(fh.Name(), dbFileMode, nil)
if err != nil {
t.Fatalf("err: %s", err)
}
tx, err := db.Begin(true)
if err != nil {
t.Fatalf("err: %s", err)
}
if _, err := tx.CreateBucket([]byte(dbLogs)); err != bolt.ErrBucketExists {
if _, err := tx.CreateBucket([]byte(dbLogs)); err != bbolt.ErrBucketExists {
t.Fatalf("bad: %v", err)
}
if _, err := tx.CreateBucket([]byte(dbConf)); err != bolt.ErrBucketExists {
if _, err := tx.CreateBucket([]byte(dbConf)); err != bbolt.ErrBucketExists {
t.Fatalf("bad: %v", err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/hashicorp/raft-boltdb
go 1.12

require (
github.com/boltdb/bolt v1.3.1
// github.com/boltdb/bolt v1.3.1
github.com/hashicorp/go-msgpack v0.5.5
github.com/hashicorp/raft v1.1.0
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
go.etcd.io/bbolt v1.3.5
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cjyFjutgw/Vhan2zLy/A=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=