diff options
Diffstat (limited to 'svc/db.go')
-rw-r--r-- | svc/db.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/svc/db.go b/svc/db.go index 0bb96ee..e0c2690 100644 --- a/svc/db.go +++ b/svc/db.go @@ -11,6 +11,11 @@ import ( "github.com/syndtr/goleveldb/leveldb" ) +type dbase interface { + push() error + pull() +} + type dbLevel struct { db *leveldb.DB } @@ -19,9 +24,8 @@ type dbSqlite struct { db *sql.DB } -type dbase interface { - push() error - pull() +type dbPostgres struct { + db *sql.DB } // Pull DB data into cache, if available. @@ -41,6 +45,10 @@ func initDatabase() { var lite *sql.DB db = &dbSqlite{db: lite} + case "postgres": + var pg *sql.DB + db = &dbPostgres{db: pg} + } confObj.Mu.RUnlock() @@ -65,15 +73,16 @@ func dbTimer() bool { // database for safe keeping. func pushDB() error { db := <-dbChan + err := db.push() dbChan <- db - return db.push() + return err } func pullDB() { db := <-dbChan - dbChan <- db db.pull() + dbChan <- db } func (lvl dbLevel) push() error { @@ -176,3 +185,12 @@ func (lite dbSqlite) push() error { func (lite dbSqlite) pull() { } + +func (pg dbPostgres) push() error { + + return nil +} + +func (pg dbPostgres) pull() { + +} |