glixir/pubsub

PubSub support for distributed messaging

This module provides a Gleam-friendly interface to Phoenix.PubSub, using our Elixir helper module for clean data conversion.

Types

Opaque type representing a PubSub system

pub opaque type PubSub
pub type PubSubBroadcastResult {
  PubsubBroadcastOk
  PubsubBroadcastError(reason: dynamic.Dynamic)
}

Constructors

Errors from PubSub operations

pub type PubSubError {
  StartError(reason: String)
  SubscribeError(reason: String)
  BroadcastError(reason: String)
  UnsubscribeError(reason: String)
}

Constructors

  • StartError(reason: String)
  • SubscribeError(reason: String)
  • BroadcastError(reason: String)
  • UnsubscribeError(reason: String)
pub type PubSubStartResult {
  PubsubStartOk(pid: process.Pid)
  PubsubStartError(reason: dynamic.Dynamic)
}

Constructors

pub type PubSubSubscribeResult {
  PubsubSubscribeOk
  PubsubSubscribeError(reason: dynamic.Dynamic)
}

Constructors

pub type PubSubUnsubscribeResult {
  PubsubUnsubscribeOk
  PubsubUnsubscribeError(reason: dynamic.Dynamic)
}

Constructors

Values

pub fn broadcast(
  pubsub_name: String,
  topic: String,
  message: dynamic.Dynamic,
) -> Result(Nil, PubSubError)

Broadcast a message to all subscribers of a topic

pub fn start_pubsub(name: String) -> Result(PubSub, PubSubError)

Start a new PubSub system with the given name

pub fn subscribe(
  pubsub_name: String,
  topic: String,
) -> Result(Nil, PubSubError)

Subscribe the current process to a topic

pub fn unsubscribe(
  pubsub_name: String,
  topic: String,
) -> Result(Nil, PubSubError)

Unsubscribe the current process from a topic

Search Document