{"id":31730771,"url":"https://github.com/g41797/tofu","last_synced_at":"2026-01-31T05:31:48.610Z","repository":{"id":296519143,"uuid":"993661279","full_name":"g41797/tofu","owner":"g41797","description":"Tofu - Async messaging for Zig","archived":false,"fork":false,"pushed_at":"2026-01-21T12:13:16.000Z","size":11728,"stargazers_count":19,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-24T20:41:37.121Z","etag":null,"topics":["async","messaging","protocol","zig-library","zig-package"],"latest_commit_sha":null,"homepage":"https://g41797.github.io/tofu/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g41797.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-31T08:37:07.000Z","updated_at":"2026-01-21T12:13:27.000Z","dependencies_parsed_at":"2025-07-02T11:21:59.939Z","dependency_job_id":"c524c0a1-2f61-4c6a-9d91-e26a27d0e773","html_url":"https://github.com/g41797/tofu","commit_stats":null,"previous_names":["g41797/zyamp","g41797/yaaamp","g41797/tofu"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/g41797/tofu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g41797%2Ftofu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g41797%2Ftofu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g41797%2Ftofu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g41797%2Ftofu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g41797","download_url":"https://codeload.github.com/g41797/tofu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g41797%2Ftofu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28930367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T04:05:25.756Z","status":"ssl_error","status_checked_at":"2026-01-31T04:02:35.005Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","messaging","protocol","zig-library","zig-package"],"created_at":"2025-10-09T07:40:36.612Z","updated_at":"2026-01-31T05:31:48.604Z","avatar_url":"https://github.com/g41797.png","language":"Zig","funding_links":[],"categories":["Zig"],"sub_categories":[],"readme":"![](_logo/Ziggy_And_Zero_Are_Cooking_Tofu.png)\n# **_Tofu - Sync your devs, Async your apps_**!\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Linux](https://github.com/g41797/yaaamp/actions/workflows/linux.yml/badge.svg)](https://github.com/g41797/yaaamp/actions/workflows/linux.yml)\n\u003c!-- [![MacOS](https://github.com/g41797/yaaamp/actions/workflows/mac.yml/badge.svg)](https://github.com/g41797/yaaamp/actions/workflows/mac.yml) --\u003e\n\n---\n\n**tofu** is a _protocol_ and an _asynchronous_ **Zig messaging library** used to:\n\n- Build **custom** communication flows.\n- Create **non-blocking** systems.\n- Enable **peer-to-peer** messaging between applications.\n\n**tofu** is a completely new project. It is not a port of old code, and it does not use any C libraries.\nIt is built **100% in native Zig**. The core functionality uses only the standard library.\n\n---\n\n## Why tofu?\n\nAs a food, **tofu** is simple and doesn’t have much flavor on its own.  \nWith tofu cubes, you can:\n\n- Eat them plain as an easy snack.\n- Add some spice to make them better.\n- Cook up something really tasty.\n\n\nAs a **protocol**, tofu uses **messages** like cubes. By \"cooking\" these messages together, you can grow your project:\n\n- Start with **minimal setups**.\n- Build **complex flows**.\n- Create full **distributed applications**.\n\n\u003e [!IMPORTANT]\n\u003e **tofu** is as good as you are a cook.\n\n---\n\n## A Bit of History\n\n**tofu** did not come from nowhere.\n\nThe journey began in 2008 when I first built a similar system. I maintained and ran that system\nfor many years in high-stakes environments. It powered everything from basic IPC to complex data transfers in a custom distributed file system.\n\nI left that project a few years ago, but I haven't heard any complaints yet — the systems are still running strong.\n\nCorporate lawyers can stay calm: I didn't take any code. I only took the \"**smell**.\"\n(See the [precedent case about paying for a smell](http://fable1001.blogspot.com/2009/11/nasreddin-hodja-smell-of-soup-and-sound.html)).\n\nBy \"**smell**,\" I mean the core philosophy:\n\n- **The Message is the API**: The data itself defines the connection.\n- **Gradual Evolution**: Start with something simple and grow it into a powerful system over time.\n- **The Mantra**: \"Connect your developers. Then connect your applications.\"\n\n\n## \"Connect your developers. Then connect your applications.\"\n\nThis **tofu** mantra is a paraphrase of [Conway's Law](https://en.wikipedia.org/wiki/Conway%27s_law). \n\n**tofu** \"expects\" that development starts with a conversation (_connection_) similar to the one shown below.\n\n**Context:**\n\n- Two developers are discussing the message flow for a new Print Server.\n- The first one is the _Spool Server_ developer (**S**).\n- The second one develops the _RIP Worker Process_ (**R**).\n- Don’t worry — RIP means *Raster Image Processing*, not what you might think.\n- Some terms may be unknown — that’s fine. These two know exactly what they mean.\n\nThis dialog is shown without the usual jokes or side comments common in real programmer discussions — just the technical part.\n\n```\nS: I don't know the addresses of the workers, so you should connect to me.\n\nR: I'll send a HelloRequest, because the worker can process only specific PDL types,\n   the PDL header will contain either PS or PDF.\n\nS: Do I need to send you a HelloResponse?\n\nR: No, just start sending me messages with PDL data.\n\nS: As signals?\n\nR: No, as multi-requests — each with a message ID equal to the job ID.\n\nS: You forgot the Job Ticket.\n\nR: Right. The first request should have a JobTicket header (JDF or PPD) and the\n   ticket data in the body. The following requests will have the PDL header\n   (PDF or PS) with the related content.\n\nS: But JDF is usually used only for PDF...\n\nR: Yes, but let's keep it flexible.\n\nS: Can you process several jobs simultaneously?\n\nR: It depends on licensing. Anyway, if I can, I'll send another HelloRequest —\n   working one job per channel looks cleaner.\n\nS: I need a progress indicator.\n\nR: No problem. I'll send signals with the same message ID — the Progress header\n   will show the range [N:M] for page numbers.\n\nS: On job finish, send me a Response with the same message ID and processing status.\n   Also include the Progress header.\n\nR: Why should I send an obsolete message? Are you expecting a graceful close?\n\nS: Of course.\n\nR: Then I'll send a ByeRequest with the same information, and you'll send me a\n   ByeResponse. After that connection will be automatically aborted.\n\nS: That's enough for today. Send me a short text file with this protocol —\n   I'll save it in Git.\n\nR: Deal. How about a cup of coffee?\n```\n\nI hope you got the point without long smart descriptions or advertising.\n\n\n## Features\n \n- **Message-Based**: Uses discrete messages for communication.\n- **Asynchronous**: Enables non-blocking message exchanges.\n- **Duplex**: Supports two-way communication.\n- **Peer-to-Peer**: Allows equal roles after connection establishment.\n- **Stream oriented transport** - TCP/IP and **U**nix **D**omain **S**ockets\n- **Multithread-friendly** - All APIs are safe for concurrent access.\n- **Memory management for messages** - internal message pool\n- **Backpressure management** - allows to control receive of messages\n- **Customizable application flows** - allows to build various application flows not restricted to request/response or pub/sub\n- **Simplest API** - you don't have to bother with or know the \"guts\" of socket interfaces\n\n\nDocumentation and examples are available on the [Tofu documentation site](https://g41797.github.io/tofu/).\n\nFor the impatient:\n\n- [your first server](https://g41797.github.io/tofu/mds/your-first-server/)\n- [your first client](https://g41797.github.io/tofu/mds/your-first-client/)\n\n---\n\n## Credits\n- [Karl Seguin](https://github.com/karlseguin) — for introducing me to [Zig networking](https://www.openmymind.net/TCP-Server-In-Zig-Part-1-Single-Threaded/)\n- [tardy](https://github.com/tardy-org/tardy) — I peeked into 2 files of the project (the author will guess which ones)\n- [temp.zig](https://github.com/abhinav/temp.zig) — helped me (and will help you) work with temporary files\n- [Gemini AI image generator](https://gemini.google.com/app) — the only one out of six I managed to convince to seat Ziggy and Zero at the same table\n- Zig Community Forums (in order of my registration) - for your help and patience with my posts\n  - [Zig on Reddit](https://www.reddit.com/r/Zig/)\n  - [Zig on Discord](https://discord.com/invite/zig)\n  - [Zig on Discourse](https://ziggit.dev/)\n\n---\n\n## Last but not least\n⭐️ Like, share, and don’t forget to [subscribe to the channel](https://github.com/g41797/tofu) !\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg41797%2Ftofu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg41797%2Ftofu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg41797%2Ftofu/lists"}