PhoenixKit.Modules.Storage.LibraryState (phoenix_kit v2.52.2)

Copy Markdown View Source

What is going on with each library's storage, derived — never stored — from two things: how many of its files are out of date (PhoenixKit.Modules.Storage.Reconciler.counts_by_library/0, one grouped query) and its storage.reconcile run (PhoenixKit.Modules.Storage.Jobs.Reconcile, dev_docs/plans/2026-10-03-job-runs.md §6.3, R8).

statewhen
:pausedits reconcile run is paused (or pausing)
:syncinga reconcile run is queued or running — "N files left"
:attentionno run is active, and either its last run failed with files left, or the reconciler tried files and could not finish them (they wait out their retry window)
:waitingfiles are out of date and no run is active: the queue is down, or nothing has triggered yet — the case a global count hides
:up_to_datenothing is out of date

"Up to date" means the files carry the revisions of their library's profile and variant set. It does not prove every recorded object is still on its bucket; that is what a later storage.verify is for (§6.4).

The map returned for a library:

%{state: :syncing, out_of_date: 12, eligible: 12, failing: 0, run: %Run{}}

run is the active run when there is one, else the last one, else nil.

Summary

Functions

The state of each of library_uuids, as a map keyed by the uuid string: three queries however many libraries (the counts, the active runs, the last runs).

The state of one library.

The kind whose runs this state is about.

Types

state()

@type state() :: :up_to_date | :syncing | :paused | :attention | :waiting

t()

@type t() :: %{
  state: state(),
  out_of_date: non_neg_integer(),
  eligible: non_neg_integer(),
  failing: non_neg_integer(),
  run: PhoenixKit.Jobs.Run.t() | nil
}

Functions

for_libraries(library_uuids)

@spec for_libraries([String.t()]) :: %{required(String.t()) => t()}

The state of each of library_uuids, as a map keyed by the uuid string: three queries however many libraries (the counts, the active runs, the last runs).

for_library(library_uuid)

@spec for_library(String.t()) :: t()

The state of one library.

kind()

@spec kind() :: String.t()

The kind whose runs this state is about.