http.zig
libxev
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
http.zig
-
Epoll: The API that powers the modern internet (2022)
I have a somewhat popular HTTP server library for Zig [1]. It started off as a thread-per-connection (with an optional thread pool), but when it became apparent that async wasn't going to be added back into the language any time soon, I switched to using epoll/kqueue.
Both APIs allow you to associate arbitrary data (void ) with the event that you're registering. So when you're notified of the event, you can access this data. In my case, it's a big Conn struct. It contains things like the # of requests on this connection (to enforce a configured max request per connection), a timestamp where it should timeout if there's no activity. The Conn is part of an intrusive linked list, so it has a next: Conn and prev: *Conn. But, what you're probably most curious about, is that it has a Request.State. This has a static buffer ([]u8) that can grow as needed to hold all the received data up until that point (or if we're writing the data, then the buffered data that we have to write). It's important to have a max # of connections and a max request size so you can enforce an upper limit on the maximum memory the library might use. It acts as a state machine to track up to what point it's parsed the request. (since you don't want to have to re-parse the entire request as more bytes trickle in).
It's all half-baked. I can do receiving/sending asynchronously, but the application handler is called synchronously, and if that, for example, calls PG, that's probably also synchronous (since there's no async PG library in Zig). Makes me feel that any modern language needs a cohensive (as in standard library, or de facto standard) concurrency story.
[1] https://github.com/karlseguin/http.zig
-
0.11.0 Release Notes
I took a year off, and one of the things I did was learn Zig. I've built a number of libraries, including one of the currently more popular HTTP server libraries (https://github.com/karlseguin/http.zig).
A number of my libraries are used for https://www.aolium.com/ which I decided to write for myself.
I try to write a bit every day with the benefit that I can "waste" time digging into things or exploring likely-to-fail paths.
libxev
-
libxev: A cross-platform, high-performance event loop
io_uring support is obviously great & excellent, fulfills the "high performance" part well.
i was not expecting "Wasm + WASI" support at all. that's very cool. implementation is wasi_poll.zig (https://github.com/mitchellh/libxev/blob/main/src/backend/wa...). not to be unkind, but this makes me wonder very much if WASI is already missing the mark, if polling is the solution offered.
gotta say, this is some very understandable clean code. further enhancing my sense that i really ought be playing with zig.
- Show HN: Async tasks in 350 lines of C
-
Epoll: The API that powers the modern internet (2022)
You might be interested in a pure Zig implementation of these primitives by Mitchell in his libxev library: https://github.com/mitchellh/libxev
-
Zig: The Modern Alternative to C
https://github.com/mitchellh/libxev
- one from the Tigerbeetle DB
- Libxev: A cross-platform, high-performance event loop
What are some alternatives?
ctregex.zig - Compile time regular expressions in zig
unzig - Zig with Unused Variables
zeroman
async_io_uring - An event loop in Zig using io_uring and coroutines
zigself - An implementation of the Self programming language in Zig
sokol-tools - Command line tools for use with sokol headers
meduza - 🦎 🧜♀️ Zig codebase graph generator that emits a Mermaid class diagram.
zig-pico - Not so scuffed Zig project for using the Raspberry Pi Pico SDK
libvlc-zig - Zig bindings for libVLC media framework.
mach - zig game engine & graphics toolkit
zig-gorillas - A clone of the classic QBasic Gorillas written in the Zig programming language
aviary.sh - Minimal distributed configuration management in bash