Documentation
¶
Overview ¶
Package sqlite is the default queue driver, sharing the filex DB file with the metadata store. It uses BEGIN IMMEDIATE for the dequeue fast-path; SQLite's single-writer semantics make this race-free under the typical single-node deployment. For HA setups switch to the postgres driver via FILEMANAGER_QUEUE_DRIVER=postgres.
It also serves MySQL/MariaDB, registered under the name "mysql". The placeholder syntax and every statement here are shared; the three expressions that ask the server for the current time are not, and go through nowExpr/nowOffset. ⚠ Before issue #19 a MySQL install got this driver in its SQLite spelling, so every poll logged a syntax error and no queued job — content extraction, antivirus scans, replica retries — ever ran, on a server that otherwise looked healthy.
Index ¶
- type Driver
- func (d *Driver) Ack(ctx context.Context, id string) error
- func (d *Driver) Cancel(ctx context.Context, id string) error
- func (d *Driver) Close() error
- func (d *Driver) Dequeue(ctx context.Context, types []string) (queue.Op, error)
- func (d *Driver) Enqueue(ctx context.Context, op queue.Op) (string, error)
- func (d *Driver) Fail(ctx context.Context, id, errMsg string, retry bool) error
- func (d *Driver) Get(ctx context.Context, id string) (queue.Op, error)
- func (d *Driver) Init(_ context.Context, cfg map[string]any) error
- func (d *Driver) List(ctx context.Context, status string, limit, offset int) ([]queue.Op, int64, error)
- func (d *Driver) Name() string
- func (d *Driver) RecoverOrphans(ctx context.Context, olderThan time.Duration) (int64, error)
- func (d *Driver) Retry(ctx context.Context, id string) error
- func (d *Driver) Stats(ctx context.Context) (queue.Stats, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the SQLite-backed queue — and, in mysql mode, the MySQL/MariaDB one.
func (*Driver) Close ¶
Close releases the underlying *sql.DB only when this driver opened it (cfg["dsn"] path). When wired against the application's shared *sql.DB (cfg["db"]), Close is a no-op so we don't tear down the metadata store.
func (*Driver) Dequeue ¶
Dequeue uses an UPDATE-with-subquery RETURNING (SQLite ≥ 3.35) to atomically claim the next eligible op for a worker.
func (*Driver) Init ¶
Init opens the queue's DB. cfg keys:
dsn — SQLite connection string. Required.
Pass the same DSN as the metadata store to share one file.
db — *sql.DB (optional). When set, dsn is ignored. Used by the
bootstrap path that already has the application *sql.DB
handle.
func (*Driver) List ¶
func (d *Driver) List(ctx context.Context, status string, limit, offset int) ([]queue.Op, int64, error)
List returns ops with optional status filter and pagination.
func (*Driver) RecoverOrphans ¶
RecoverOrphans flips long-running rows back to pending. Called on boot to handle ungraceful shutdowns.