sqlite

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxStateFilterSize = sqliteMaxVariableNumber - countByStateBaseParams

MaxStateFilterSize caps the number of state names accepted in a CountByState filter. The cap is derived from SQLite's bound-variable limit minus the count of other parameters bound in the same query, so the IN-clause `?`-list combined with the base params can never exceed SQLITE_MAX_VARIABLE_NUMBER. State values are already bound as parameters (no interpolation), but the bounded-input contract closes the door on a caller accidentally passing a huge list and triggering a driver-level "too many SQL variables" error rather than a clean helper-boundary rejection.

Variables

View Source
var ErrInvalidAggregate = errors.New("invalid aggregate expression")

ErrInvalidAggregate signals a malformed AggregateExpr reaching the plugin.

View Source
var ErrInvalidFilterPath = fmt.Errorf("%w", spi.ErrInvalidFilterPath)

ErrInvalidFilterPath is returned when a Filter.Path or OrderSpec.Path contains characters that could break out of a JSON-path literal in a json_extract expression. Sentinel for callers that want to distinguish input validation errors from storage errors.

It wraps spi.ErrInvalidFilterPath, the cross-backend sentinel, so errors.Is matches against either this one or the SPI one. The "%w"-only wrap adds no prefix, leaving the message text unchanged.

View Source
var ErrInvalidGroupExpr = errors.New("invalid group expression")

ErrInvalidGroupExpr signals a malformed spi.GroupExpr reaching the plugin. Inputs are normally validated upstream (Task 6); this is defence-in-depth.

View Source
var ErrStateFilterTooLarge = errors.New("state filter exceeds maximum size")

ErrStateFilterTooLarge is returned by CountByState when the caller supplies more state names than MaxStateFilterSize allows. Callers can detect it via errors.Is — wrapped with the actual and max sizes to aid diagnostics without leaking SQL driver internals.

Functions

func DefaultDBPath

func DefaultDBPath() string

DefaultDBPath returns the per-OS default path for the sqlite database file. Linux and macOS share XDG semantics ($XDG_DATA_HOME/cyoda/cyoda.db, fallback ~/.local/share/cyoda/cyoda.db). Windows uses %LocalAppData%\cyoda\ cyoda.db. Returns the literal "cyoda.db" (current directory) when the user home directory cannot be determined.

func EvaluateFilter

func EvaluateFilter(p spi.PreparedFilter, entity *spi.Entity) bool

EvaluateFilter is a public wrapper around evaluateFilter exposed so that cross-module parity tests (against spi.PreparedFilter.Match) can pin the contract that grouped-stats / streaming-tally must produce the same boolean as the sqlite post-filter step for any (filter, entity) tuple. NOT intended for hot-path use by other code — call sites within this plugin should keep using evaluateFilter directly.

Types

type ApplyFunc

type ApplyFunc func(base []byte, deltas []spi.SchemaDelta) ([]byte, error)

ApplyFunc replays opaque SchemaDeltas, in order, onto a base schema in one call and returns the new schema bytes; an empty list re-encodes base. Production wiring uses schema.ApplyMany from internal/domain/model/schema; the SPI keeps deltas opaque so the catalog stays out of the plugin.

type Clock

type Clock interface {
	Now() time.Time
}

Clock abstracts time.Now so tests can advance it deterministically. Production uses wallClock; conformance tests use TestClock.

type Option

type Option func(*StoreFactory)

Option is a functional option for newStoreFactory.

func WithApplyFunc

func WithApplyFunc(fn ApplyFunc) Option

WithApplyFunc installs the replay function used by ExtendSchema. Must be called when the caller intends to use ExtendSchema; until then, ExtendSchema returns an informative error.

func WithBusinessClock

func WithBusinessClock(c Clock) Option

WithBusinessClock injects the BUSINESS clock: the one behind submit time, snapshot time, consistency time and retention cutoffs. It defaults to the physical clock.

func WithClock

func WithClock(c Clock) Option

WithClock injects the PHYSICAL clock into the factory: the clock behind liveness (scheduler owner heartbeats and sweeps, search-job heartbeats and stale reclaim). Used by conformance tests to advance time deterministically.

type StoreFactory

type StoreFactory struct {
	// contains filtered or unexported fields
}

StoreFactory implements spi.StoreFactory backed by SQLite.

func NewStoreFactoryForTest

func NewStoreFactoryForTest(ctx context.Context, dbPath string, opts ...Option) (*StoreFactory, error)

NewStoreFactoryForTest creates a factory with auto-migrate enabled and the given path. Intended for test use only.

func (*StoreFactory) AsyncSearchStore

func (f *StoreFactory) AsyncSearchStore(_ context.Context) (spi.AsyncSearchStore, error)

func (*StoreFactory) Close

func (f *StoreFactory) Close() error

func (*StoreFactory) EntityStore

func (f *StoreFactory) EntityStore(ctx context.Context) (spi.EntityStore, error)

func (*StoreFactory) KeyValueStore

func (f *StoreFactory) KeyValueStore(ctx context.Context) (spi.KeyValueStore, error)

func (*StoreFactory) MessageStore

func (f *StoreFactory) MessageStore(ctx context.Context) (spi.MessageStore, error)

func (*StoreFactory) ModelStore

func (f *StoreFactory) ModelStore(ctx context.Context) (spi.ModelStore, error)

func (*StoreFactory) Ping

func (f *StoreFactory) Ping(ctx context.Context) error

Ping implements spi.StoreFactory. It checks the read handle, which is a separate pool from the writer and so answers while a write is in progress. After Close the handle is closed and the ping fails.

func (*StoreFactory) ScheduledTaskStore

func (f *StoreFactory) ScheduledTaskStore(_ context.Context) (spi.ScheduledTaskStore, error)

ScheduledTaskStore returns the scheduled-task store. No tenant is resolved from ctx: every tenant-facing method takes its tenant as an argument, and ClaimDue, GiveBackIdle and the owner and sweep methods are cross-tenant.

func (*StoreFactory) SetApplyFunc

func (f *StoreFactory) SetApplyFunc(fn func(base []byte, deltas []spi.SchemaDelta) ([]byte, error))

SetApplyFunc installs the replay function used by ExtendSchema. May be called at most once — typically immediately after Plugin.NewFactory in app/app.go. Panics on double-call (programmer error).

The parameter is the unnamed function type (not sqlite.ApplyFunc) so that an interface type-assertion in app/app.go can satisfy the setter uniformly across plugins.

func (*StoreFactory) StateMachineAuditStore

func (f *StoreFactory) StateMachineAuditStore(ctx context.Context) (spi.StateMachineAuditStore, error)

func (*StoreFactory) SupportsCompositeUniqueKeys

func (f *StoreFactory) SupportsCompositeUniqueKeys() bool

SupportsCompositeUniqueKeys advertises composite-unique-key enforcement.

func (*StoreFactory) TransactionManager

func (f *StoreFactory) TransactionManager(_ context.Context) (spi.TransactionManager, error)

TransactionManager implements spi.StoreFactory. Returns the TM registered via initTransactionManager. Errors if none is set.

func (*StoreFactory) WorkflowStore

func (f *StoreFactory) WorkflowStore(ctx context.Context) (spi.WorkflowStore, error)

type TestClock

type TestClock struct {
	// contains filtered or unexported fields
}

TestClock is a mutable clock for tests. Advance(d) moves it forward; Now returns the current virtual time. Safe for concurrent use.

func NewTestClock

func NewTestClock() *TestClock

NewTestClock returns a TestClock starting at the current wall-clock time.

func NewTestClockAt

func NewTestClockAt(t time.Time) *TestClock

NewTestClockAt returns a TestClock whose virtual time starts at t.

func (*TestClock) Advance

func (c *TestClock) Advance(d time.Duration)

Advance moves the virtual clock forward by d. d must be > 0; d <= 0 panics. Matches the spitest.Harness.AdvanceClock contract.

func (*TestClock) Now

func (c *TestClock) Now() time.Time

Now returns the current virtual time.

Jump to

Keyboard shortcuts

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