SuperPi.Durable.DeferredFlusher (super_pi v0.1.0)

Copy Markdown View Source

Implements pi-durable deferred commit batching (REQ-DUR-04, REQ-DUR-05).

Streaming partial tokens and tool stdout commit to :ets every 100ms so UI watchers see instant updates, and flush to SQLite/PostgreSQL lazily within 1000ms or piggyback on the next immediate commit.

Summary

Functions

Returns a specification to start this module under a supervisor.

Flushes all pending deferred ETS updates to Ecto immediately (REQ-DUR-05). Safe to call inside or outside an existing Ecto transaction.

Stages a deferred document update in ETS immediately (100ms memory path) and schedules a lazy database flush within persist_within_ms (default 1000ms).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

ensure_pending_ets!()

flush_now!()

Flushes all pending deferred ETS updates to Ecto immediately (REQ-DUR-05). Safe to call inside or outside an existing Ecto transaction.

pending_count()

stage_deferred(scope_kind, scope_id, kind, value, key \\ "")

Stages a deferred document update in ETS immediately (100ms memory path) and schedules a lazy database flush within persist_within_ms (default 1000ms).

start_link(opts \\ [])