function
WithStore
func WithStore(factory StoreFactory) ExecuteOptionProvide the singular document-store adapter through the Execute lifecycle.
WithStore is required only for the no-argument server branch of Execute. Project commands such as generate and check resolve config without applying this option, so they do not need DATABASE_URL or a reachable database.
The factory receives the server lifecycle context. Return an unopened error rather than terminating the process inside the factory; Execute wraps it as open document store and returns it to main.
The returned store must implement the base store.Store contract and every optional capability enabled by the application. Production startup also requires store.ReadinessStore unless ServerOptions.AllowUnverifiableReadiness delegates readiness checking to an external system.
Execute owns the returned adapter. On startup failure or shutdown it calls Close() or Close() error when implemented, bounded by ServerOptions.ShutdownTimeout. Optional upload storage closes first, then the document store.
Example
err := ridu.Execute(
content.Config(),
ridu.WithStore(func(ctx context.Context) (store.Store, error) {
return postgres.Open(ctx, os.Getenv("DATABASE_URL"))
}),
ridu.WithAddress(":8080"),
)
if err != nil {
log.Fatal(err)
}Related types
StoreFactoryA lazy, lifecycle-owned document-store constructor.
ExecuteOptionOne opaque runtime option accepted by Execute.