A lightweight FastAPI microservice that resolves location queries via geocoding providers.
155
A lightweight FastAPI microservice that resolves location queries via geocoding providers. Designed for LLM agent tool-calling with bounded rate limiting and queueing built in.
cp .env.example .env
# Edit .env: set PROVIDER and API_KEY
docker compose up -d
# Health check
curl http://localhost:8000/health
# → {"status":"ok"}
# Resolve a location
curl "http://localhost:8000/resolve?query=Paris"
# → {"formattedAddress":"Paris, France","latitude":48.85...,"longitude":2.34...}
| Variable | Default | Description |
|---|---|---|
PORT | 8000 | HTTP port |
PROVIDER | opencage | nominatim or opencage |
API_KEY | — | OpenCage API key |
GLOBAL_RATE_LIMIT | 1 | Requests/sec to the provider |
MAX_QUEUE_SIZE | 10 | Max queued requests (beyond this → 503) |
CONFIDENCE_THRESHOLD | 0.7 | Min confidence for results |
services:
location-resolver:
image: tamanois/location-resolver:latest
ports:
- "8000:8000"
restart: unless-stopped
env_file:
- .env
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
User-Agent header.Requests are processed one-at-a-time at GLOBAL_RATE_LIMIT per second. Additional requests are queued in a bounded FIFO queue (up to MAX_QUEUE_SIZE). When full, new requests receive HTTP 503.
~350 MB — based on python:3.10-slim, installs only FastAPI + uvicorn + requests.
Content type
Image
Digest
sha256:f6d2830c9…
Size
60.1 MB
Last updated
3 months ago
docker pull tamanois/location-resolver