type

StoreFactory

A lazy, lifecycle-owned document-store constructor.

Example

go
func openStore(ctx context.Context) (store.Store, error) {
  return postgres.Open(ctx, os.Getenv("DATABASE_URL"))
}

err := ridu.Execute(content.Config(), ridu.WithStore(openStore))

Properties

PropertyTypeDescription
ctxcontext.ContextThe server lifecycle context, cancelled during shutdown.

Returns

One opened adapter owned by Execute, or a startup error.

(store.Store, error)

How it works

Project commands resolve configuration without calling this factory. Execute closes the returned store during shutdown.

Use a closure to read runtime configuration and adapt a concrete constructor such as postgres.Open to the store.Store return type. Go function types do not widen concrete return values automatically.

Do not open the database in package initialization or content.Config. Keeping the connection inside this factory is what lets schema discovery and generation run without database access.

Full signature