Wiregrid Plainwire · Manual 1.0

Gleam

Gleam bindings

bindings/gleam targets Erlang and calls wiregrid_api. There is no Gleam runtime and no second copy of session state. Closed types cover topics, targets, presence, signals, delivery class, profiles, prepared handles, dispatch plans, and actors. Event bodies and metadata stay Dynamic, because Wiregrid does not own the product schema.

./scripts/check-gleam.sh

CI pins Gleam 1.18.1. WIREGRID_REQUIRE_GLEAM=1 makes a missing compiler fail the check.

Types

pub type Topic {
  User(String)
  Channel(String)
  Thread(String)
  Room(String)
  Game(String)
  Document(String)
  Custom(String, String)
}

pub type DeliveryClass { Durable Ephemeral }
pub type Profile { Small Balanced Large }
pub type Presence { Online Idle Dnd Invisible Offline CustomPresence(String) }

Signal is Ring, Accept, Decline, Cancel, Offer, Answer, IceCandidate, Leave, Reconnect, Membership. Target is TopicTarget, RoomTarget, UserTarget, or SessionTarget. FanoutStats carries sent, dropped, evicted, gone, excluded, overloaded. AckStats carries acked, unknown, pending. PresenceSnapshot carries status, session count, metadata, and updated_at_ms. ReplayStats carries delivered, dropped, complete_page, cursors, and stopped. Actor is instance, session_id, and user_id.

Calls

Discovery: version, protocol_version, foreign_protocol_version, c_abi_major, capabilities, describe. Start with start_instance or start_profile(name, Balanced). Connect with connect, connect_encoded (delivery format encoded), connect_resumable, connect_resumable_encoded, and resume_session. Actor forms are connect_actor, connect_resumable_actor, and resume_actor.

Routing covers subscribe, unsubscribe, the many-forms, sync_subscriptions, sync_topology, prepare, publish, publish_class, publish_prepared, batch and multi-topic publish, room publish, user and session sends, dispatch, dispatch_prepared, compile_dispatch, and dispatch_plan. Actor helpers (actor_publish, actor_subscribe, actor_set_presence, actor_join_room, actor_ack, and the rest) inject the actor session through the Erlang FFI so the session id cannot be omitted by accident. They do not cache permissions.

ack and ack_many return results you can decode with ack_stats. fanout_stats decodes a publish result. replay_session is the bounded replay primitive. replay_session_with_options takes an explicit cursor, page size, class, or delivery topic.

An encoded session keeps codec bytes on the envelope. Decode when the consumer has decided to handle the event. That is the same delivery_format: :encoded option the Elixir connect/4 accepts.

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