The old rule made a currency named in both vs_currencies and convert_currency
a 400, on the grounds that one key cannot be both Passthrough and Estimate.
The cost landed on the client: to phrase a legal request status-go had to
carry a hardcoded proxyPassthroughCurrencies = {usd, eur, btc, eth} mirroring
coingecko_prices.currencies from our config.yaml. Editing our config would
have broken the client silently, and the client was deciding something it had
no information about.
convert_currency=X now means "give me values in X". The proxy picks the
source: when it already holds the provider's own values for X it serves those,
because provider data beats anything derived from a ratio; otherwise it
converts as before. The duplicate is deduped and served once. An unsupported
currency is still a 400, and convert_currency alone is now a complete request
since it names a currency just as vs_currencies does.
The URL no longer tells you which of the two you got, and that signal is worth
keeping - X-Estimated-Currencies carries it back instead, listing the computed
currencies and absent when everything served was provider data. It survives
nginx: cached with the body on a HIT and returned on a 304, verified against
the local stack.
Checking the "only simple/price is affected" assumption in code turned up a
latent bug rather than confirming it. The leaderboard caches
coingecko_leaderboard.currency, not usd, and converted by reading the cache
under the base currency - configure it to anything but usd and every converted
response was empty. It now reads its own currency and crosses the Ratios,
which are all expressed against the base. coins/markets has the analogous
shape via market_params_normalize.vs_currency. Both now serve their cached
currency directly instead of computing a copy of data they already hold.
ADR 0001 gets an amendment recording what superseded the original rule and
why, rather than a quiet edit; the invariant it protects - Passthrough is
never mutated - is untouched.
Adding a fetcher touches nine places across three directories, and which ones
you need is only discoverable by reading an existing service end to end. The
recent additions each missed something different, so the layers are written
down: config block and validation, API client and request builder, service
with scheduler and metrics, composition root, handler and interfaces entry,
nginx location and CORS patch, tests.
It is a guide, not a rule set - CONTEXT.md and the ADR keep their roles. It
leans on coingecko_assets_platforms as the minimal shape and currency_ratios
as the recent full one, and ends with the checklist of things that are easy
to forget: the metrics writer, the README endpoint lists, and the two test
tools outside this repo.
currency_ratios was the example of a miss: its siblings all have an api_test.go
and it had none, so the request it builds - every configured currency, the 24h
changes the honest conversion needs, full precision - was only covered
indirectly. Now it is covered directly.