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
// ContentBlobs, when set, makes workflow storage compact the payloads it
// encodes into this blob store. Peen's runtime always sets it.
ContentBlobs contentblob.Store
}
Config identifies the private directory and SQLite connection behavior.
type ContentBlobStore ¶ added in v0.26.3
type ContentBlobStore struct {
// contains filtered or unexported fields
}
ContentBlobStore keeps the long strings of compacted durable state in the session database. See package contentblob.
func (*ContentBlobStore) GetContentBlobs ¶ added in v0.26.3
func (s *ContentBlobStore) GetContentBlobs( ctx context.Context, hashes []string, ) (map[string][]byte, error)
GetContentBlobs returns the stored blobs for the requested hashes. A hash that is not stored is left out.
func (*ContentBlobStore) PutContentBlobs ¶ added in v0.26.3
func (s *ContentBlobStore) PutContentBlobs( ctx context.Context, blobs []contentblob.Blob, ) error
PutContentBlobs stores blobs. Storing a blob that is already stored is a no-op. Every blob must be one string literal whose bytes match its hash, so no caller can store text under a hash it does not own.
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.
func (*Handle) ContentBlobs ¶ added in v0.26.3
func (h *Handle) ContentBlobs() *ContentBlobStore
ContentBlobs returns the blob store of this database.
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.