devout: write uevent KEY=value format to clients

This commit is contained in:
Daniel Barlow 2024-04-26 17:37:28 +01:00
parent b33249a050
commit 324465bc18

View file

@ -21,6 +21,15 @@
(k:lower) v) (k:lower) v)
(tset :path (string.sub s (+ at 1) (- nl 1)))))) (tset :path (string.sub s (+ at 1) (- nl 1))))))
(fn format-event [e]
(..
(string.format "%s@%s\0" e.action e.path)
(table.concat
(icollect [k v (pairs e)]
(string.format "%s=%s" (string.upper k) v ))
"\n")))
(fn event-matches? [e terms] (fn event-matches? [e terms]
(accumulate [match? true (accumulate [match? true
name value (pairs terms)] name value (pairs terms)]
@ -102,7 +111,7 @@
(db:subscribe (db:subscribe
client client
(fn [e] (fn [e]
(ll.write client (view e))) (ll.write client (format-event e)))
(parse-terms s)) (parse-terms s))
true) true)
(nil err) (do (print err) false))) (nil err) (do (print err) false)))