diff options
author | 2021-08-29 15:41:41 +0100 | |
---|---|---|
committer | 2021-08-29 16:41:41 +0200 | |
commit | ed462245730bd7832019bd43e0bc1c9d1c055e8e (patch) | |
tree | 1caad78ea6aabf5ea93c93a8ade97176b4889500 /internal/db/bundb/session.go | |
parent | Mention fixup (#167) (diff) | |
download | gotosocial-ed462245730bd7832019bd43e0bc1c9d1c055e8e.tar.xz |
Add SQLite support, fix un-thread-safe DB caches, small performance f… (#172)
* Add SQLite support, fix un-thread-safe DB caches, small performance fixes
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
* add SQLite licenses to README
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
* appease the linter, and fix my dumbass-ery
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
* make requested changes
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
* add back comment
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
Diffstat (limited to 'internal/db/bundb/session.go')
-rw-r--r-- | internal/db/bundb/session.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/internal/db/bundb/session.go b/internal/db/bundb/session.go index 55efd21d4..c8b09ec86 100644 --- a/internal/db/bundb/session.go +++ b/internal/db/bundb/session.go @@ -23,22 +23,19 @@ import ( "crypto/rand" "errors" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" - "github.com/uptrace/bun" ) type sessionDB struct { config *config.Config - conn *bun.DB - log *logrus.Logger + conn *DBConn } func (s *sessionDB) GetSession(ctx context.Context) (*gtsmodel.RouterSession, db.Error) { - rss := []*gtsmodel.RouterSession{} + rss := make([]*gtsmodel.RouterSession, 0, 1) _, err := s.conn. NewSelect(). @@ -47,7 +44,7 @@ func (s *sessionDB) GetSession(ctx context.Context) (*gtsmodel.RouterSession, db Order("id DESC"). Exec(ctx) if err != nil { - return nil, processErrorResponse(err) + return nil, s.conn.ProcessError(err) } if len(rss) <= 0 { @@ -92,8 +89,8 @@ func (s *sessionDB) createSession(ctx context.Context) (*gtsmodel.RouterSession, Model(rs) _, err = q.Exec(ctx) - - err = processErrorResponse(err) - - return rs, err + if err != nil { + return nil, s.conn.ProcessError(err) + } + return rs, nil } |