Documentation
¶
Overview ¶
Package persistence provides the database interface for Flamenco Manager.
SPDX-License-Identifier: GPL-3.0-or-later
Package persistence provides the database interface for Flamenco Manager.
Index ¶
- Constants
- Variables
- func ErrIsDBBusy(err error) bool
- type DB
- func (db *DB) Close() error
- func (db *DB) PeriodicIntegrityCheck(ctx context.Context, period time.Duration, onErrorCallback func())
- func (db *DB) RequestIntegrityCheck()
- func (db *DB) UpstreamBufferDiscard(ctx context.Context, queuedTaskUpdate *TaskUpdate) error
- func (db *DB) UpstreamBufferFrontItem(ctx context.Context) (*TaskUpdate, error)
- func (db *DB) UpstreamBufferQueue(ctx context.Context, taskID string, ...) error
- func (db *DB) UpstreamBufferQueueSize(ctx context.Context) (int, error)
- type GooseLogger
- type LoggingDBConn
- func (ldbc *LoggingDBConn) ExecContext(ctx context.Context, sql string, args ...interface{}) (sql.Result, error)
- func (ldbc *LoggingDBConn) PrepareContext(ctx context.Context, sql string) (*sql.Stmt, error)
- func (ldbc *LoggingDBConn) QueryContext(ctx context.Context, sql string, args ...interface{}) (*sql.Rows, error)
- func (ldbc *LoggingDBConn) QueryRowContext(ctx context.Context, sql string, args ...interface{}) *sql.Row
- type TaskUpdate
Constants ¶
const TestDSN = "file::memory:"
Change this to a filename if you want to run a single test and inspect the resulting database.
Variables ¶
var ErrIntegrity = errors.New("database integrity check failed")
Functions ¶
func ErrIsDBBusy ¶
ErrIsDBBusy returns true when the error is a "database busy" error.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB provides the database interface.
func (*DB) PeriodicIntegrityCheck ¶
func (db *DB) PeriodicIntegrityCheck( ctx context.Context, period time.Duration, onErrorCallback func(), )
PeriodicIntegrityCheck periodically checks the database integrity. This function only returns when the context is done.
func (*DB) RequestIntegrityCheck ¶
func (db *DB) RequestIntegrityCheck()
RequestIntegrityCheck triggers a check of the database persistency.
func (*DB) UpstreamBufferDiscard ¶
func (db *DB) UpstreamBufferDiscard(ctx context.Context, queuedTaskUpdate *TaskUpdate) error
UpstreamBufferDiscard discards the queued task update with the given row ID.
func (*DB) UpstreamBufferFrontItem ¶
func (db *DB) UpstreamBufferFrontItem(ctx context.Context) (*TaskUpdate, error)
UpstreamBufferFrontItem returns the first-queued item. The item remains queued.
func (*DB) UpstreamBufferQueue ¶
func (db *DB) UpstreamBufferQueue(ctx context.Context, taskID string, apiTaskUpdate api.TaskUpdateJSONRequestBody) error
UpstreamBufferQueue queues a task update in the upstrema buffer.
type GooseLogger ¶
type GooseLogger struct{}
func (*GooseLogger) Fatalf ¶
func (gl *GooseLogger) Fatalf(format string, v ...interface{})
func (*GooseLogger) Printf ¶
func (gl *GooseLogger) Printf(format string, v ...interface{})
type LoggingDBConn ¶
type LoggingDBConn struct {
// contains filtered or unexported fields
}
LoggingDBConn wraps a database/sql.DB connection, so that it can be used with sqlc and log all the queries.
func (*LoggingDBConn) ExecContext ¶
func (*LoggingDBConn) PrepareContext ¶
func (*LoggingDBConn) QueryContext ¶
func (*LoggingDBConn) QueryRowContext ¶
type TaskUpdate ¶
type TaskUpdate struct {
sqlc.TaskUpdate
}
TaskUpdate is a queued task update.
func (*TaskUpdate) Unmarshal ¶
func (t *TaskUpdate) Unmarshal() (*api.TaskUpdateJSONRequestBody, error)