OTP ERLANG Wiregrid Plainwire · Manual 1.0

LFE

LFE bindings

LFE is optional. Elixir and Erlang own sessions, ETS, resume tokens, storage rules, authorization, and delivery reservations. LFE calls wiregrid_api. The node boots with no LFE compiler installed. Compile the bindings with mix wiregrid.lfe.compile or ./scripts/check-lfe.sh. Release builds that require LFE should set WIREGRID_REQUIRE_LFE=1. CI builds LFE 2.2.2.

The sources are split by job. A lane that preserves per-key order has different failure rules from a coalesce step that may drop superseded typing events, and both differ from a macro that emits fixed topic constructors. One module would hide those rules.

Modules

FileRole
wiregrid.lfeThe usual API: lifecycle, subscriptions, publish, direct delivery, rooms, presence, signals, receipts, storage, cache, health, drain, shutdown
wiregrid_macros.lfeCompile-time helpers for fixed topics, targets, publishers, subscription sets, workers, and command handlers. Generated functions call wiregrid_api
wiregrid_fast.lfePrepared and grouped operations
wiregrid_mailbox.lfeOne bounded burst from the worker’s own mailbox. The collect wait is bounded. It does not scan another process
wiregrid_worker.lfe, wiregrid_batch_worker.lfe, wiregrid_adaptive_worker.lfeWorker processes with off-heap queues and hard batch limits. The adaptive worker inspects its own mailbox after the first delivery
wiregrid_lane.lfeOrder inside a key (a session or a topic) while other keys run, under a hard lane cap
wiregrid_coalesce.lfeDrops superseded ephemeral work inside one batch. Durable deliveries are kept
wiregrid_kernel.lfe, wiregrid_selector.lfeRoute or drop from envelope metadata before the payload is decoded
wiregrid_pipeline.lfeDecode-once handler pipelines
wiregrid_fold.lfeStateful bounded folds
wiregrid_stream.lfeChunk orchestration when the caller has more work than one public batch

None of these modules keep a second queue of record. Delivery ids still come from Wiregrid. Successful work is acknowledged through Wiregrid. Unprocessed deliveries stay reserved.

Further modules in the same directory stay on that boundary:

Prepared publish

(case (wiregrid:prepare 'chat event)
  ((tuple 'ok prepared)
    (wiregrid:publish-topics-prepared
      'chat
      (list (wiregrid:topic-channel #"general")
            (wiregrid:topic-document #"activity"))
      prepared)))

For topology known at compile time, wiregrid_macros can emit ordinary functions with the topic terms baked in. wiregrid:replay-session/3,4 reads one storage page and redelivers it under the same authorization and backpressure rules. The resume cursor advances only past rows delivery accepted.

Use lanes when order matters inside one key. Use coalesce for ephemeral typing or cursor updates inside the current batch. If the hot path is database latency, an LFE mailbox loop will not shorten that wait. Profile first, and keep an ordinary Elixir consumer when it is fast enough.

Wiregrid 1.0 · Plainwire · github.com/Plainwire-development/Wiregrid