mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
328b5fcb2b
Atlas throttled to the 1.1s OSM asks for and cached its answers in a 50k map; maps did neither, so five interactive routes fired straight at the service while the two atlas backfill loops politely waited their turn. From Nominatim's side that is one instance ignoring the rate limit. Both go through geo/nominatim.client.ts now. Three things the naive merge would have got wrong: - The shared client sends UA, the instance-identifying User-Agent, not the generic string atlas used. A shared generic UA is throttled harder. - One cursor across five interactive routes and two background loops would have put a keystroke behind however many places the backfill enqueued, so there are two lanes over the one cursor and background yields. - The cache key carries the query shape. Atlas asks at zoom 3 and 8, maps at 18; a coordinate-only key answers a street lookup with a country. The throttle cursor and the cache stay module state, the way the permissions and FX caches do, because the bridges build their collaborators outside the container and a second copy of the cursor is the bug being removed here. GeocodingService owns only the cleanup timer's lifecycle, which atlas used to start as an import-time side effect. Also folds the three haversine implementations into common/geo.ts, keeping the clamped form: asin of a value a hair over 1 is NaN, and a NaN distance fails every comparison it feeds instead of throwing. tests/setup.ts zeroes the interval. Nineteen maps cases drive these paths back to back with real timers and were sleeping nineteen seconds for it.
20 lines
732 B
TypeScript
20 lines
732 B
TypeScript
import { Module } from '@nestjs/common';
|
|
import { GeocodingService } from './geocoding.service';
|
|
|
|
/**
|
|
* The single Nominatim seam.
|
|
*
|
|
* A leaf that imports nothing and is registered straight in AppModule, rather
|
|
* than imported by MapsModule and AtlasModule. That is not an oversight: both
|
|
* domains reach `nominatimFetch` as a module-level primitive, because the
|
|
* bridges have to reach the very same throttle cursor from outside the
|
|
* container. An import here would claim an injection edge that does not exist.
|
|
* What the module contributes is the lifecycle hook that starts and stops the
|
|
* cache's cleanup timer.
|
|
*/
|
|
@Module({
|
|
providers: [GeocodingService],
|
|
exports: [GeocodingService],
|
|
})
|
|
export class GeoModule {}
|