Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultDBPath() string
- type ApplyFunc
- type Clock
- type Option
- type StoreFactory
- func (f *StoreFactory) AsyncSearchStore(_ context.Context) (spi.AsyncSearchStore, error)
- func (f *StoreFactory) Close() error
- func (f *StoreFactory) EntityStore(ctx context.Context) (spi.EntityStore, error)
- func (f *StoreFactory) KeyValueStore(ctx context.Context) (spi.KeyValueStore, error)
- func (f *StoreFactory) MessageStore(ctx context.Context) (spi.MessageStore, error)
- func (f *StoreFactory) ModelStore(ctx context.Context) (spi.ModelStore, error)
- func (f *StoreFactory) SetApplyFunc(fn func(base []byte, delta spi.SchemaDelta) ([]byte, error))
- func (f *StoreFactory) StateMachineAuditStore(ctx context.Context) (spi.StateMachineAuditStore, error)
- func (f *StoreFactory) TransactionManager(_ context.Context) (spi.TransactionManager, error)
- func (f *StoreFactory) WorkflowStore(ctx context.Context) (spi.WorkflowStore, error)
- type TestClock
Constants ¶
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. See issue #68 (item 11) and #99.
Variables ¶
var ErrInvalidFilterPath = errors.New("invalid filter path")
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.
var ErrScanBudgetExhausted = errors.New("scan budget exhausted")
ErrScanBudgetExhausted is returned when a search with a residual filter examines more rows than the configured SearchScanLimit without filling the requested result page. Callers should tighten their filter.
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.
Types ¶
type ApplyFunc ¶
type ApplyFunc func(base []byte, delta spi.SchemaDelta) ([]byte, error)
ApplyFunc replays an opaque SchemaDelta onto a base schema and returns the new schema bytes. Production wiring uses schema.Apply from internal/domain/model/schema; the SPI keeps deltas opaque so the catalog stays out of the plugin.
type Clock ¶
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 ¶
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.
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 NewStoreFactoryForTestWithScanLimit ¶
func NewStoreFactoryForTestWithScanLimit(ctx context.Context, dbPath string, scanLimit int, opts ...Option) (*StoreFactory, error)
NewStoreFactoryForTestWithScanLimit creates a factory with a custom scan limit for testing scan budget exhaustion. 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) SetApplyFunc ¶
func (f *StoreFactory) SetApplyFunc(fn func(base []byte, delta 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) 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.