Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ fixture both products are tested against.
| `watch` | `Watcher`: DDL event trigger + `LISTEN/NOTIFY` (`TriggerName`, `Channel`), hash-polling fallback when the trigger cannot be installed → `OnChange(*Catalog)` |
| `postgis` | spatial value layer: flavour detection, GeoJSON/WKT/EWKT parsing to one bound parameter, filter `Ops`, derived accessors, transform/simplify/buffer/KNN/distance SQL (`BufferSQL`, metres on geography; `DistanceSQL`, metres on the spheroid with `SpheroidDistanceSQL`), GeoJSON output with a bound coordinate precision (`OutputPrecisionSQL`/`OutputJSONPrecisionSQL`, `CheckPrecision`); `postgis_raster` columns (`IsRaster`): header-only metadata `RasterAccessors` (width, height, bands, SRID, pixel size, envelope as GeoJSON), `RasterValueSQL` (`ST_Value` at a bound point, reprojected to the raster's SRID), `RasterSummaryStatsSQL` (`ST_SummaryStats` of a band as a JSON object), `RasterIntersectsSQL` (served by a GiST index on `ST_ConvexHull(col)`) and `Raster*Cost` weights for cost estimators |
| `contrib` | operator vocabularies + value coercion for full-text search (`tsvector`, and `to_tsvector` over text and json/jsonb documents, with `ts_headline` snippets), `pg_trgm`, `unaccent`, `fuzzystrmatch`, `hstore`, `ltree`, `citext`, `intarray`, range/multirange, `inet`/`cidr`, pgvector (`vector`, `halfvec`, `sparsevec`, plus bit distances on `bit`/`varbit`), `cube` and `earthdistance` (`earth` columns, `<@>` on `point`) columns (see [Contrib vocabularies](#contrib-vocabularies)): `ForColumn`/`ForType` lookup bound to the extension's schema, filter `Op`s, ordering `Expr`s (`Expr.Score` marks the selectable similarity/distance values, `Expr.Derived` the per-use parameterised values such as an hstore key's value, `Expr.OrderSQL` the index-served ordering form), `Accessor`s, value `Codec`s, `Op.RankSQL`/`Op.HeadlineSQL` with validated `HeadlineOptions`, `HeadlineDocumentSQL`/`HeadlineDocumentCost` to bound and price a headline's document |
| `auth` | `Authenticator`: JWT (HS*, JWKS RS*/ES* with a kid-matched cache refreshed by one shared background fetch, stale keys served for one extra TTL during endpoint outages, failure backoff, endpoint details logged and never returned to clients), trusted-gateway claim headers with `TrustedProxies` (one spelling per claim: `User-Id` is `user_id`; underscores, repeats and case-folded duplicates are rejected; optional `HeaderClaims` allowlist; the gateway must strip every client-supplied prefixed header), role resolution and allowlist; `ErrInvalidToken` / `ErrRoleNotAllowed` |
| `pgexec` | pool `Connect` (connections to PostgreSQL < 14 fail), `RunTx` (isolation, `SET LOCAL ROLE`, claims via `set_config(prefix.k, v, true)`, 40001/40P01 retries), `QueryTx` (one pipelined round trip), `Savepoint` (run a step in a SAVEPOINT inside a `RunTx` callback; a failure rolls back to it and comes back as `*RolledBackError`, so the transaction goes on), `Observer` (per-attempt duration and error via `TxOptions.Observer`, `Observe` for direct statements), `Identity`, `Classify` PG errors into classes with `dev`/`prod`/`strict` message policies (malformed tsquery/ltree operands, unknown text search configs and raster/geometry SRID mismatches are user input), `QuoteIdent`/`ValidRole`/`ValidClaimKey` |
| `auth` | `Authenticator`: JWT (HS*, JWKS RS*/ES* with a kid-matched cache refreshed by one shared background fetch, stale keys served for one extra TTL during endpoint outages, failure backoff, endpoint details logged and never returned to clients), trusted-gateway claim headers with `TrustedProxies` (one spelling per claim: `User-Id` is `user_id`; underscores, repeats and case-folded duplicates are rejected; optional `HeaderClaims` allowlist; the gateway must strip every client-supplied prefixed header), typed `Mode` (`jwt`, `headers`, `none`; `New` rejects anything else, a headers mode without trusted proxies, and a jwt mode without a key), case-insensitive `Bearer`, clock-skew `Leeway`, role claim paths (`app_metadata.role`, `realm_access.roles[0]`), role resolution and allowlist, optional anonymous access, `SkipRoleSwitch`; `ErrInvalidToken` / `ErrAuthRequired` / `ErrRoleNotAllowed`, and `Challenge` for the `WWW-Authenticate` value |
| `pgexec` | pool `Connect` (connections to PostgreSQL < 14 fail), `RunTx` (isolation, `SET LOCAL ROLE`, claims via `set_config(prefix.k, v, true)` and optionally as one JSON setting, 40001/40P01 retries), `QueryTx` (one pipelined round trip), `Savepoint` (run a step in a SAVEPOINT inside a `RunTx` callback; a failure rolls back to it and comes back as `*RolledBackError`, so the transaction goes on), `Observer` (per-attempt duration and error via `TxOptions.Observer`, `Observe` for direct statements), `Identity`, `Classify` PG errors into classes with `dev`/`prod`/`strict` message policies (21* cardinality violations, malformed tsquery/ltree operands, unknown text search configs and raster/geometry SRID mismatches are user input), `QuoteIdent`/`ValidRole`/`ValidClaimKey` |
| `jwtmint` | composite-typed function results → signed HS256 JWT (`MintsFunction`, `Mint`, `Sign`) |
| `httpx` | CORS + preflight, gzip, `Healthz`, `ListenAndServe` with the standard timeouts and graceful shutdown |
| `httpx` | CORS (`CORSPolicy`: origins, preflight methods, exposed headers) + preflight, `AddVary`, gzip, `Healthz`, `ListenAndServe` with the standard timeouts and graceful shutdown |
| `metrics` | Prometheus instrumentation on a per-instance registry (or a caller's `Registerer` + `ConstLabels`): HTTP `Middleware` (requests, duration, in flight by route class, method, status class; `SetRoute`), `DBObserver` (a `pgexec.Observer`: duration, errors by SQLSTATE class, retries), `RegisterPool` (pgxpool `Stat`), `SchemaRebuilt`, `ObserveCompile`, product counters via `NewCounter`; `NewRegistry` + `RegisterPoolOn` for several instances (one per contract) on one registry; a nil `*Metrics` records nothing (see [Metrics](#metrics)) |
| `confx` | koanf `Load` (defaults < YAML < env < changed flags), env key mapper (`_` → `.`, `__` → `_`, comma-separated lists), `ExampleYAML` from `koanf`/`doc` tags, `Discover`, `ParseTrustedProxy`, shared config sections (`Database`, `Schema`, `Filters`, `RLS`/`Auth`, `TX`, `Watch`, `Errors`, `Plugins`, `Log`, `Metrics`, `Contract` list entries) + `Validate*` helpers (`ValidateContracts`), `AuthConfig(RLS)` |
| `confx` | strict koanf `Load` (defaults < YAML < env < changed flags; unknown keys are errors naming the key they moved to or the closest valid one, `MovedKeys`/`WithMoved`), env key mapper (`_` → `.`, `__` → `_`, comma-separated lists), `ExampleYAML` from `koanf`/`doc` tags, `Discover`, `ParseTrustedProxy`, shared config sections (`Database`, `Schema`, `Filters`, `Auth`/`JWT`/`Headers`, `Roles`, `Claims`, `TX`, `Watch`, `Errors`, `Plugins[S]` with typed per-plugin settings, `Log`, `Metrics`, `Contract` list entries) + `Validate*` helpers (`ValidateIdentity`, `ValidatePluginNames`, `ValidateContracts`), `AuthConfig(Auth, Roles)`, `IdentityWarnings` |
| `plugin` | `Plugin`, `Registry` (priority + registration order), `CatalogHook`, `InflectionHook`, `TransformCatalog`, `Inflector` chain |
| `smartcomments/catalog` | catalog half of the smart-comments plugin (`@omit`, `@primaryKey`, `@unique`, `@foreignKey`, `@notNull`, `@filterable`, `@anyelement` / `@anycompatible` on polymorphic functions, `@name` index) — products add their transport half on top |
| `testutil` | `FixtureSQL` (embedded DDL) and `FixtureCatalog()`, the one fixture both products test against; `testutil/cmd/fixture` prints the SQL; `drift_test.go` is the fixture drift gate |
Expand All @@ -52,7 +52,7 @@ cat, _ := introspect.Introspect(ctx, pool, cfg.Schema.Schemas) // or cache.Load(
// ... the product builds its schema / routes from cat and runs its own compiler ...
err := pgexec.RunTx(ctx, pool,
pgexec.TxOptions{Isolation: iso, MaxRetries: 2, RLS: true},
pgexec.Identity{Role: role, Claims: claims, ClaimsPrefix: "pdbq.claims"},
pgexec.Identity{Role: role, Claims: claims, ClaimsPrefix: "jwt.claims"},
func(q pgexec.Querier) error { return q.QueryRow(ctx, sql, args...).Scan(&data) })
```

Expand Down Expand Up @@ -81,8 +81,12 @@ Both products embed the `confx` sections in their own `Config` struct (the
product owns `Server` and its defaults such as `watch.channel` and the claim
header prefix), wrap `plugin.Registry` with their transport-specific hooks,
and register `smartcomments/catalog.New()` inside their smart-comments
plugin. `rls.claims_prefix` defaults to `pdbq.claims` in both so RLS policies
work unchanged behind either server; `watch.TriggerName` differs
plugin. `claims.prefix` defaults to `jwt.claims` (PostGraphile's namespace)
in both, and `claims.json_setting` can add PostgREST's `request.jwt.claims`,
so RLS policies work unchanged behind either server. The claim header
prefix stays per product (`X-Pdbq-Claim-` / `X-Pdbr-Claim-`): names SQL
sees are product-neutral so policies port, while names on the wire between
a gateway and the server are namespaced like every other product header; `watch.TriggerName` differs
(`pdbq_watch` / `pdbr_watch`) so both can watch one database.

Until the first tag lands the products point at a sibling checkout:
Expand Down
Loading
Loading