|
| 1 | +# Flight Status Provider |
| 2 | + |
| 3 | +Handles flight status queries from the Firefox address bar. If the sanitized query matches a flight number in a GCS-sourced manifest, respond with flight details from a Redis cache, or live AeroAPI (FlightAware) calls on cache miss. This provider is fronted by a circuit breaker. |
| 4 | + |
| 5 | +## Request Flow |
| 6 | + |
| 7 | +```mermaid |
| 8 | +sequenceDiagram |
| 9 | + actor Firefox |
| 10 | + participant Merino |
| 11 | + participant GCS |
| 12 | + participant Redis |
| 13 | + participant AeroAPI as AeroAPI (FlightAware) |
| 14 | +
|
| 15 | + Firefox->>Merino: GET /api/v1/suggest?q=ac 100 |
| 16 | +
|
| 17 | + alt Flight number not in manifest |
| 18 | + Merino-->>Firefox: { suggestions: [] } |
| 19 | + else Flight number in manifest |
| 20 | + Merino->>Redis: Look up flight status |
| 21 | +
|
| 22 | + alt Cached |
| 23 | + Redis-->>Merino: Flight data |
| 24 | + else Not cached |
| 25 | + Redis-->>Merino: (miss) |
| 26 | + Merino->>AeroAPI: GET /flights/AC100 |
| 27 | + AeroAPI-->>Merino: Flight data |
| 28 | + Merino->>Redis: Store flight data |
| 29 | + end |
| 30 | +
|
| 31 | + Merino-->>Firefox: { suggestions: [{provider: "flightaware", ...}] } |
| 32 | + end |
| 33 | +``` |
| 34 | + |
| 35 | +## Flight Numbers Manifest Sync |
| 36 | + |
| 37 | +Flight numbers are loaded into memory from GCS on app startup and refreshed periodically (see [config](../operations/configs.md#general)). This is an append-only manifest which contains all flight numbers that have been synced via the scheduled flight numbers ingestion job. |
| 38 | + |
| 39 | +```mermaid |
| 40 | +sequenceDiagram |
| 41 | + participant Merino |
| 42 | + participant GCS |
| 43 | +
|
| 44 | + Note over Merino: App startup |
| 45 | + Merino->>GCS: Fetch flight number manifest |
| 46 | + GCS-->>Merino: list of valid flight numbers |
| 47 | + Note over Merino: Stores manifest in memory |
| 48 | +
|
| 49 | + loop Periodic refresh |
| 50 | + Merino->>GCS: Fetch flight number manifest |
| 51 | + GCS-->>Merino: list of valid flight numbers |
| 52 | + Note over Merino: Updates in-memory manifest |
| 53 | + end |
| 54 | +``` |
| 55 | + |
| 56 | +## Flight Numbers Ingestion Job (Manifest update) |
| 57 | + |
| 58 | +This ingest job fetches flight numbers for scheduled flights from AeroAPI every 6 hours, and adds them to the existing flight numbers manifest(s) in GCS. Currently two copies of the manifests are stored in separate buckets as part of ongoing GCP v2 migration. |
| 59 | + |
| 60 | +The job scheduling and invocation is handled by Airflow (see [dags](https://github.com/mozilla/telemetry-airflow/blob/main/dags/merino_jobs.py) here). |
| 61 | + |
| 62 | +```mermaid |
| 63 | +sequenceDiagram |
| 64 | + participant Job as fetch_flights Job |
| 65 | + participant AeroAPI as AeroAPI (FlightAware) |
| 66 | + participant GCS |
| 67 | +
|
| 68 | + loop Every 6 hours |
| 69 | + Job->>AeroAPI: GET scheduled flights |
| 70 | + AeroAPI-->>Job: Page of scheduled flights |
| 71 | + end |
| 72 | +
|
| 73 | + Job->>GCS: Download existing flight_numbers_latest.json |
| 74 | + GCS-->>Job: Existing flight number list |
| 75 | +
|
| 76 | + Note over Job: Merge new + existing (union) |
| 77 | +
|
| 78 | + Job->>GCS: Upload flight_numbers_latest.json (×2 buckets) |
| 79 | +``` |
| 80 | + |
| 81 | +Note that the job can be configured to store the manifest in Redis by setting `settings.flightaware.storage` (resolves to `MERINO_FLIGHTAWARE__STORAGE` env var) to `redis`. However, the provider is only configured to fetch the manifest from GCS. |
0 commit comments