Botica.Flags.Persistence.Writer (Botica v2.2.0)

Copy Markdown View Source

Serializes persistence writes to the configured adapter.

The Botica.Flags.Store GenServer delegates every mutation to this writer via cast, so disk writes happen strictly one at a time in mailbox order. This avoids read-modify-write races between concurrent flag mutations (two writes reading the same file and one overwriting the other).

The writer is deliberately NOT linked to the Store: a slow disk must never crash the flags registry. Errors are logged, not raised.

Supervision

Started by Botica.Application after the Store. If the Store is restarted, the writer keeps its queue — writes are idempotent against the adapter.

Summary

Functions

Returns a specification to start this module under a supervisor.

Enqueues a flag deletion. Returns :ok immediately.

Number of pending writes in the mailbox queue (diagnostics).

Enqueues a flag save. Returns :ok immediately; the write happens asynchronously in mailbox order.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

delete(name)

@spec delete(atom()) :: :ok

Enqueues a flag deletion. Returns :ok immediately.

pending()

@spec pending() :: non_neg_integer()

Number of pending writes in the mailbox queue (diagnostics).

save(flag)

@spec save(Botica.Flags.Flag.t()) :: :ok

Enqueues a flag save. Returns :ok immediately; the write happens asynchronously in mailbox order.