Skip to content

Commit e07080d

Browse files
authored
chore(docs): flights provider documentation (#1341)
* chore(docs): flights provider documentation * chore(docs): fix typo and cross-link to operations configfile
1 parent fa20669 commit e07080d

File tree

5 files changed

+101
-3
lines changed

5 files changed

+101
-3
lines changed

book.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[book]
22
authors = ["Mozilla Content Discovery Services"]
33
language = "en"
4-
multilingual = false
54
src = "docs"
65
title = "Merino Book"
76

docs/SUMMARY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
- [Unit Tests](./testing/unit-tests.md)
2222
- [Integration Tests](./testing/integration-tests.md)
2323
- [Load Tests](./testing/load-tests.md)
24+
- [Providers](./providers/index.md)
25+
- [Flights](./providers/flights.md)
2426
- [Operations](./operations/index.md)
2527
- [Rollback](./operations/rollback.md)
2628
- [Modify Navigational Suggestions Blocklist](./operations/blocklist-nav-suggestions.md)
@@ -34,8 +36,8 @@
3436
- [Remote Settings CSV Uploader](./operations/jobs/csv-remote-settings.md)
3537
- [Geonames Uploader](./operations/jobs/geonames-uploader.md)
3638

37-
3839
# ADR
40+
3941
- [Archive](./adr/index.md)
4042
- [Load Test Framework: Locust VS K6](./adr/0001-locust-vs-k6-merino-py-performance-test-framework.md)
4143
- [General API Response](./adr/0002-merino-general-response.md)

docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This page describes the API endpoints available on Merino.
44

5-
The autogenerated API documentation exists [here](https://merinopy.services.mozilla.com).
5+
The autogenerated API documentation exists [here](https://merino.services.mozilla.com/docs).

docs/providers/flights.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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.

docs/providers/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Providers
2+
3+
Providers return suggestions for queries. By default, each query to the `/suggest` endpoint is dispatched asynchronously to every enabled provider. The `providers` query param can be used to specify which providers should serve the request. The provider determines whether the query is relevant to its domain and responds appropriately.
4+
5+
The `/providers` endpoint provides a list of available providers. See [the API docs](https://merino.services.mozilla.com/docs#/providers) for more information.
6+
7+
Provider documentation:
8+
9+
- [Flights](./flights.md)
10+
- Finance (stocks)
11+
- Sports
12+
- Weather
13+
- ADM (sponsored content)
14+
- AMO (Addons)
15+
- Wikipedia
16+
- Top Picks

0 commit comments

Comments
 (0)