First rule of developers' club: never implement your own IPC/RPC message bus.

Second rule of developers' club: see rule number one, specially if you are doing embedded development.

Do you need async method calls, and event notifications? There's something that already comes with your GNU/Linux base system: D-Bus.

I get it, D-Bus does not have good marketing and doesn't look “enterprisey” enough, but for some reason it has worse reputation than it should, supports many rich IPC/RPC patterns, and it's definitely faster than one may think. Do you need extra speed? Pass a file descriptor to a buffer over the bus, let the other process memory-map it.

Show thread

Does D-Bus sound too punk for you and your boss doesn't want anything to do with FLOSS neckbeards? Well, there's gRPC: “if it's good enough for Google, surely is for us”. Also: Apache Thrift.

Do you need something tiny for a hard embedded system? Well, there's eRPC (Embedded RPC).

Do you want something a bit more exotic, kind of small, which plays extremely well with C, and somewhat cute? There's 9P!

Show thread

Will you mostly share around big chunks of memory which must be mapped around in different processes in the same machine and have some degree of coordination and resource management? Use Wayland by writing your own extension protocols on top.

Fun fact: Wayland is not a graphics system, it's a protocol designed to pass and share “resources” around. Usually memory buffers containing pixel data, but the contents could be anything. The “server” (compositor) does not even need to talk to the GPU!

Show thread

Seriously, in general your first pit stop should be D-Bus. It just works. Also if you use systemd, most likely it's already in your system. GLib has a client implementation which integrates well with a GMainLoop.

Also: if you don't want/need to expose things in the system or session bus, only coordinate two processes, GLib has also a server which can be exposed over Unix sockets, TCP sockets, or a socketpair(3)… You can have a full-fledged RPC private bus between your processes!

Show thread
Follow

Okay, I know what some will say you: some may not like GLib or D-Bus, or maybe can't use them because $REASONS, and/or maybe you want something smaller with less dependencies…

Did you know that OpenWRT has a small message bus which has been seriously battle tested? Enter ubus: openwrt.org/docs/techref/ubus

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!