UNIX-socket boundary: accepts hook arrivals and hands each decoded event to an injected dispatch fn.
The dispatch fn is an argument rather than a direct hive-events call, so
the accept loop is exercised in tests against a recording fn and carries no
dependency on the event system it feeds.
Binding follows STD-04 T2/T3 through hive-system.network.unix: the socket directory is 0700, the socket 0600, and an existing path is connect-probed first. A stale socket is replaced; a LIVE one is never unlinked, so a second listener on the same path does not start and the first keeps receiving.
The adapter's bind! and close-server! take a lock file with no deadline.
Addon init and shutdown must not hang on it, so both run on a helper
thread with a deadline (bind-deadline-ms): past it the listener is left
not started (bind), or its channel is closed without the unlink (close;
the next bind probes the file stale and removes it).
UNIX-socket boundary: accepts hook arrivals and hands each decoded event to an injected dispatch fn. The dispatch fn is an argument rather than a direct `hive-events` call, so the accept loop is exercised in tests against a recording fn and carries no dependency on the event system it feeds. Binding follows STD-04 T2/T3 through hive-system.network.unix: the socket directory is 0700, the socket 0600, and an existing path is connect-probed first. A stale socket is replaced; a LIVE one is never unlinked, so a second listener on the same path does not start and the first keeps receiving. The adapter's bind! and close-server! take a lock file with no deadline. Addon init and shutdown must not hang on it, so both run on a helper thread with a deadline (`bind-deadline-ms`): past it the listener is left not started (bind), or its channel is closed without the unlink (close; the next bind probes the file stale and removes it).
Longest wait for the adapter's bind or close, both of which take a lock file with no deadline of their own.
Longest wait for the adapter's bind or close, both of which take a lock file with no deadline of their own.
(start! socket-path dispatch!)(start! socket-path
dispatch!
{:keys [deadline-ms] :or {deadline-ms bind-deadline-ms}})Bind SOCKET-PATH (STD-04 T3, see the ns docstring) and serve arrivals to DISPATCH! until stopped.
Returns a map carrying the server and the accept thread; pass it to
stop!. Returns nil, and logs why, when the listener did not start: a
live listener already answers on the path (it is left alone), the path
is not a socket, or the bind passed its deadline. Never unlinks a live
socket. OPTS: :deadline-ms (default bind-deadline-ms).
Bind SOCKET-PATH (STD-04 T3, see the ns docstring) and serve arrivals to DISPATCH! until stopped. Returns a map carrying the server and the accept thread; pass it to `stop!`. Returns nil, and logs why, when the listener did not start: a live listener already answers on the path (it is left alone), the path is not a socket, or the bind passed its deadline. Never unlinks a live socket. OPTS: :deadline-ms (default `bind-deadline-ms`).
(stop! {:keys [server running bound] :as l})Close the listener started by start! and unlink its socket file, but
only while the file is still this listener's socket (a later listener's
live socket on the same path is left alone).
Idempotent: stopping an already-stopped (or never-started, nil) listener is a no-op rather than an error, so addon shutdown need not track whether start succeeded. The unlink runs under the adapter's lock with a deadline; past it the channel is closed and the file left for the next bind to probe stale.
Close the listener started by `start!` and unlink its socket file, but only while the file is still this listener's socket (a later listener's live socket on the same path is left alone). Idempotent: stopping an already-stopped (or never-started, nil) listener is a no-op rather than an error, so addon shutdown need not track whether start succeeded. The unlink runs under the adapter's lock with a deadline; past it the channel is closed and the file left for the next bind to probe stale.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |