biiiiig refactor

This commit is contained in:
tsmethurst 2021-05-04 17:50:00 +02:00
commit 1ec22fe52c
151 changed files with 3231 additions and 4556 deletions

View file

@ -20,17 +20,13 @@ package db
import (
"context"
"fmt"
"net"
"strings"
"github.com/go-fed/activity/pub"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
const dbTypePostgres string = "POSTGRES"
const DBTypePostgres string = "POSTGRES"
// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query.
type ErrNoEntries struct{}
@ -283,14 +279,3 @@ type DB interface {
// if they exist in the db and conveniently returning them if they do.
EmojiStringsToEmojis(emojis []string, originAccountID string, statusID string) ([]*gtsmodel.Emoji, error)
}
// New returns a new database service that satisfies the DB interface and, by extension,
// the go-fed database interface described here: https://github.com/go-fed/activity/blob/master/pub/database.go
func New(ctx context.Context, c *config.Config, log *logrus.Logger) (DB, error) {
switch strings.ToUpper(c.DBConfig.Type) {
case dbTypePostgres:
return newPostgresService(ctx, c, log.WithField("service", "db"))
default:
return nil, fmt.Errorf("database type %s not supported", c.DBConfig.Type)
}
}