Tofu — Asynchronous Messaging for Boring Systems

I built a messaging system in 2008. C++ first. Then C#.

It ran for years in production:

  • Basic IPC
  • Complex data transfers
  • A custom distributed file system

Those systems are still running…

Tofu is the same approach, but built in Zig from scratch.

What It Is

Asynchronous communication library:

  • Message-based
  • Duplex
  • Peer-to-peer
  • Multithread-safe

You:

  • Don’t manage sockets.
  • Don’t call Io.Threaded or Io.Evented or similar level APIs.
  • Work with messages as API.

Why It Exists

In large systems, messaging is plumbing.
Critical
Invisible

(almost as invisible as the developer who builds it.)

Nobody thinks about it until it breaks.

A developer of raster image processing should not need to know epoll, or (sorry) Io.Evented magic.

Send a message and get back to work. That’s all.

Tofu hides the transport.

Developers use understandable terms for building different communication scenarios.

Same protocol-level thinking as HTTP, just not hostile to the developer.

Tofu’s mantra: “Connect your developers. Then connect your applications.”

Read the Mantra page to see what this looks like in practice.

Why I’m Posting This

This is not a typical showcase.

Maybe Zig will never be used for big boring enterprise systems.
Maybe it will.

I don’t know.

I checked my niche.

Zig works for network infrastructure the same way C++ and C# did.

Other niches — check yours.

Who is interested — the docs are there.

Shortcuts

7 Likes

why the oppositional stance towards std.Io? given that it hasn’t landed in a stable 0.16, this strikes me as odd, so i’m curious.

My point — app developers don’t need (and don’t want) to know low-level APIs from another domain.

epoll, Io.Evented — just examples.

No opposition - Opposite — I plan to use Io.Evented as Tofu’s backend when it’s ready.

And Tofu’s API won’t change

1 Like

The point of Io is that is hide those low level api’s, though Io isn’t high level either.

1 Like

Exactly.

And Tofu is the next layer up — where my former colleagues actually want to work.

Also — Tofu’s API depends on the language, not on std. So std breaking changes don’t break user code.

Only I will be victim :rofl:

see Sacrifice One Person pattern

3 Likes

This seems very similar to RabbitMQ but as a library instead of a service.

2 Likes