persistence

package
v0.0.0-...-dfed899 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

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

View Source
const TestDSN = "file::memory:"

Change this to a filename if you want to run a single test and inspect the resulting database.

Variables

View Source
var ErrIntegrity = errors.New("database integrity check failed")

Functions

func ErrIsDBBusy

func ErrIsDBBusy(err error) bool

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 OpenDB

func OpenDB(ctx context.Context, dsn string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

Close closes the connection to the database.

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.

func (*DB) UpstreamBufferQueueSize

func (db *DB) UpstreamBufferQueueSize(ctx context.Context) (int, error)

UpstreamBufferQueueSize returns how many task updates are queued in the upstream 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 (ldbc *LoggingDBConn) ExecContext(ctx context.Context, sql string, args ...interface{}) (sql.Result, error)

func (*LoggingDBConn) PrepareContext

func (ldbc *LoggingDBConn) PrepareContext(ctx context.Context, sql string) (*sql.Stmt, error)

func (*LoggingDBConn) QueryContext

func (ldbc *LoggingDBConn) QueryContext(ctx context.Context, sql string, args ...interface{}) (*sql.Rows, error)

func (*LoggingDBConn) QueryRowContext

func (ldbc *LoggingDBConn) QueryRowContext(ctx context.Context, sql string, args ...interface{}) *sql.Row

type TaskUpdate

type TaskUpdate struct {
	sqlc.TaskUpdate
}

TaskUpdate is a queued task update.

func (*TaskUpdate) Unmarshal

func (t *TaskUpdate) Unmarshal() (*api.TaskUpdateJSONRequestBody, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL