Closed notramo closed 8 months ago
The issue is the application code.
fn about(_: *httpz.Request, res: *httpz.Response) !void {
var file = try std.fs.cwd().openFile("example/index.html", .{});
defer file.close();
res.body = try file.readToEndAlloc(res.arena, 100000);
}
Until std
itself is async, and the libraries (like pg.zig) are async, it's a bit pointless. http.zig itself can be async (and it is), and that helps with protection from DOS and slow clients, but it's an incomplete solution until the entire ecosystem is async.
An update. While still not using libxev
, the current state of the master branch is that socket reading/writing is async (using epoll or kqueue) and application handlers are executing through a threadpool.
I just found this Zig library for async I/O. https://github.com/mitchellh/libxev Since async is not in Zig language yet, is it a viable substitute?