Skip to content

refactor!: API hygiene before 1.0 - #90

Closed
archlemon wants to merge 1 commit into
feat/smarttags-v5from
refactor/b15
Closed

archlemon wants to merge 1 commit into
feat/smarttags-v5from
refactor/b15

Conversation

@archlemon

Copy link
Copy Markdown
Member

Closes #87

Stacked on #89 (base feat/smarttags-v5). Once #89 merges, GitHub retargets this PR to main, and I'll rebase it onto the squash commit.

Implements the readiness review's B15 cleanup. The full list is in docs/upgrading.md ("API hygiene") and CHANGELOG.md Unreleased.

confx

  • Load(envPrefix, path, dst, opts...) no longer imports pflag. Command-line values come in through WithFlags(map[path]value), and the new confx/cliflags.Changed(fs, except...) replaces ChangedFlags.
  • New WithRemoved(map[old]reason) option for keys removed without a replacement. The error reads unknown key transactions.mutations: removed: <reason>, for both file keys and environment variables.
  • The schema.cache_path, auth.headers.prefix and errors.detail doc tags no longer name a product, and the InvalidConfig doc no longer says "pdbq's error shape".
  • MovedKeys, ParseTrustedProxy, ValidChannelName and the unread TX.Mutations field are no longer exported. Contract.Default is a contract.Policy.

Typed enums that reject instead of falling back

  • pgexec.ParseIsolation returns (pgx.TxIsoLevel, error) and pgexec.ParseDetail returns (Detail, error); Detail gains String.
  • transactions.isolation errors now name the accepted values.
  • contract.ParsePolicy is new, and Contract.View returns an error for an unknown policy.

One error-policy API

pgexec.SanitizeMessage(pgErr, strict) is gone. Classify(err, detail).Message renders the same text.

postgis and contrib

  • OutputSQL(ref, Output{JSON, Precision}) replaces the four Output{,JSON}{,Precision}SQL functions.
  • Derived.SQL(ref, f, Output) and RasterAccessor.SQL(ref, Output) replace their variants.
  • Ops(), Deriveds(), RasterAccessors() and contrib.VectorTypes() replace the mutable exported variables.
  • postgis.Op.Index / Op.Arg are renamed to Indexable / OperandType, so they no longer clash with contrib.Op.Index / contrib.Op.Arg.

Pruned exports

  • Removed: jwtmint.Sign, contract.Apply / OmitAll / TransformCatalog, postgis.OpsDoc / OpNames / DerivedSuffixes.
  • I regenerated the usage table against current main. An export was pruned only when neither product nor pdbcore's external tests or docs need it.

watch

  • New(Config) (*Watcher, error) validates the names and requires Pool and OnChange.
  • OnChange is func(ctx, cat) and receives Run's context.
  • Run no longer writes defaults or state back into the watcher's fields; per-run state lives in an unexported struct.

CI

The downstream job builds pdbq and pdbr main against this branch. It is expected to fail here because of the breaking changes, until the pdbq and pdbr PRs that switch to this API merge.

Tests

  • go test -race ./..., go vet, golangci-lint
  • DB-backed suites on PostGIS 18 with pgvector
  • act lint-test

- confx: Load takes WithFlags values instead of a pflag set
  (confx/cliflags.Changed builds them); WithRemoved names keys removed
  without a replacement; shared doc tags and messages no longer name a
  product; MovedKeys, ParseTrustedProxy, ValidChannelName and
  TX.Mutations are gone; Contract.Default is a contract.Policy.
- pgexec: SanitizeMessage is gone in favour of Classify; ParseIsolation
  and ParseDetail reject unknown spellings instead of falling back.
- contract: ParsePolicy; View fails on an unknown policy; Apply, OmitAll
  and TransformCatalog are gone.
- postgis: OutputSQL, Derived.SQL and RasterAccessor.SQL take an Output
  (json, precision) instead of four variants each; Ops, Deriveds and
  RasterAccessors are accessor functions; Op.Index and Op.Arg are
  Indexable and OperandType; OpsDoc, OpNames and DerivedSuffixes are gone.
- contrib: VectorTypes is an accessor function.
- jwtmint: Sign is unexported.
- watch: New(Config) validates up front, OnChange receives Run's context,
  and Run no longer writes into the watcher's fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant