-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f69af81
commit 41d3aa7
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package bitcask | ||
|
||
import "git.tcp.direct/tcp.direct/database" | ||
|
||
func init() { | ||
database.Register("bitcask", func(path string) (database.Keeper, error) { | ||
db := OpenDB(path) | ||
err := db.init() | ||
return db, err | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package pogreb | ||
|
||
import "git.tcp.direct/tcp.direct/database" | ||
|
||
func init() { | ||
database.Register("pogreb", func(path string) (database.Keeper, error) { | ||
db := OpenDB(path) | ||
err := db.init() | ||
return db, err | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package database | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
var ( | ||
keepers = make(map[string]KeeperCreator) | ||
regMu = &sync.RWMutex{} | ||
) | ||
|
||
func Register(name string, keeper KeeperCreator) { | ||
regMu.Lock() | ||
keepers[name] = keeper | ||
regMu.Unlock() | ||
} | ||
|
||
func Get(name string) KeeperCreator { | ||
regMu.RLock() | ||
k := keepers[name] | ||
regMu.RUnlock() | ||
return k | ||
} | ||
|
||
func All() map[string]KeeperCreator { | ||
regMu.RLock() | ||
ks := keepers | ||
regMu.RUnlock() | ||
return ks | ||
} |