ForgeOpsTracker.DeliveryQueue (forge_ops_tracker v0.1.0)

Copy Markdown View Source

A small bounded queue, processed one event at a time, so delivery never blocks the caller that raised the error. The BEAM equivalent of the Ruby/Python/Java clients' own background-thread- backed queue -- except here the "queue manager" is an ordinary supervised GenServer (started once, see ForgeOpsTracker.Application, not spun up lazily on first push, since BEAM processes are cheap enough that there's no meaningful cost to keeping one alive idle) and each actual delivery runs in its own short-lived Task, not inline in the GenServer's own callback.

That split matters, confirmed directly (not a hypothetical): a GenServer that calls a slow, blocking operation (:httpc.request, here) directly from inside handle_info cannot process any other message -- including a push from another process, or even :sys.get_state -- until that call returns, because a GenServer only ever handles one message at a time. Doing the actual HTTP call in a separate Task instead keeps this GenServer responsive to new pushes the whole time a delivery is in flight, while handle_info(:delivery_done, ...) below still enforces the same one-delivery-at-a-time ordering every other client's own queue has.

Bounded via Configuration.queue_size (:queue has no size limit of its own, so this tracks the length itself) -- a burst of exceptions must never apply backpressure to the host app by growing this queue without limit.

Summary

Functions

Returns a specification to start this module under a supervisor.

Enqueues payload for delivery. Always returns :ok -- a full queue drops the payload (logged via Configuration.logger) rather than raising or blocking the caller.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

push(payload)

@spec push(map()) :: :ok

Enqueues payload for delivery. Always returns :ok -- a full queue drops the payload (logged via Configuration.logger) rather than raising or blocking the caller.