Browse Source

DbBackend -> DBBackend

pull/1842/head
Ethan Buchman 7 years ago
parent
commit
1b5176003a
3 changed files with 11 additions and 11 deletions
  1. +1
    -1
      db/backend_test.go
  2. +1
    -1
      db/common_test.go
  3. +9
    -9
      db/db.go

+ 1
- 1
db/backend_test.go View File

@ -15,7 +15,7 @@ func cleanupDBDir(dir, name string) {
os.RemoveAll(filepath.Join(dir, name) + ".db") os.RemoveAll(filepath.Join(dir, name) + ".db")
} }
func testBackendGetSetDelete(t *testing.T, backend DbBackendType) {
func testBackendGetSetDelete(t *testing.T, backend DBBackendType) {
// Default // Default
dir, dirname := cmn.Tempdir(fmt.Sprintf("test_backend_%s_", backend)) dir, dirname := cmn.Tempdir(fmt.Sprintf("test_backend_%s_", backend))
defer dir.Close() defer dir.Close()


+ 1
- 1
db/common_test.go View File

@ -45,7 +45,7 @@ func checkValuePanics(t *testing.T, itr Iterator) {
assert.Panics(t, func() { itr.Key() }, "checkValuePanics expected panic but didn't") assert.Panics(t, func() { itr.Key() }, "checkValuePanics expected panic but didn't")
} }
func newTempDB(t *testing.T, backend DbBackendType) (db DB) {
func newTempDB(t *testing.T, backend DBBackendType) (db DB) {
dir, dirname := cmn.Tempdir("test_go_iterator") dir, dirname := cmn.Tempdir("test_go_iterator")
db = NewDB("testdb", backend, dirname) db = NewDB("testdb", backend, dirname)
dir.Close() dir.Close()


+ 9
- 9
db/db.go View File

@ -5,21 +5,21 @@ import "fmt"
//---------------------------------------- //----------------------------------------
// Main entry // Main entry
type DbBackendType string
type DBBackendType string
const ( const (
LevelDBBackend DbBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc
CLevelDBBackend DbBackendType = "cleveldb"
GoLevelDBBackend DbBackendType = "goleveldb"
MemDBBackend DbBackendType = "memdb"
FSDBBackend DbBackendType = "fsdb" // using the filesystem naively
LevelDBBackend DBBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc
CLevelDBBackend DBBackendType = "cleveldb"
GoLevelDBBackend DBBackendType = "goleveldb"
MemDBBackend DBBackendType = "memdb"
FSDBBackend DBBackendType = "fsdb" // using the filesystem naively
) )
type dbCreator func(name string, dir string) (DB, error) type dbCreator func(name string, dir string) (DB, error)
var backends = map[DbBackendType]dbCreator{}
var backends = map[DBBackendType]dbCreator{}
func registerDBCreator(backend DbBackendType, creator dbCreator, force bool) {
func registerDBCreator(backend DBBackendType, creator dbCreator, force bool) {
_, ok := backends[backend] _, ok := backends[backend]
if !force && ok { if !force && ok {
return return
@ -27,7 +27,7 @@ func registerDBCreator(backend DbBackendType, creator dbCreator, force bool) {
backends[backend] = creator backends[backend] = creator
} }
func NewDB(name string, backend DbBackendType, dir string) DB {
func NewDB(name string, backend DBBackendType, dir string) DB {
db, err := backends[backend](name, dir) db, err := backends[backend](name, dir)
if err != nil { if err != nil {
panic(fmt.Sprintf("Error initializing DB: %v", err)) panic(fmt.Sprintf("Error initializing DB: %v", err))


Loading…
Cancel
Save