I’ve been integrating zio into more real-world projects, now I have HTTP client and server, NATS client, PostgreSQL. Whenever I do it, I think about migration path to std.Io and there is a repeating pattern of problems, timeouts.
Pretty much any production server needs to have timeouts on everything. Blocking forever is simply not an option. In my view, that’s one of the differentiating factors between a toy and a system, that somebody is able to support in production environments.
And it’s where the interface lacks. I’m looking for options how to make it usable for server applications. I’m happy to help pushing the change forward, as it’s really important to me.
The easy targets are timedWait on Conditon and Event. The futex operations in the vtable already support timeouts, so it’s just a matter of exposing that.
Network timeouts are harder, due to the difference between blocking syscalls and event loops. In blocking mode, you typically set timeouts on the socket directly and the OS respects them. So it’s a per-socket setting. In the evented world, you typically set timeouts for each operation, as they are implemented as timers. In the case of io_uring the timers can be directly linked the operating, but it’s still per operation. I’d really like to add timeout to e.g. netRead but that might he hard to implement in the threaded version without a separate syscall per operation.
For example, netConnect has timeout option, but it’s actually not implemented in the threaded version.
The alternative would be the change interface to use “fat” handles, containing not just the file descriptor, but also timeout info. In the case of blocking, it could be set after conmecting, for evented it would he used per operation.
Or maybe even just netSetReadTimeout and expect the evented impl to remember it somewhere internally.
Anybody with ideas about this?