type
StoreFactory
type StoreFactory = core.StoreFactoryA lazy, lifecycle-owned document-store constructor.
ctxcontext.Context- The server lifecycle context, cancelled during shutdown.
Returns (store.Store, error) One opened adapter owned by Execute, or a startup error.
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.
Example
func openStore(ctx context.Context) (store.Store, error) {
return postgres.Open(ctx, os.Getenv("DATABASE_URL"))
}
err := ridu.Execute(content.Config(), ridu.WithStore(openStore))