Skip to content

Commit

Permalink
Change constructor name for boltdb
Browse files Browse the repository at this point in the history
Co-authored-by: Antonio Navarro <antnavper@gmail.com>
  • Loading branch information
thehowl and ajnavarro committed Feb 29, 2024
1 parent b14e4ce commit a7ff77f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions tm2/pkg/db/boltdb/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var bucket = []byte("tm")

func init() {
db.InternalRegisterDBCreator(db.BoltDBBackend, func(name, dir string) (db.DB, error) {
return NewBoltDB(name, dir)
return New(name, dir)
}, false)
}

Expand All @@ -32,14 +32,14 @@ type BoltDB struct {
db *bbolt.DB
}

// NewBoltDB returns a BoltDB with default options.
func NewBoltDB(name, dir string) (db.DB, error) {
return NewBoltDBWithOpts(name, dir, bbolt.DefaultOptions)
// New returns a BoltDB with default options.
func New(name, dir string) (db.DB, error) {
return NewWithOptions(name, dir, bbolt.DefaultOptions)
}

// NewBoltDBWithOpts allows you to supply *bbolt.Options. ReadOnly: true is not
// supported because NewBoltDBWithOpts creates a global bucket.
func NewBoltDBWithOpts(name string, dir string, opts *bbolt.Options) (db.DB, error) {
// NewWithOptions allows you to supply *bbolt.Options. ReadOnly: true is not
// supported because NewWithOptions creates a global bucket.
func NewWithOptions(name string, dir string, opts *bbolt.Options) (db.DB, error) {
if opts.ReadOnly {
return nil, errors.New("ReadOnly: true is not supported")
}
Expand Down
6 changes: 3 additions & 3 deletions tm2/pkg/db/boltdb/boltdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/stretchr/testify/require"
)

func TestBoltDBNewBoltDB(t *testing.T) {
func TestBoltDBNew(t *testing.T) {
t.Parallel()

name := fmt.Sprintf("test_%x", internal.RandStr(12))

db, err := NewBoltDB(name, t.TempDir())
db, err := New(name, t.TempDir())
require.NoError(t, err)
db.Close()
}
Expand All @@ -24,7 +24,7 @@ func BenchmarkBoltDBRandomReadsWrites(b *testing.B) {
}

name := fmt.Sprintf("test_%x", internal.RandStr(12))
db, err := NewBoltDB(name, b.TempDir())
db, err := New(name, b.TempDir())
if err != nil {
b.Fatal(err)
}
Expand Down

0 comments on commit a7ff77f

Please sign in to comment.