Documentation
¶
Overview ¶
Package db opens Peen's SQLite database, applies its embedded migrations, and wires the generated gorm/gen repositories. Business code uses the typed repository layer rather than a raw database handle.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Directory string
InMemory bool
BusyTimeout time.Duration
Metrics *metrics.Metrics
}
Config identifies the private directory and SQLite connection behavior.
type Handle ¶
type Handle struct {
GormDB *gorm.DB
// Workflows shares the handle's lifetime when runtime assembly opens it.
Workflows *WorkflowStorage
// contains filtered or unexported fields
}
Handle owns an open SQLite connection and its generated GORM query surface.
type WorkflowStorage ¶ added in v0.25.0
WorkflowStorage owns the native workflow backend and its SQL connection. Its schema is separate from Peen's pinned session schema.
func OpenWorkflowStorage ¶ added in v0.25.0
func OpenWorkflowStorage( ctx context.Context, cfg Config, ) (*WorkflowStorage, error)
OpenWorkflowStorage prepares private SQLite storage and applies the native workflow backend's migrations. Startup errors are returned to the caller.
func (*WorkflowStorage) Close ¶ added in v0.25.0
func (s *WorkflowStorage) Close() error
Close releases the caller-owned SQL connection. Repeated calls are safe.
func (*WorkflowStorage) WorkerBackend ¶ added in v0.25.0
func (s *WorkflowStorage) WorkerBackend( ctx context.Context, generationID uuid.UUID, ) (diag.Backend, error)
WorkerBackend binds native task leases to one worker generation. The controller keeps the SQL connection; closing this borrowed backend does not close durable storage or apply migrations again.