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
| File | Role |
|---|---|
wiregrid.lfe | The usual API: lifecycle, subscriptions, publish, direct delivery, rooms, presence, signals, receipts, storage, cache, health, drain, shutdown |
wiregrid_macros.lfe | Compile-time helpers for fixed topics, targets, publishers, subscription sets, workers, and command handlers. Generated functions call wiregrid_api |
wiregrid_fast.lfe | Prepared and grouped operations |
wiregrid_mailbox.lfe | One 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.lfe | Worker processes with off-heap queues and hard batch limits. The adaptive worker inspects its own mailbox after the first delivery |
wiregrid_lane.lfe | Order inside a key (a session or a topic) while other keys run, under a hard lane cap |
wiregrid_coalesce.lfe | Drops superseded ephemeral work inside one batch. Durable deliveries are kept |
wiregrid_kernel.lfe, wiregrid_selector.lfe | Route or drop from envelope metadata before the payload is decoded |
wiregrid_pipeline.lfe | Decode-once handler pipelines |
wiregrid_fold.lfe | Stateful bounded folds |
wiregrid_stream.lfe | Chunk 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:
wiregrid_actor.lfeis a session-bound convenience API. It caches no permissions. Publish helpers injectsession_idand reject a caller-supplied override.wiregrid_policy.lfeis pure helpers for macro-compiled authorizers. It does not call back into Wiregrid, so an authorizer cannot deadlock the control plane.wiregrid_flow.lfecomposes coalesce and lanes. Durable envelopes are not coalesced.wiregrid_plan.lfekeeps a dispatch plan with its target set and recompiles once if an instance restart invalidates the plan.wiregrid_projection.lfeis the LFE face of commit-before-ack projections implemented inWiregrid.Consumer.wiregrid_router.lferoutes on envelope metadata and decodes after a route is chosen.handle-event/4does not ack by itself.wiregrid_transport.lfereads the sanitized command-handler context (instance,session_id,user_id).
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.