Skip to main content

Module time_travel_api

Module time_travel_api 

Source
Expand description

Time-travel runtime API mirrored from the admin server onto the main HTTP port Time-travel runtime API for hosted-mock deployments.

Time-travel routes existed on the admin server (port 9080) via mockforge-ui::time_travel_handlers. Hosted-mock Fly machines only expose port 3000 publicly, so the admin server’s routes were unreachable from outside the container — operators couldn’t set or advance virtual time on a deployed mock without redeploying.

This module mirrors the same surface on the main HTTP app. Handlers talk to a local OnceLock<Arc<TimeTravelManager>>; serve.rs initialises it alongside the existing admin-server init so both paths see the same manager (the inner Arc is shared).

§Endpoints (mounted under /__mockforge/time-travel)

  • `GET /status → current clock status
  • `POST /enable → start virtual clock at given time
  • `POST /disable → stop virtual clock
  • `POST /advance → advance virtual time by a duration
  • `POST /set → set virtual time to a specific instant
  • `POST /scale → set time scale factor (e.g., 60.0 = 1min/sec)
  • `POST /reset → reset to real time

Scheduled responses, scenarios, and cron jobs are intentionally not mirrored here — they’re only useful from the admin UI flow that already exists, and adding them here would more than double the surface area for a marginal gain.

Functions§

init_time_travel_manager
Register a TimeTravelManager for use by the HTTP-port time-travel API. Idempotent — subsequent calls are no-ops.
time_travel_router
Build the time-travel runtime router. Mount under /__mockforge/time-travel.