Skip to main content

Module usage

Module usage 

Source
Expand description

LeanCTX Cloud usage (GET /v1/usage): how far each quota of the workspace is used, so this machine warns at 80 % instead of meeting a refusal.

Read only from a server that announced the usage capability (FEATURE_USAGE, cached by crate::session_ref); an older server gets no request and nothing here prints anything.

  • lean-ctx cloud status shows every quota as “used of limit” (GiB for bytes, $ for model credit, counts otherwise), warn and full marked with the service’s next step (status_lines).
  • The background sync reads it at most every REFRESH_EVERY and logs one line when a quota rises to warn or full (rises); the states it last logged are kept in <data>/usage.json, so neither the next tick nor a restart repeats the line.

Structs§

UsageRead
A usage answer and when it was read.

Constants§

FEATURE_USAGE
The features entry of a server that serves GET /v1/usage.
REFRESH_EVERY
How often the background sync asks (a status asks every time).

Functions§

announced
Whether the enrolled server announced usage when last asked.
fetch
Read GET /v1/usage; None without the capability (no request).
quota_line
One quota: storage 34 GiB of 40 GiB · warn (85 %); <next step>.
read
The usage for a reader (lean-ctx cloud status, cloud usage --json): read now, else the last answer of this server. None when the server did not announce usage (no request is sent).
rise_line
The log line of a quota that reached warn or full, worded like the refusal it comes before.
rises
One line per quota now at warn or full whose state was lower when last seen (seen): a state change, never a repeat. A quota that falls back and rises again is said again.
status
The Usage: lines of lean-ctx cloud status: read now when the server announced usage (the last answer, dated, when that fails); nothing at all without the capability.
status_lines
The status lines of usage; as_of dates an answer that was not read just now.