Database dialects, proper database shutdown, pagination in configuration.
Added possibility to use different database (storage) backends. Currently supported: flatfiles and mysql. Fixes #2. Added database shutdown call. This call will properly shutdown database connections (in case of RDBMS) or flush pastes index cache on disk (in case of flatfiles). De-hardcoded pagination count. Fixes #12.
This commit is contained in:
@@ -25,13 +25,23 @@
|
||||
package databaseinterface
|
||||
|
||||
import (
|
||||
// other
|
||||
"github.com/jmoiron/sqlx"
|
||||
// stdlib
|
||||
"database/sql"
|
||||
|
||||
// local
|
||||
"github.com/pztrn/fastpastebin/database/dialects/interface"
|
||||
"github.com/pztrn/fastpastebin/pastes/model"
|
||||
)
|
||||
|
||||
// Interface represents database interface which is available to all
|
||||
// parts of application and registers with context.Context.
|
||||
type Interface interface {
|
||||
GetDatabaseConnection() *sqlx.DB
|
||||
GetDatabaseConnection() *sql.DB
|
||||
GetPaste(pasteID int) (*pastesmodel.Paste, error)
|
||||
GetPagedPastes(page int) ([]pastesmodel.Paste, error)
|
||||
GetPastesPages() int
|
||||
Initialize()
|
||||
RegisterDialect(dialectinterface.Interface)
|
||||
SavePaste(p *pastesmodel.Paste) (int64, error)
|
||||
Shutdown()
|
||||
}
|
||||
|
Reference in New Issue
Block a user