function
WithStore
Provide the singular document-store adapter through the Execute lifecycle.
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)
}Arguments
| Argument | Type | Description |
|---|---|---|
factory | StoreFactory | A lazy constructor invoked once when Execute starts the HTTP server. |
Returns
An option to pass directly to ridu.Execute.
ExecuteOptionHow it works
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.
Full signature
func WithStore(factory StoreFactory) ExecuteOptionRelated types
StoreFactoryA lazy, lifecycle-owned document-store constructor.
ExecuteOptionOne opaque runtime option accepted by Execute.