simplify protocol for watchers of service output directories

Previously: the service wrote a timestamp and the receiver
read and parsed it to see if there was new data

Now: the service writes and removes a .lock file to prevent
the receiver reading partial data. The receiver is responsible
for remembering the *previous* state and only updating if it's changed
This commit is contained in:
Daniel Barlow
2023-07-02 00:52:18 +01:00
parent 5532144747
commit 3900683413
2 changed files with 83 additions and 51 deletions

View File

@@ -56,8 +56,9 @@
"unbound" false
"stopped" false
_ true)]
(write-value "last-update" (tostring (os.time)))
(write-value ".lock" (tostring (os.time)))
(write-value "ifname" ifname)
(write-value "state" state)
(os.remove (.. state-directory "/.lock"))
(when ready
(with-open [fd (io.open "/proc/self/fd/10" :w)] (fd:write "\n"))))