Documentation
¶
Overview ¶
Package bootstrap loads configuration and assembles the application: it resolves secret placeholders, opens the database provider, converts config entities to the core entity model, and wires the registry, authorizer, cost gate, engine, and tools. It is the only place that imports gopkg.in/yaml.v3 and x/providers.
Index ¶
- Variables
- func Load(path string) (*config.Config, error)
- func RedactDSN(dsn string) string
- func ValidateFile(path string, resolver SecretResolver) error
- type App
- type EnvFileResolver
- type Provider
- type Runtime
- func (r *Runtime) Acquire() (*App, func(), error)
- func (r *Runtime) Close() error
- func (r *Runtime) Current() *App
- func (r *Runtime) DatabasesReady(ctx context.Context) error
- func (r *Runtime) Reload(path string) error
- func (r *Runtime) RollbackSession(session string)
- func (r *Runtime) SnapshotReady(context.Context) error
- func (r *Runtime) Watch(ctx context.Context, path string, interval time.Duration, onError func(error)) error
- type SecretResolver
Constants ¶
This section is empty.
Variables ¶
var ErrRuntimeClosed = errors.New("bootstrap: runtime closed")
ErrRuntimeClosed is returned when a closed runtime is used.
var ErrUnsupportedDriver = providerregistry.ErrUnsupportedDriver
ErrUnsupportedDriver is returned for a driver with no provider yet.
Functions ¶
func RedactDSN ¶
RedactDSN returns dsn with any password replaced by ***, for safe logging. It handles PostgreSQL URI form (scheme://user:pass@host) and MySQL DSN form (user:pass@tcp(host)); DSNs without a password are returned unchanged.
func ValidateFile ¶
func ValidateFile(path string, resolver SecretResolver) error
ValidateFile parses, defaults, validates, and resolves secrets without opening database connections.
Types ¶
type App ¶
type App struct {
Provider Provider
Providers map[string]Provider
Prepared map[string]*store.PreparedDB
Sources map[string]tool.DataSource
Dialect dialect.Dialect
Registry *entity.Registry
Authorizer rbac.Authorizer
Masker mask.Masker
Gate cost.Gate
Engine *engine.Engine
Tools *tool.Registry
ToolFlags config.ToolFlags
DefaultRole string
QueryTimeout time.Duration
MaxRows int64
MaxProcedureRows int64
MaxReturnedBytes int64
MaxINListSize int
MaxFilterConditions int
MaxGroupByFields int
MaxAggregates int
MaxExpand int
CacheMaxEntryRows int
CacheMaxEntryBytes int64
TransactionBeginTimeout time.Duration
TransactionCommitTimeout time.Duration
TransactionRollbackTimeout time.Duration
Auditor audit.Auditor
Hooks *hook.Hooks
Cache cache.Cache[[]map[string]any]
Feedback cost.FeedbackStore
Analyze cost.AnalyzePolicy
Budget budget.Manager
Transactions *tool.TransactionManager
TxBeginners map[string]store.TxBeginner
// contains filtered or unexported fields
}
App is the assembled application, ready to serve.
func Assemble ¶
Assemble opens the provider and wires the application from cfg, using the default EnvFileResolver for secret placeholders.
func AssembleWithProvider ¶
AssembleWithProvider wires the application using an injected provider (for testing with fakes).
func AssembleWithProviders ¶
AssembleWithProviders wires named providers. It is intended for tests and embedders; ownership transfers to the returned App on success.
func AssembleWithResolver ¶
func AssembleWithResolver(cfg *config.Config, r SecretResolver) (*App, error)
AssembleWithResolver resolves secrets with the given resolver, opens the provider, and wires the application. Use a custom resolver to integrate secret managers (Vault, AWS Secrets Manager, etc.) without coupling core to any specific backend.
func (*App) Close ¶
Close preserves the original unbounded close contract. Callers that need a shutdown deadline should use CloseContext.
func (*App) CloseContext ¶
CloseContext stops engine admission and drains all execution before rolling back transactions and releasing audit/provider resources.
func (*App) Ping ¶ added in v0.1.6
Ping verifies every configured database is reachable. It backs the /readyz/db readiness probe and stays off the tool execution path: it uses the provider's native connection ping when exposed and falls back to a trivial query otherwise.
func (*App) ToolContext ¶
ToolContext builds a per-request tool.Context for the given role.
type EnvFileResolver ¶
type EnvFileResolver struct {
AllowedRoots []string
}
EnvFileResolver resolves ${ENV} (environment variables) and ${file:/path} (file contents, e.g. Kubernetes Secret volume mounts).
type Provider ¶
type Provider = coreprovider.Provider
Provider aggregates the core interfaces a database adapter must satisfy.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns the atomically replaceable App snapshot used by serving handlers. A successful reload publishes the new App before draining and closing the old one; a failed build leaves the current App untouched.
func NewRuntime ¶
NewRuntime creates a runtime using Load followed by Assemble for reloads.
func NewRuntimeWithBuilder ¶
NewRuntimeWithBuilder creates a runtime with an injected reload builder. It is useful for embedders and tests that assemble providers themselves.
func (*Runtime) Acquire ¶
Acquire leases the current snapshot until the returned release function is called. It retries when racing with retirement.
func (*Runtime) Current ¶
Current returns the currently published App, or nil after Close. Handlers that execute work must use Acquire so the App cannot close during the call.
func (*Runtime) DatabasesReady ¶ added in v0.1.6
DatabasesReady pings every database of the current snapshot. It backs the /readyz/db readiness probe.
func (*Runtime) Reload ¶
Reload performs parse/default/validate/secret-resolution/assembly before atomically publishing the new App. Build failure preserves the old snapshot.
func (*Runtime) RollbackSession ¶
RollbackSession rolls back transactions associated with a disconnected MCP session when the transport exposes a stable non-empty session ID.
func (*Runtime) SnapshotReady ¶ added in v0.1.6
SnapshotReady reports whether a configuration snapshot is currently published and servable. It backs the /readyz/snapshot readiness probe.
type SecretResolver ¶
SecretResolver resolves ${...} placeholders in a string (e.g. a DSN). EnvFileResolver is the built-in implementation; custom implementations can back this by Vault, AWS Secrets Manager, GCP Secret Manager, etc., without coupling core to any specific backend.