config

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config defines pdbq's configuration model and its loading rules: YAML file < environment (PDBQ_*) < command-line flags.

Every field carries a `koanf` tag (its YAML/env path) and a `doc` tag; the annotated reference YAML (`pdbq config example`) is generated from these tags so documentation can never drift from the structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExampleYAML

func ExampleYAML() string

ExampleYAML renders the fully-commented reference configuration from the Config struct tags and defaults, so the reference can never drift from the real config surface.

Types

type Auth

type Auth struct {
	Mode         string        `koanf:"mode" doc:"Claim source: 'jwt', 'headers' (behind a trusted gateway), or 'none'."`
	JWTSecret    string        `koanf:"jwt_secret" doc:"HMAC secret for HS256/384/512 verification (jwt mode; ignored when jwks_url is set)."`
	JWKSURL      string        `` /* 134-byte string literal not displayed */
	JWKSCacheTTL time.Duration `koanf:"jwks_cache_ttl" doc:"How long fetched JWKS keys are cached; an unknown kid triggers an early refresh (key rotation)."`
	JWTIssuer    string        `koanf:"jwt_issuer" doc:"Expected iss claim; empty skips the check."`
	JWTAudience  string        `koanf:"jwt_audience" doc:"Expected aud claim; empty skips the check."`
	HeaderPrefix string        `koanf:"header_prefix" doc:"Header prefix mapped to claims in headers mode, e.g. X-Pdbq-Claim-."`
	JWTType      string        `` /* 320-byte string literal not displayed */
}

type Config

type Config struct {
	Database Database `koanf:"database"`
	Server   Server   `koanf:"server"`
	Schema   Schema   `koanf:"schema"`
	Filters  Filters  `koanf:"filters"`
	RLS      RLS      `koanf:"rls"`
	TX       TX       `koanf:"transactions"`
	Watch    Watch    `koanf:"watch"`
	Errors   Errors   `koanf:"errors"`
	Plugins  Plugins  `koanf:"plugins"`
	Log      Log      `koanf:"log"`
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the documented defaults.

func Load

func Load(path string, flags *flag.FlagSet) (Config, error)

Load builds the effective config: defaults, then optional YAML file, then PDBQ_* env vars, then flags (highest precedence).

func (*Config) DisabledPlugins

func (c *Config) DisabledPlugins() map[string]bool

DisabledPlugins returns the disabled-plugin set for registry filtering.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks cross-field invariants.

type Database

type Database struct {
	URL              string        `` /* 131-byte string literal not displayed */
	MaxConns         int32         `koanf:"max_conns" doc:"Maximum pooled connections."`
	ConnectTimeout   time.Duration `koanf:"connect_timeout" doc:"Timeout for establishing a connection."`
	StatementTimeout time.Duration `koanf:"statement_timeout" doc:"Per-statement timeout applied to every request (0 disables)."`
}

type Errors

type Errors struct {
	Detail string `` /* 139-byte string literal not displayed */
}

type Filters

type Filters struct {
	IndexedOnly  bool                `koanf:"indexed_only" doc:"Only allow filtering on columns covered by an index (default policy)."`
	AllowColumns map[string][]string `koanf:"allow_columns" doc:"Per-table extra filterable columns, keyed by schema.table, overriding indexed_only."`
}

type Log

type Log struct {
	Level  string `koanf:"level" doc:"Log level: debug, info, warn, error."`
	Format string `koanf:"format" doc:"Log format: text or json."`
}

type Plugins

type Plugins struct {
	Disabled []string                  `koanf:"disabled" doc:"Plugin names to disable."`
	Settings map[string]map[string]any `koanf:"settings" doc:"Per-plugin configuration, keyed by plugin name."`
}

type RLS

type RLS struct {
	Enabled       bool     `` /* 180-byte string literal not displayed */
	DefaultRole   string   `koanf:"default_role" doc:"Role assumed for authenticated requests without a role claim."`
	AnonymousRole string   `koanf:"anonymous_role" doc:"Role assumed for unauthenticated requests."`
	RoleClaim     string   `koanf:"role_claim" doc:"JWT claim (or header name in header mode) carrying the database role."`
	AllowedRoles  []string `` /* 178-byte string literal not displayed */
	ClaimsPrefix  string   `koanf:"claims_prefix" doc:"set_config namespace for request claims, e.g. pdbq.claims."`
	Auth          Auth     `koanf:"auth"`
}

type Schema

type Schema struct {
	Schemas   []string `koanf:"schemas" doc:"PostgreSQL schemas to expose."`
	CachePath string   `koanf:"cache_path" doc:"Boot from this schema cache file instead of introspecting (see pdbq schema dump)."`
	Functions bool     `koanf:"functions" doc:"Expose PostgreSQL functions as custom queries/mutations."`
}

type Server

type Server struct {
	Addr                 string        `koanf:"addr" doc:"Listen address for the HTTP server."`
	GraphiQL             bool          `koanf:"graphiql" doc:"Serve the GraphiQL playground at / (off by default; enable for development)."`
	ExposeSchema         bool          `` /* 160-byte string literal not displayed */
	RequestTimeout       time.Duration `koanf:"request_timeout" doc:"Overall HTTP request timeout."`
	MaxBodyBytes         int64         `koanf:"max_body_bytes" doc:"Maximum accepted request body size in bytes."`
	MaxDepth             int           `koanf:"max_depth" doc:"Maximum GraphQL selection depth per operation."`
	MaxCost              int           `koanf:"max_cost" doc:"Maximum estimated cost (selected fields x list multipliers) per operation."`
	MaxPageSize          int           `` /* 136-byte string literal not displayed */
	CORSOrigins          []string      `` /* 129-byte string literal not displayed */
	Compression          bool          `koanf:"compression" doc:"Gzip responses for clients that send Accept-Encoding: gzip (off by default)."`
	APQ                  bool          `` /* 179-byte string literal not displayed */
	PersistedQueriesPath string        `` /* 142-byte string literal not displayed */
	PersistedOnly        bool          `` /* 159-byte string literal not displayed */
}

type TX

type TX struct {
	Mutations  bool   `koanf:"mutations" doc:"Wrap every mutation in a transaction."`
	PerRequest bool   `koanf:"per_request" doc:"Use one transaction for the whole request instead of one per operation."`
	Isolation  string `koanf:"isolation" doc:"Transaction isolation level: read_committed, repeatable_read, serializable."`
	MaxRetries int    `` /* 233-byte string literal not displayed */
}

type Watch

type Watch struct {
	Enabled      bool          `` /* 129-byte string literal not displayed */
	PollInterval time.Duration `koanf:"poll_interval" doc:"Poll interval used when event triggers cannot be installed."`
	Channel      string        `koanf:"channel" doc:"NOTIFY channel used by the DDL event trigger."`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL