Come up with sane way of having event loop monitoring configuration change events
Currently peacockr re-loads data each timer tick (I believe it is one second), but e.g. configuration is not usually changed every second. I propose introducing event loop with inotify
watching configuration file changes.
This come with several design decisions. As we preferably want to control the subscriptions, we need another event stream and such, to not waste CPU cycles requires some levels of wait-for-event.
Rust actually has a nice inotify
crate, but that one is either non-blocking or blocking on the single »event« and it doesn't even provide any timeout. One option would be to use tokio
runtime which it is compatible with, but I find it overkill for such thing as monitoring configuration change.
Otherwise, we can do the entire event loop manually and that either by using some epoll
wrapper or io-uring
. Both do require a bit of unsafe code, io-uring
bit more. For the message queue we could utilize eventfd
which we can also try to read. Or we can try using another runtime, but most of them are also kinda icky to use with raw file descriptors (which we kinda need if we want to do more with the inotify
crate than just straight up blocking or nonblocking read).