Expand description
The operator console for id_effect services: live fibers, supervision trees, metrics, health
and the log level, behind an id_effect_authz guard.
§The API
Console collects what the console shows and Console::router turns it into an Axum
router answering JSON under API_PREFIX (/_console/api) and the dashboard page at
/_console:
| Route | Answers |
|---|---|
GET fibers | every live fiber (FiberView, from core fiber_dump, feature fiber-registry) |
GET supervisors | the registered supervision trees (SupervisorsView, from which_children) |
GET metrics | the metric registry and the runtime fiber gauges (MetricView) |
GET health | the HealthRegistry report (always 200) |
GET log-level | the reloadable EnvFilter and the EffectLogger minimum (LogLevelView) |
PUT log-level | changes both without a restart (LogLevelChange) |
GET jobs | per-queue counts and the newest jobs of a job queue (JobsView, feature jobs) |
POST jobs/{id}/retry | a dead or cancelled job runs again now (JobView; 404 unknown id, 409 other state) |
POST jobs/{id}/cancel | a scheduled or failed job is cancelled (JobView; 404 unknown id, 409 other state) |
The two POST routes require Content-Type: application/json (415 otherwise), so a
cross-site form cannot trigger them.
§The dashboard
The same router serves GET /_console: one static page (inline CSS and vanilla JavaScript,
compiled in with include_str!, no build step and nothing loaded from another origin) that
polls the API and shows the health checks, the log level with a form that changes it, the
supervision trees, the job queues (when the jobs feature and a queue are configured, with a
retry button on dead and cancelled jobs and a cancel button on scheduled and failed ones), the
live fibers and the metrics. It is behind the same guard as the API.
§Security model
There is no unguarded constructor: the only way to get the routes is
Console::router, which takes an authorization Guard and puts it
in front of every console route and the console router’s fallback, so a principal the
guard denies learns nothing about the API (401 anonymous, 403 otherwise, Problem Details
body). The authentication layer that sets the principal runs outside the guard
(Router::layer on the merged app), as for any id_effect_authz route. Console answers carry
Cache-Control: no-store.
ConsoleConfig is where the console listens. Bound to a loopback address it serves the local
machine only; on any other address ConsoleConfig::requires_guard is true: the guard must then
restrict the console to operators (a role or permission policy), while a loopback console may
use a lenient one such as authenticated(). The guard is required either way. On the
console’s own listener, ConsoleConfig::check_host_and_origin also answers 403 to a
request for another host or from another origin (DNS rebinding, cross-site posts; see
Host and Origin), by default allowing the bind address only.
use std::net::{Ipv6Addr, SocketAddr};
use id_effect_authz::{Guard, require_role};
use id_effect_console::{Console, ConsoleConfig};
let config = ConsoleConfig::new(SocketAddr::from((Ipv6Addr::LOCALHOST, 9090)));
assert!(!config.requires_guard());
let console: axum::Router = Console::new().router(Guard::new("console", require_role("operator")));Tier platform (ADR 0010 Amendment 6): the Ledger reference app under
examples/reference/ depends on it.
Structs§
- Console
- What the console shows, built up then turned into its guarded routes by
Console::router. - Console
Config - Where the console listens, and the host names it answers to.
- Fiber
View - One live fiber, as
GET /_console/api/fiberslists it (by ascending id). - JobView
- One job, without its payload (which may carry personal data).
- Jobs
View - What
GET /_console/api/jobsanswers. - LogLevel
Change - The body of
PUT /_console/api/log-level: at least one field. - LogLevel
View - The log level in force, as
GET /_console/api/log-levelanswers it. - Metric
View - One metric series, as
GET /_console/api/metricslists it: the registry’s series sorted by name, kind and tags, then the runtime’sid_effect_fibers_liveandid_effect_fibers_started_total. - Queue
View - One queue’s counts.
- Supervisors
View - What
GET /_console/api/supervisorsanswers. - Unreachable
Supervisor - A registered supervisor that did not answer.
Constants§
- API_
PREFIX - Where the console API is mounted: every route is
/_console/api/<name>.
Type Aliases§
- EnvFilter
Handle - The reload handle of an
EnvFilterlayered directly on aRegistry: whatid_effect_opentelemetry’sOtelStarterGuard::env_filterreturns, or whattracing_subscriber::reload::Layer::new(filter)gives an app that builds its own subscriber.