I’m looking for a tiny PubSub to embed with my Erlang app.
Plenty are available (erlbus, erlroute, …) but none of them comes without dependencies.
Speed isn’t important for me. Appreciate your help.
Could you expand a little on what your requirements are? Thanks!
@lpil The PubSub
should support basic operations. Minimum requirements are:
create(Topic). %% optional
subcribe(Topic). %% mandatory
unsubcribe(Topic). %% mandatory
publish(Topic, Msg). %% mandatory
and anything else is a plus (i don’t even need persistency to disk, etc.).
Subscribing to a non-existing Topic
could potentially call create(Topic)
.
The historical goto in this space has been gproc
https://github.com/uwiger/gproc/wiki/Publish-subscribe-with-gproc
Judging by the looks of erlbus
and erlroute
you’re looking for an in-app, process-based pubsub mechanism, rather than an MQTT implementation or something, right?
If so, gproc
is very mature and you can either use the gproc
primitives to roll your own simple pubsub, or use the built-in patterns in the included gproc_ps
module - but that does have rebar.config
deps
on edown
and gen_leader
.
syn
doesn’t have any dependencies (in rebar.config
/deps
at least) and has a really neat, simple interface that lets you do really nice stuff with dynamic process group membership.
I’m kind of a syn
fanboy so you might want to investigate for yourself, but it’s made several projects enormously easier for me, in cases where i’ve had a few message-producer processes directing the behaviour of tens of thousands of short- and long-lived consumer processes, addressed as multiple groups through transient membership of syn
groups. Simple, neat & flexible.
@LeonardB thanks for gproc
which we’ve already checked. But it has a dependency gen_leader_revival.git
:
In zotonic we have a simple embeddable mqtt v5 server.
We also have an embeddable router with wildcards which you can use for a very simple diy pub/sub solution.
The router can be used for different use-cases. FYI. We implemented a proof of concept dispatcher for cowboy with it, but decided to go for a different approach there.
Don’t forget pg too. It doesn’t have publish
but that’s trivially implementable using get_members
/ get_local_members
.
This is pub-sub and has no dependency.
It is far from optimized/complete but implements DDS interoperability protocol RTPS. It has been developed to be used in ROS2 networks.
If you want to check it out: