Services.BgIndexingControl (fnord v0.9.29)
View SourceSession-local (per BEAM node) control plane for pausing background indexing on a per-model basis.
Why this exists
Background indexing is a convenience feature. When OpenAI starts returning throttling responses (HTTP 429 with a recognized throttling code), we can disable background indexing for the affected model(s) to reduce load.
This module is intentionally:
- model-agnostic: any model string encountered can be tracked
- boolean-only: models are either paused or not paused (no timers)
- session-local: state is stored in
Services.Globalsand seeded idempotently
State
Stored in Services.Globals under the :fnord app:
:bg_indexer_paused_models=>%{model => true}:bg_indexer_throttle_counts=>%{model => consecutive_throttles}:bg_indexer_throttle_threshold=> integer (default: 3)
Summary
Functions
Reset the consecutive throttling count for the model back to 0.
Increment the consecutive throttling count for the model.
Functions
@spec clear_pause(binary() | nil) :: :ok
@spec ensure_init() :: :ok
@spec note_success(binary() | nil) :: :ok
Reset the consecutive throttling count for the model back to 0.
Returns :ok and ignores nil models.
@spec note_throttle(binary() | nil) :: :ok
Increment the consecutive throttling count for the model.
If the count reaches the configured threshold, the model is paused.
Returns :ok and ignores nil models.
@spec pause(binary() | nil) :: :ok
@spec set_threshold(non_neg_integer()) :: :ok
@spec threshold() :: non_neg_integer()