Keep network calls out of post transactions; cache and throttle geocoding
- PostService.create/update geocode and upload photos before opening the DB transaction (TransactionTemplate); uploaded files are removed if the transaction fails, so a DB connection is no longer held while waiting for Nominatim or MinIO. - GeocodingService: configurable URL and User-Agent (geocoding.*), results cached in Redis for 30 days by coordinates rounded to ~11 m, and a cluster-wide 1 request/s slot (geo:throttle) as the public Nominatim policy requires; city/district are cut to the column sizes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,13 @@ ai:
|
||||
delay: 500
|
||||
multiplier: 2
|
||||
|
||||
# Обратное геокодирование (GeocodingService): публичный Nominatim требует
|
||||
# User-Agent с контактом и не больше 1 запроса/с; для нагрузки — свой экземпляр
|
||||
geocoding:
|
||||
url: ${GEOCODING_URL:https://nominatim.openstreetmap.org}
|
||||
user-agent: ${GEOCODING_USER_AGENT:ReFound-backend/1.0}
|
||||
min-interval: ${GEOCODING_MIN_INTERVAL:PT1S}
|
||||
|
||||
# Поиск по объявлениям (PostSearchService)
|
||||
search:
|
||||
typo-threshold: 0.3
|
||||
|
||||
Reference in New Issue
Block a user