Skip to content

Add topics — topic-based pub/sub for Gleam#256

Open
manelsen wants to merge 1 commit into
gleam-lang:mainfrom
manelsen:add-topics
Open

Add topics — topic-based pub/sub for Gleam#256
manelsen wants to merge 1 commit into
gleam-lang:mainfrom
manelsen:add-topics

Conversation

@manelsen

Copy link
Copy Markdown

topics

Topic-based publish/subscribe for Gleam with automatic dead subscriber cleanup.

  • Generic message type: PubSub(msg) works with any Gleam type
  • Dead subscriber auto-pruning on subscribe, broadcast, and count
  • Ghost topic cleanup: list_topics excludes empty topics
  • Idempotent subscribe: duplicate subscriptions are no-ops
  • Supervisor-ready via start_linked()
  • 13 tests, CI, full docs

Links:

Category: Erlang and OTP (actor-based registry pattern, similar to chip)

@lpil

lpil commented Apr 29, 2026

Copy link
Copy Markdown
Member

Thank you, but this library has similar issues to the other one, which I provided feedback for here: #257

In OTP cleanup is performed using monitors. Worth reading up on those and looking at the source for existing pubsub systems to see how it is done.

The actor based design is slow, especially since the actor is the one that sends the messages. This is likely to become a bottleneck and cause performance problems, or crashes with how the timeouts are fixed. A design that minimises the amount of work that the actor does would be better, with regular access going via an ETS table with concurrent reads enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants