• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rm-hull / next-departures-api / 25461678005

06 May 2026 09:17PM UTC coverage: 28.278% (+0.2%) from 28.031%
25461678005

push

github

web-flow
feat: add Traveline fallback for SIRI rate limits (#14)

Implement a fallback mechanism to fetch bus departures from Traveline
when the primary SIRI API exceeds its usage limits. This ensures service
availability even after the daily TransportAPI quota is exhausted.

-   Introduces `FallbackManager` to track rate-limit state.
- Adds `TravelineClient` to scrape live departures from the Traveline
website.
- Includes a daily **CRON** job to reset the fallback state at midnight.
-   Updates `NextDepartures` route to automatically switch providers.

Fixes #12 

```mermaid
sequenceDiagram
    participant User
    participant API as API Server
    participant SIRI as SIRI API
    participant FM as Fallback Manager
    participant TVL as Traveline

    User->>API: GET /v1/next-departures/:id
    API->>FM: IsSiriRateLimited?
    alt No
        API->>SIRI: Request departures
        alt Success
            SIRI-->>API: Departure data
        else Rate Limited (429/403)
            SIRI-->>API: Limit Exceeded
            API->>FM: SetSiriRateLimited(true)
            API->>TVL: Scrape departures
            TVL-->>API: Fallback data
        end
    else Yes
        API->>TVL: Scrape departures
        TVL-->>API: Fallback data
    end
    API-->>User: JSON Response
```

50 of 142 new or added lines in 5 files covered. (35.21%)

317 of 1121 relevant lines covered (28.28%)

0.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/api_server.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc