diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-06-11 00:37:26 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-06-11 04:54:47 -0400 |
commit | 40357b7bc536665812adc51998ecc00d725f2aaf (patch) | |
tree | a56853d9a6cc88a302f1f1b4ffa2fb4c2ece9e30 /svc/sqlite.go | |
parent | f02cb61da3370e113796dad83eaedcd577f0278a (diff) | |
download | getwtxt-40357b7bc536665812adc51998ecc00d725f2aaf.tar.gz |
dbSqlite.Push() now updating confObj.LastPush; dbSqlite.Push() and dbSqlite.Pull() now expecting pointer receiver only
Diffstat (limited to 'svc/sqlite.go')
-rw-r--r-- | svc/sqlite.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/svc/sqlite.go b/svc/sqlite.go index fe9622c..40a7ff2 100644 --- a/svc/sqlite.go +++ b/svc/sqlite.go @@ -42,10 +42,13 @@ func initSqlite() *dbSqlite { } } -func (lite dbSqlite) push() error { - err := lite.db.Ping() - if err != nil { - return err +func (lite *dbSqlite) push() error { + confObj.Mu.Lock() + confObj.LastPush = time.Now() + confObj.Mu.Unlock() + + if err := lite.db.Ping(); err != nil { + lite = initSqlite() } tx, err := lite.db.Begin() @@ -90,7 +93,7 @@ func (lite dbSqlite) push() error { return nil } -func (lite dbSqlite) pull() { +func (lite *dbSqlite) pull() { errLog("Error pinging sqlite DB: ", lite.db.Ping()) rows, err := lite.pullStmt.Query() |