Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultDBPath() string
- func EvaluateFilter(f spi.Filter, entity *spi.Entity) (bool, error)
- 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) ScheduledTaskStore(_ context.Context) (spi.ScheduledTaskStore, 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) SupportsCompositeUniqueKeys() bool
- 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 ErrInvalidAggregate = errors.New("invalid aggregate expression")
ErrInvalidAggregate signals a malformed AggregateExpr reaching the plugin.
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 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.
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 ¶ added in v0.8.1
EvaluateFilter is a public wrapper around evaluateFilter exposed so that cross-module parity tests (e.g. against internal/match.MatchFilter) 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, 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) ScheduledTaskStore ¶ added in v0.8.3
func (f *StoreFactory) ScheduledTaskStore(_ context.Context) (spi.ScheduledTaskStore, error)
ScheduledTaskStore returns the durable ScheduledTask store. Unlike the per-tenant accessors above, it does not resolve a tenant from ctx: ScanDue is cross-tenant by design and Upsert/Delete/Reconcile carry the tenant on the task/request itself (see spi.ScheduledTaskStore godoc).
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) SupportsCompositeUniqueKeys ¶ added in v0.8.2
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 ¶ added in v0.8.2
NewTestClockAt returns a TestClock whose virtual time starts at t.
Source Files
¶
- clock.go
- config.go
- entity_store.go
- errors.go
- grouped_stats.go
- kv_store.go
- message_store.go
- migrate.go
- model_extensions.go
- model_store.go
- path_validation.go
- plugin.go
- post_filter.go
- query_planner.go
- scheduled_task_store.go
- search_store.go
- searcher.go
- sm_audit_store.go
- store_factory.go
- txmanager.go
- unique_claims.go
- uuid.go
- workflow_store.go